Skip to content

Commit

Permalink
chore(): part of feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
themonster2015 committed May 7, 2024
1 parent bdb5c5f commit 4ea3b73
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 42 deletions.
16 changes: 16 additions & 0 deletions ui/apps/akasha/src/components/pages/entry-page/beam-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@ const BeamPage: React.FC<BeamPageProps> = props => {
<EditableReflectionResolver
reflectID={itemData.node.reflectionID}
beamID={beamId}
onContentClick={() => {
navigate({
to: '/reflection/$reflectionId',
params: {
reflectionId: itemData.node.reflectionID,
},
});
}}
onReflect={() => {
navigate({
to: '/reflection/$reflectionId/reflect',
params: {
reflectionId: itemData.node.reflectionID,
},
});
}}
/>
<ReflectionPreview
reflectionId={itemData.node.reflectionID}
Expand Down
16 changes: 16 additions & 0 deletions ui/apps/akasha/src/components/pages/entry-page/reflection-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@ const ReflectionPage: React.FC<ReflectionPageProps> = props => {
<EditableReflectionResolver
reflectID={itemData.node.reflectionID}
beamID={entryData.beam?.id}
onContentClick={() => {
navigate({
to: '/reflection/$reflectionId',
params: {
reflectionId: itemData.node.reflectionID,
},
});
}}
onReflect={() => {
navigate({
to: '/reflection/$reflectionId/reflect',
params: {
reflectionId: itemData.node.reflectionID,
},
});
}}
/>
<ReflectionPreview
reflectionId={itemData.node.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@ import EntryCardLoading from '@akashaorg/design-system-components/lib/components
export type EditableReflectionResolverProps = {
reflectID: string;
beamID: string;
onContentClick: () => void;
onReflect: () => void;
};

export const EditableReflectionResolver = (props: EditableReflectionResolverProps) => {
const { getRoutingPlugin } = useRootComponentProps();

export const EditableReflectionResolver = ({
reflectID,
beamID,
onContentClick,
onReflect,
}: EditableReflectionResolverProps) => {
const reflectionReq = useGetReflectionByIdQuery({
variables: {
id: props.reflectID,
id: reflectID,
},
fetchPolicy: 'cache-first',
skip: !props.reflectID,
skip: !reflectID,
});

if (reflectionReq.loading) return <EntryCardLoading />;
Expand All @@ -33,25 +38,8 @@ export const EditableReflectionResolver = (props: EditableReflectionResolverProp
entryData={mapReflectEntryData(entryData)}
reflectToId={mapReflectEntryData(entryData).id}
contentClickable={true}
onContentClick={() => {
if (hasOwn(reflectionReq.data?.node, 'id')) {
const reflectionId = reflectionReq.data.node.id;
return getRoutingPlugin().navigateTo({
appName: '@akashaorg/app-akasha-integration',
getNavigationUrl: navRoutes => `${navRoutes.Reflection}/${reflectionId}`,
});
}
}}
onReflect={() => {
if (hasOwn(reflectionReq.data?.node, 'id')) {
const reflectionId = reflectionReq.data.node.id;
getRoutingPlugin().navigateTo({
appName: '@akashaorg/app-akasha-integration',
getNavigationUrl: navRoutes =>
`${navRoutes.Reflection}/${reflectionId}${navRoutes.Reflect}`,
});
}
}}
onContentClick={onContentClick}
onReflect={onReflect}
/>
</React.Suspense>
);
Expand Down
21 changes: 3 additions & 18 deletions ui/lib/feed/src/components/editable-reflection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,19 @@ import {
useMentions,
useAkashaStore,
} from '@akashaorg/ui-awf-hooks';
import {
GetReflectionsFromBeamDocument,
GetReflectReflectionsDocument,
useUpdateAkashaReflectMutation,
} from '@akashaorg/ui-awf-hooks/lib/generated/apollo';
import { useUpdateAkashaReflectMutation } from '@akashaorg/ui-awf-hooks/lib/generated/apollo';
import { useTranslation } from 'react-i18next';
import {
AnalyticsCategories,
IPublishData,
NotificationTypes,
NotificationEvents,
} from '@akashaorg/typings/lib/ui';
import { useApolloClient } from '@apollo/client';
import { useCloseActions } from '@akashaorg/design-system-core/lib/utils';
import ErrorBoundary, {
ErrorBoundaryProps,
} from '@akashaorg/design-system-core/lib/components/ErrorBoundary';
import ReflectionEditorRenderer from './reflection-editor-renderer';

const MAX_EDIT_TIME_IN_MINUTES = 10;

Expand All @@ -49,9 +45,7 @@ const EditableReflection: React.FC<ReflectCardProps & { reflectToId: string }> =
const [isReflecting, setIsReflecting] = useState(true);

const sdk = getSDK();
const beamId = entryData.beamID;
const isReflectOfReflection = beamId !== reflectToId;
const apolloClient = useApolloClient();

const {
data: { authenticatedDID, authenticatedProfile },
} = useAkashaStore();
Expand All @@ -69,16 +63,7 @@ const EditableReflection: React.FC<ReflectCardProps & { reflectToId: string }> =
onCompleted: async () => {
setEdit(false);
setNewContent(null);
//reset the state modified inside Editor component when done
setIsReflecting(true);

if (!isReflectOfReflection) {
await apolloClient.refetchQueries({ include: [GetReflectionsFromBeamDocument] });
}

if (isReflectOfReflection) {
await apolloClient.refetchQueries({ include: [GetReflectReflectionsDocument] });
}
analyticsActions.trackEvent({
category: AnalyticsCategories.REFLECT,
action: 'Reflect Updated',
Expand Down

0 comments on commit 4ea3b73

Please sign in to comment.