Skip to content

Commit

Permalink
Merge branch 'next' into improve-virtual-list-and-scroll-restoration-…
Browse files Browse the repository at this point in the history
…on-antenna-app
  • Loading branch information
didd committed May 8, 2024
2 parents 58870d2 + a3bbeb7 commit 015b5c9
Show file tree
Hide file tree
Showing 85 changed files with 922 additions and 947 deletions.
8 changes: 0 additions & 8 deletions ui/apps/akasha/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import '../jest.setup';

import { genLoggedInState } from '@akashaorg/af-testing';
import * as loginHooks from '@akashaorg/ui-awf-hooks/lib/use-login.new';
import * as mediaHooks from '@akashaorg/ui-awf-hooks/lib/utils/media-utils';

jest.mock('@akashaorg/typings/lib/ui', () => ({
Expand Down Expand Up @@ -38,13 +37,6 @@ jest
.spyOn(mediaHooks, 'getMediaUrl')
.mockReturnValue({ originLink: '', fallbackLink: '', pathLink: '' });

jest.spyOn(loginHooks, 'useGetLogin').mockReturnValue({
data: { ...genLoggedInState(true) },
status: 'success',
isSuccess: true,
reported: true,
});

const mockIntersectionObserver = jest.fn();

mockIntersectionObserver.mockReturnValue({
Expand Down
8 changes: 5 additions & 3 deletions ui/apps/akasha/src/components/app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { I18nextProvider } from 'react-i18next';
import { useGetLogin, useRootComponentProps } from '@akashaorg/ui-awf-hooks';
import { useAkashaStore, useRootComponentProps } from '@akashaorg/ui-awf-hooks';
import { router } from './app-routes';
import { RouterProvider } from '@tanstack/react-router';
import { useApolloClient } from '@apollo/client';
Expand All @@ -14,15 +14,17 @@ declare module '@tanstack/react-router' {
const SocialApp: React.FC<unknown> = () => {
const { getTranslationPlugin, baseRouteName } = useRootComponentProps();
const apolloClient = useApolloClient();
const login = useGetLogin();
const {
data: { authenticatedDID },
} = useAkashaStore();

return (
<I18nextProvider i18n={getTranslationPlugin().i18n}>
<RouterProvider
router={router({
baseRouteName,
apolloClient,
authenticatedDID: login.data?.id ?? '',
authenticatedDID,
})}
/>
</I18nextProvider>
Expand Down
10 changes: 6 additions & 4 deletions ui/apps/akasha/src/components/pages/editor-page/editor-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ import ErrorLoader from '@akashaorg/design-system-core/lib/components/ErrorLoade
import Button from '@akashaorg/design-system-core/lib/components/Button';
import { useTranslation } from 'react-i18next';
import { Extension } from '@akashaorg/ui-lib-extensions/lib/react/extension';
import { useGetLogin, useRootComponentProps } from '@akashaorg/ui-awf-hooks';
import { useAkashaStore, useRootComponentProps } from '@akashaorg/ui-awf-hooks';
import { Helmet, HelmetProvider } from 'react-helmet-async';

const EditorPage: React.FC<unknown> = () => {
const { data } = useGetLogin();
const authenticatedDID = data?.id;
const {
data: { authenticatedDID },
} = useAkashaStore();
const { getRoutingPlugin } = useRootComponentProps();
const navigateTo = React.useRef(getRoutingPlugin().navigateTo);
const { t } = useTranslation();

return (
<HelmetProvider>
<Stack fullWidth={true}>
<Helmet>
<title>Beam Editor</title>
<title>{t('Beam Editor')}</title>
</Helmet>
{!authenticatedDID && (
<Stack>
Expand Down
8 changes: 5 additions & 3 deletions ui/apps/akasha/src/components/pages/entry-page/beam-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
hasOwn,
mapBeamEntryData,
mapReflectEntryData,
useAkashaStore,
useAnalytics,
useGetLogin,
useNsfwToggling,
useRootComponentProps,
} from '@akashaorg/ui-awf-hooks';
Expand All @@ -34,12 +34,14 @@ const BeamPage: React.FC<BeamPageProps> = props => {
const { beamId, beamStream, beam } = props;
const { t } = useTranslation('app-akasha-integration');
const { navigateToModal, getTranslationPlugin } = useRootComponentProps();
const { data, loading: authenticating } = useGetLogin();
const {
data: { authenticatedDID, isAuthenticating: authenticating },
} = useAkashaStore();
const { showNsfw } = useNsfwToggling();
const [analyticsActions] = useAnalytics();
const wrapperRef = useRef(null);
const navigate = useNavigate();
const isLoggedIn = !!data?.id;
const isLoggedIn = !!authenticatedDID;

/**
* Check the current moderation status of the beam
Expand Down
9 changes: 5 additions & 4 deletions ui/apps/akasha/src/components/pages/my-antenna-page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import ScrollTopWrapper from '@akashaorg/design-system-core/lib/components/Scrol
import ScrollTopButton from '@akashaorg/design-system-core/lib/components/ScrollTopButton';
import StartCard from '@akashaorg/design-system-components/lib/components/StartCard';
import { useTranslation } from 'react-i18next';
import { ModalNavigationOptions, Profile, QueryKeys } from '@akashaorg/typings/lib/ui';
import { ModalNavigationOptions, QueryKeys } from '@akashaorg/typings/lib/ui';
import { useGetInterestsByDidQuery } from '@akashaorg/ui-awf-hooks/lib/generated/apollo';
import { hasOwn, useGetLoginProfile, useRootComponentProps } from '@akashaorg/ui-awf-hooks';
import { hasOwn, useAkashaStore, useRootComponentProps } from '@akashaorg/ui-awf-hooks';
import { BeamContentResolver, TagFeed } from '@akashaorg/ui-lib-feed';
import { Helmet, HelmetProvider } from 'react-helmet-async';

Expand All @@ -15,8 +15,9 @@ const MY_ANTENNA_OVERSCAN = 10;
const MyAntennaPage: React.FC<unknown> = () => {
const { t } = useTranslation('app-akasha-integration');
const { getRoutingPlugin, navigateToModal, worldConfig } = useRootComponentProps();
const authenticatedProfileReq = useGetLoginProfile();
const authenticatedProfile: Profile = authenticatedProfileReq?.akashaProfile;
const {
data: { authenticatedProfile },
} = useAkashaStore();
const navigateTo = React.useRef(getRoutingPlugin().navigateTo);
const _navigateToModal = React.useRef(navigateToModal);
const showLoginModal = React.useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';
import {
hasOwn,
mapBeamEntryData,
useGetLoginProfile,
useAkashaStore,
useRootComponentProps,
} from '@akashaorg/ui-awf-hooks';
import { BeamCard, BeamFeed } from '@akashaorg/ui-lib-feed';
Expand All @@ -20,8 +20,10 @@ const ProfileFeedPage: React.FC<ProfileFeedPageProps> = props => {
const { profileDID } = props;
const { t } = useTranslation('app-akasha-integration');
const { getRoutingPlugin, worldConfig } = useRootComponentProps();
const authenticatedProfileReq = useGetLoginProfile();
const authenticatedProfile = authenticatedProfileReq?.akashaProfile;
const {
data: { authenticatedProfile },
} = useAkashaStore();

const profileUserName = React.useMemo(() => {
if (authenticatedProfile && authenticatedProfile.name) {
return authenticatedProfile.name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import getSDK from '@akashaorg/awf-sdk';
import { hasOwn, useGetLogin, useRootComponentProps } from '@akashaorg/ui-awf-hooks';
import { hasOwn, useAkashaStore, useRootComponentProps } from '@akashaorg/ui-awf-hooks';
import {
useGetIndexedStreamCountQuery,
useGetInterestsByDidQuery,
Expand All @@ -26,10 +26,11 @@ type TagFeedPageProps = {
const TagFeedPage: React.FC<TagFeedPageProps> = props => {
const { tagName } = props;
const { t } = useTranslation('app-akasha-integration');
const { data } = useGetLogin();
const {
data: { authenticatedDID },
} = useAkashaStore();
const { navigateToModal, worldConfig } = useRootComponentProps();
const isLoggedIn = !!data?.id;
const authenticatedDID = data?.id;
const isLoggedIn = !!authenticatedDID;
const _navigateToModal = React.useRef(navigateToModal);
const showLoginModal = React.useCallback(
(redirectTo?: { modal: ModalNavigationOptions }, message?: string) => {
Expand Down
13 changes: 5 additions & 8 deletions ui/apps/akasha/src/components/reflect-editor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React, { useMemo, useState } from 'react';
import React, { useState } from 'react';
import ReflectionEditor from '@akashaorg/design-system-components/lib/components/ReflectionEditor';
import getSDK from '@akashaorg/awf-sdk';
import {
transformSource,
encodeSlateToBase64,
useAnalytics,
decodeb64SlateContent,
useGetLoginProfile,
useRootComponentProps,
createReactiveVar,
useMentions,
useGetLogin,
useAkashaStore,
} from '@akashaorg/ui-awf-hooks';
import {
useCreateReflectMutation,
Expand Down Expand Up @@ -58,11 +57,9 @@ const ReflectEditor: React.FC<ReflectEditorProps> = props => {
const [indexReflection, indexReflectionMutation] = useIndexReflectionMutation();
const { addPendingReflection, pendingReflections } = usePendingReflections(pendingReflectionsVar);

const { data: authData } = useGetLogin();
const authenticatedDID = useMemo(() => authData?.id, [authData]);

const authenticatedProfileDataReq = useGetLoginProfile();
const authenticatedProfile = authenticatedProfileDataReq?.akashaProfile;
const {
data: { authenticatedDID, authenticatedProfile },
} = useAkashaStore();

const { setMentionQuery, mentions } = useMentions(authenticatedDID);
const handleGetMentions = (query: string) => {
Expand Down

0 comments on commit 015b5c9

Please sign in to comment.