jam411 3 лет назад
Родитель
Сommit
4b6a0a3226
2 измененных файлов с 6 добавлено и 5 удалено
  1. 2 2
      packages/app/src/pages/[[...path]].page.tsx
  2. 4 3
      packages/app/src/stores/page.tsx

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

@@ -243,10 +243,10 @@ const GrowiPage: NextPage<Props> = (props: Props) => {
   useCurrentPageId(pageId ?? null);
   // useIsNotCreatable(props.isForbidden || !isCreatablePage(pagePath)); // TODO: need to include props.isIdentical
   useCurrentPathname(props.currentPathname);
+  useCurrentRevisionId(props.currentRevisionId);
 
-  const { data: currentPage } = useSWRxCurrentPage(undefined, props.currentRevisionId, pageWithMeta?.data ?? null); // store initial data
+  const { data: currentPage } = useSWRxCurrentPage(undefined, pageWithMeta?.data ?? null); // store initial data
   useEditingMarkdown(pageWithMeta?.data.revision?.body ?? '');
-  useCurrentRevisionId(props.currentRevisionId);
 
   const { data: grantData } = useSWRxIsGrantNormalized(pageId);
   const { mutate: mutateSelectedGrant } = useSelectedGrant();

+ 4 - 3
packages/app/src/stores/page.tsx

@@ -15,7 +15,7 @@ import { IRevisionsForPagination } from '~/interfaces/revision';
 
 import { IPageTagsInfo } from '../interfaces/tag';
 
-import { useCurrentPageId, useCurrentPathname } from './context';
+import { useCurrentPageId, useCurrentPathname, useCurrentRevisionId } from './context';
 import { useStaticSWR } from './use-static-swr';
 
 const { isPermalink: _isPermalink } = pagePathUtils;
@@ -52,11 +52,12 @@ export const useSWRxPageByPath = (path?: string): SWRResponse<IPagePopulatedToSh
 };
 
 export const useSWRxCurrentPage = (
-    shareLinkId?: string, revisionId?: string, initialData?: IPagePopulatedToShowRevision|null,
+    shareLinkId?: string, initialData?: IPagePopulatedToShowRevision|null,
 ): SWRResponse<IPagePopulatedToShowRevision|null, Error> => {
   const { data: currentPageId } = useCurrentPageId();
+  const { data: currentRevisionId } = useCurrentRevisionId();
 
-  const swrResult = useSWRxPage(currentPageId, shareLinkId, revisionId, initialData);
+  const swrResult = useSWRxPage(currentPageId, shareLinkId, currentRevisionId, initialData);
 
   return swrResult;
 };