Przeglądaj źródła

create getSnapshotPagePath func

Shun Miyazawa 4 lat temu
rodzic
commit
f50e23b445

+ 3 - 3
packages/app/src/components/InAppNotification/renderTargetModel/page/RenderPageModelNotification.tsx

@@ -1,7 +1,7 @@
 import React, { useCallback } from 'react';
 import React, { useCallback } from 'react';
 import { PagePathLabel } from '@growi/ui';
 import { PagePathLabel } from '@growi/ui';
 import { apiv3Post } from '~/client/util/apiv3-client';
 import { apiv3Post } from '~/client/util/apiv3-client';
-
+import { getSnapshotPagePath } from './snapshot';
 import { IInAppNotification } from '~/interfaces/in-app-notification';
 import { IInAppNotification } from '~/interfaces/in-app-notification';
 import { HasObjectId } from '~/interfaces/has-object-id';
 import { HasObjectId } from '~/interfaces/has-object-id';
 import FormattedDistanceDate from '../../../FormattedDistanceDate';
 import FormattedDistanceDate from '../../../FormattedDistanceDate';
@@ -18,8 +18,8 @@ const RenderPageModelNotification = (props: Props): JSX.Element => {
     notification, actionMsg, actionIcon, actionUsers,
     notification, actionMsg, actionIcon, actionUsers,
   } = props;
   } = props;
 
 
-  const snapshot = JSON.parse(notification.snapshot);
-  const pagePath = { path: snapshot.path };
+  const snapshot = getSnapshotPagePath(notification.snapshot);
+  const pagePath = { path: snapshot };
 
 
   const notificationClickHandler = useCallback(() => {
   const notificationClickHandler = useCallback(() => {
     // set notification status "OPEND"
     // set notification status "OPEND"

+ 4 - 0
packages/app/src/components/InAppNotification/renderTargetModel/page/snapshot.ts

@@ -6,3 +6,7 @@ export const createSnapshot = (page: IPage): string => {
     creator: page.creator,
     creator: page.creator,
   });
   });
 };
 };
+
+export const getSnapshotPagePath = (snapshot: string): string => {
+  return JSON.parse(snapshot).path;
+};