Yuken Tezuka 3 лет назад
Родитель
Сommit
e8fb756c43
1 измененных файлов с 4 добавлено и 10 удалено
  1. 4 10
      packages/app/src/components/Page/PageContents.tsx

+ 4 - 10
packages/app/src/components/Page/PageContents.tsx

@@ -4,6 +4,7 @@ import { pagePathUtils } from '@growi/core';
 import { useTranslation } from 'next-i18next';
 import type { HtmlElementNode } from 'rehype-toc';
 
+import { useUpdateStateAfterSave } from '~/client/services/page-operation';
 import { useDrawioModalLauncherForView } from '~/client/services/side-effects/drawio-modal-launcher-for-view';
 import { useHandsontableModalLauncherForView } from '~/client/services/side-effects/handsontable-modal-launcher-for-view';
 import { toastSuccess, toastError } from '~/client/util/toastr';
@@ -30,6 +31,7 @@ export const PageContents = (): JSX.Element => {
   const { data: currentPage, mutate: mutateCurrentPage } = useSWRxCurrentPage();
   const { mutate: mutateEditingMarkdown } = useEditingMarkdown();
   const { mutate: mutateCurrentPageTocNode } = useCurrentPageTocNode();
+  const updateStateAfterSave = useUpdateStateAfterSave(currentPage?._id);
 
   const { data: rendererOptions, mutate: mutateRendererOptions } = useViewOptions((toc: HtmlElementNode) => {
     mutateCurrentPageTocNode(toc);
@@ -50,11 +52,7 @@ export const PageContents = (): JSX.Element => {
     onSaveSuccess: (newMarkdown) => {
       toastSuccess(t('toaster.save_succeeded'));
 
-      // rerender
-      if (!isSharedPage) {
-        mutateCurrentPage();
-      }
-      mutateEditingMarkdown(newMarkdown);
+      updateStateAfterSave?.();
     },
     onSaveError: (error) => {
       toastError(error);
@@ -65,11 +63,7 @@ export const PageContents = (): JSX.Element => {
     onSaveSuccess: (newMarkdown) => {
       toastSuccess(t('toaster.save_succeeded'));
 
-      // rerender
-      if (!isSharedPage) {
-        mutateCurrentPage();
-      }
-      mutateEditingMarkdown(newMarkdown);
+      updateStateAfterSave?.();
     },
     onSaveError: (error) => {
       toastError(error);