Shun Miyazawa 4 лет назад
Родитель
Сommit
90d6f74da1

+ 4 - 3
packages/app/src/components/InAppNotification/PageNotification/PageModelNotification.tsx

@@ -1,7 +1,7 @@
 import React, { FC, useCallback } from 'react';
 import { PagePathLabel } from '@growi/ui';
 import { apiv3Post } from '~/client/util/apiv3-client';
-import { getSnapshotPagePath } from '../../../models/serializers/in-app-notification-snapshot/page';
+import { parseSnapshot } from '../../../models/serializers/in-app-notification-snapshot/page';
 import { IInAppNotification } from '~/interfaces/in-app-notification';
 import { HasObjectId } from '~/interfaces/has-object-id';
 import FormattedDistanceDate from '../../FormattedDistanceDate';
@@ -18,7 +18,8 @@ const PageModelNotification: FC<Props> = (props: Props) => {
     notification, actionMsg, actionIcon, actionUsers,
   } = props;
 
-  const pagePath = getSnapshotPagePath(notification.snapshot);
+  const snapshot = parseSnapshot(notification.snapshot);
+  const pagePath = { path: snapshot.path };
 
   const notificationClickHandler = useCallback(() => {
     // set notification status "OPEND"
@@ -35,7 +36,7 @@ const PageModelNotification: FC<Props> = (props: Props) => {
     <div className="p-2">
       <div onClick={notificationClickHandler}>
         <div>
-          <b>{actionUsers}</b> {actionMsg} <PagePathLabel page={{ path: pagePath }} />
+          <b>{actionUsers}</b> {actionMsg} <PagePathLabel page={pagePath} />
         </div>
         <i className={`${actionIcon} mr-2`} />
         <FormattedDistanceDate

+ 3 - 3
packages/app/src/models/serializers/in-app-notification-snapshot/page.ts

@@ -5,13 +5,13 @@ export interface IPageSnapshot {
   creator: IUser
 }
 
-export const stringifyPageModel = (page: IPageSnapshot): string => {
+export const stringifySnapshot = (page: IPageSnapshot): string => {
   return JSON.stringify({
     path: page.path,
     creator: page.creator,
   });
 };
 
-export const getSnapshotPagePath = (snapshot: string): string => {
-  return JSON.parse(snapshot).path;
+export const parseSnapshot = (snapshot: string): IPageSnapshot => {
+  return JSON.parse(snapshot);
 };

+ 2 - 2
packages/app/src/server/service/comment.ts

@@ -4,7 +4,7 @@ import loggerFactory from '../../utils/logger';
 import ActivityDefine from '../util/activityDefine';
 import Crowi from '../crowi';
 
-import { stringifyPageModel } from '~/models/serializers/in-app-notification-snapshot/page';
+import { stringifySnapshot } from '~/models/serializers/in-app-notification-snapshot/page';
 
 const logger = loggerFactory('growi:service:CommentService');
 
@@ -91,7 +91,7 @@ class CommentService {
   };
 
   private createAndSendNotifications = async function(activity, page) {
-    const snapshot = stringifyPageModel(page);
+    const snapshot = stringifySnapshot(page);
 
     // Get user to be notified
     let targetUsers: Types.ObjectId[] = [];

+ 2 - 2
packages/app/src/server/service/page.js

@@ -2,7 +2,7 @@ import { pagePathUtils } from '@growi/core';
 import loggerFactory from '~/utils/logger';
 import ActivityDefine from '../util/activityDefine';
 
-import { stringifyPageModel } from '~/models/serializers/in-app-notification-snapshot/page';
+import { stringifySnapshot } from '~/models/serializers/in-app-notification-snapshot/page';
 
 const mongoose = require('mongoose');
 const escapeStringRegexp = require('escape-string-regexp');
@@ -812,7 +812,7 @@ class PageService {
   createAndSendNotifications = async function(page, user, action) {
     const { activityService, inAppNotificationService } = this.crowi;
 
-    const snapshot = stringifyPageModel(page);
+    const snapshot = stringifySnapshot(page);
 
     // Create activity
     const parameters = {