Просмотр исходного кода

Merge pull request #7394 from weseek/fix/115652-page-body-is-blank-when-opening-editor-after-duplicating-page

fix: Page body is blank when opening editor after duplicating page
Yuki Takei 3 лет назад
Родитель
Сommit
8d97d525dd
2 измененных файлов с 6 добавлено и 8 удалено
  1. 5 2
      packages/app/src/pages/[[...path]].page.tsx
  2. 1 6
      packages/app/src/stores/editor.tsx

+ 5 - 2
packages/app/src/pages/[[...path]].page.tsx

@@ -272,9 +272,12 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
   }, [props.currentPathname, router]);
 
   // initialize mutateEditingMarkdown only once per page
+  // need to include useCurrentPathname not useCurrentPagePath
   useEffect(() => {
-    mutateEditingMarkdown(revisionBody);
-  }, [mutateEditingMarkdown, revisionBody]);
+    if (props.currentPathname != null) {
+      mutateEditingMarkdown(revisionBody);
+    }
+  }, [mutateEditingMarkdown, revisionBody, props.currentPathname]);
 
   const title = generateCustomTitleForPage(props, pagePath);
 

+ 1 - 6
packages/app/src/stores/editor.tsx

@@ -10,7 +10,6 @@ import { IEditorSettings } from '~/interfaces/editor-settings';
 import { SlackChannels } from '~/interfaces/user-trigger-notification';
 
 import {
-  useCurrentPathname,
   useCurrentUser, useDefaultIndentSize, useIsGuestUser,
 } from './context';
 // import { localStorageMiddleware } from './middlewares/sync-to-storage';
@@ -19,11 +18,7 @@ import { useStaticSWR } from './use-static-swr';
 
 
 export const useEditingMarkdown = (initialData?: string): SWRResponse<string, Error> => {
-  // need to include useCurrentPathname not useCurrentPagePath
-  // https://github.com/weseek/growi/pull/7301
-  const { data: currentPagePath } = useCurrentPathname();
-
-  return useStaticSWR(['editingMarkdown', currentPagePath], initialData);
+  return useStaticSWR('editingMarkdown', initialData);
 };