Sfoglia il codice sorgente

Merge pull request #4756 from weseek/feat/82492-prevent-transitions-to-pages-that-have-been-completely-deleted

feat: 82492 prevent transitions to pages that have been completely deleted
Yuki Takei 4 anni fa
parent
commit
ed41cfd229

+ 7 - 8
packages/app/src/components/InAppNotification/InAppNotificationElm.tsx

@@ -11,8 +11,7 @@ interface Props {
   notification: IInAppNotification & HasObjectId
 }
 
-// TODO 81946 Return to not nullable
-const InAppNotificationElm = (props: Props): JSX.Element | null => {
+const InAppNotificationElm = (props: Props): JSX.Element => {
 
   const { notification } = props;
 
@@ -63,16 +62,16 @@ const InAppNotificationElm = (props: Props): JSX.Element | null => {
     apiv3Post('/in-app-notification/open', { id: notification._id });
 
     // jump to target page
-    window.location.href = notification.target.path;
+    const targetPagePath = notification.target?.path;
+    if (targetPagePath != null) {
+      window.location.href = targetPagePath;
+    }
   }, []);
 
   const actionUsers = getActionUsers();
 
-  // TODO 81946 Return to not nullable
-  const pagePath = { path: props.notification.target?.path };
-  if (pagePath.path == null) {
-    return null;
-  }
+  // TODO: 82528 Swap target.path and snapshot.path
+  const pagePath = { path: 'test-page' };
 
   const actionType: string = notification.action;
   let actionMsg: string;