jam411 3 лет назад
Родитель
Сommit
cf449e1370

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

@@ -55,7 +55,7 @@ const PageEditor = React.memo((): JSX.Element => {
   const { data: currentPagePath } = useCurrentPagePath();
   const { data: currentPathname } = useCurrentPathname();
   const { data: currentPage, mutate: mutateCurrentPage } = useSWRxCurrentPage();
-  const { data: editingMarkdown } = useEditingMarkdown();
+  const { data: editingMarkdown, mutate: mutateEditingMarkdown } = useEditingMarkdown();
   const { data: grantData, mutate: mutateGrant } = useSelectedGrant();
   const { data: pageTags } = usePageTagsForEditors(pageId);
 
@@ -116,6 +116,7 @@ const PageEditor = React.memo((): JSX.Element => {
     try {
       await saveOrUpdate(optionsToSave, { pageId, path: currentPagePath || currentPathname, revisionId: currentRevisionId }, markdownToSave.current);
       await mutateCurrentPage();
+      await mutateEditingMarkdown(markdownToSave.current);
       mutateIsEnabledUnsavedWarning(false);
       return true;
     }
@@ -134,7 +135,7 @@ const PageEditor = React.memo((): JSX.Element => {
     }
 
   // eslint-disable-next-line max-len
-  }, [grantData, isSlackEnabled, currentPathname, slackChannels, pageTags, pageId, currentPagePath, currentRevisionId, mutateCurrentPage, mutateIsEnabledUnsavedWarning]);
+  }, [grantData, isSlackEnabled, currentPathname, slackChannels, pageTags, pageId, currentPagePath, currentRevisionId, mutateCurrentPage, mutateEditingMarkdown, mutateIsEnabledUnsavedWarning]);
 
   const saveAndReturnToViewHandler = useCallback(async(opts?: {overwriteScopesOfDescendants: boolean}) => {
     if (editorMode !== EditorMode.Editor) {

+ 0 - 5
packages/app/src/stores/attachment.tsx

@@ -9,8 +9,6 @@ import useSWR from 'swr';
 import { apiPost } from '~/client/util/apiv1-client';
 import { apiv3Get } from '~/client/util/apiv3-client';
 import { IResAttachmentList } from '~/interfaces/attachment';
-import { useEditingMarkdown } from '~/stores/context';
-import { useSWRxCurrentPage } from '~/stores/page';
 
 type Util = {
   remove(body: { attachment_id: string }): Promise<void>
@@ -23,9 +21,6 @@ type IDataAttachmentList = {
 };
 
 export const useSWRxAttachments = (pageId?: Nullable<string>, pageNumber?: number): SWRResponseWithUtils<Util, IDataAttachmentList, Error> => {
-  const { data: currentPage } = useSWRxCurrentPage();
-  useEditingMarkdown(currentPage?.revision.body);
-
   const shouldFetch = pageId != null && pageNumber != null;
 
   const fetcher = useCallback(async(endpoint, pageId, pageNumber) => {