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

+ 4 - 2
packages/app/src/components/InAppNotification/InAppNotificationElm.tsx

@@ -9,12 +9,11 @@ import FormattedDistanceDate from '../FormattedDistanceDate';
 
 interface Props {
   notification: IInAppNotification & HasObjectId
-  pagePath: string
 }
 
 const InAppNotificationElm = (props: Props): JSX.Element => {
 
-  const { notification, pagePath } = props;
+  const { notification } = props;
 
   const getActionUsers = () => {
     const latestActionUsers = notification.actionUsers.slice(0, 3);
@@ -70,6 +69,9 @@ const InAppNotificationElm = (props: Props): JSX.Element => {
 
   const actionUsers = getActionUsers();
 
+  const snapshot = JSON.parse(notification.snapshot);
+  const pagePath = snapshot.path;
+
   const actionType: string = notification.action;
   let actionMsg: string;
   let actionIcon: string;

+ 5 - 11
packages/app/src/components/InAppNotification/InAppNotificationList.tsx

@@ -28,17 +28,11 @@ const InAppNotificationList: FC<Props> = (props: Props) => {
 
   const renderInAppNotificationList = () => {
     const inAppNotificationList = notifications.map((notification: IInAppNotification & HasObjectId) => {
-
-      if (notification.targetModel === 'Page') {
-        const snapshot = JSON.parse(notification.snapshot);
-
-        return (
-          <div className="d-flex flex-row" key={notification._id}>
-            <InAppNotificationElm notification={notification} pagePath={snapshot.path} />
-          </div>
-        );
-      }
-
+      return (
+        <div className="d-flex flex-row" key={notification._id}>
+          <InAppNotificationElm notification={notification} />
+        </div>
+      );
     });
 
     return inAppNotificationList;