Browse Source

Merge pull request #6523 from weseek/fix/103326-grant-err-when-page-updating

Fix/103326 grant err when page updating
cao 3 years ago
parent
commit
71497ce552

+ 16 - 2
packages/app/src/components/PageEditor.tsx

@@ -163,7 +163,7 @@ const PageEditor = React.memo((props: Props): JSX.Element => {
       logger.error('failed to save', error);
       logger.error('failed to save', error);
       // pageContainer.showErrorToastr(error);
       // pageContainer.showErrorToastr(error);
     }
     }
-  }, [grantData, isSlackEnabled, slackChannelsData, pageTags, mutateIsEnabledUnsavedWarning]);
+  }, [grantData, isSlackEnabled, slackChannels, pageTags, mutateIsEnabledUnsavedWarning]);
 
 
 
 
   /**
   /**
@@ -368,7 +368,21 @@ const PageEditor = React.memo((props: Props): JSX.Element => {
       optionsToSave = currentOptionsToSave;
       optionsToSave = currentOptionsToSave;
     }
     }
 
 
-    await saveAndReload(optionsToSave, { pageId, path: currentPagePath || currentPathname, revisionId: currentPage?.revision?._id }, markdown);
+    try {
+      await saveAndReload(optionsToSave, { pageId, path: currentPagePath || currentPathname, revisionId: currentPage?.revision?._id }, markdown);
+    }
+    catch (error) {
+      logger.error('failed to save', error);
+      // pageContainer.showErrorToastr(error);
+      if (error.code === 'conflict') {
+        // pageContainer.setState({
+        //   remoteRevisionId: error.data.revisionId,
+        //   remoteRevisionBody: error.data.revisionBody,
+        //   remoteRevisionUpdateAt: error.data.createdAt,
+        //   lastUpdateUser: error.data.user,
+        // });
+      }
+    }
   }, [currentPage?.revision?._id,
   }, [currentPage?.revision?._id,
       currentPagePath,
       currentPagePath,
       currentPathname,
       currentPathname,

+ 2 - 16
packages/app/src/components/SavePageControls.tsx

@@ -47,22 +47,8 @@ export const SavePageControls = (props: Props): JSX.Element | null => {
     // disable unsaved warning
     // disable unsaved warning
     mutateIsEnabledUnsavedWarning(false);
     mutateIsEnabledUnsavedWarning(false);
 
 
-    try {
-      // save
-      (window as CustomWindow).globalEmitter.emit('saveAndReload');
-    }
-    catch (error) {
-      logger.error('failed to save', error);
-      // pageContainer.showErrorToastr(error);
-      if (error.code === 'conflict') {
-        // pageContainer.setState({
-        //   remoteRevisionId: error.data.revisionId,
-        //   remoteRevisionBody: error.data.revisionBody,
-        //   remoteRevisionUpdateAt: error.data.createdAt,
-        //   lastUpdateUser: error.data.user,
-        // });
-      }
-    }
+    // save
+    (window as CustomWindow).globalEmitter.emit('saveAndReload');
   }, [mutateIsEnabledUnsavedWarning]);
   }, [mutateIsEnabledUnsavedWarning]);
 
 
   const saveAndOverwriteScopesOfDescendants = useCallback(() => {
   const saveAndOverwriteScopesOfDescendants = useCallback(() => {