Shun Miyazawa 2 лет назад
Родитель
Сommit
4ee2ac541a
2 измененных файлов с 7 добавлено и 1 удалено
  1. 3 1
      apps/app/src/pages/[[...path]].page.tsx
  2. 4 0
      apps/app/src/stores/page.tsx

+ 3 - 1
apps/app/src/pages/[[...path]].page.tsx

@@ -45,7 +45,7 @@ import {
 import { useEditingMarkdown } from '~/stores/editor';
 import {
   useSWRxCurrentPage, useSWRMUTxCurrentPage, useSWRxIsGrantNormalized, useCurrentPageId,
-  useIsNotFound, useIsLatestRevision, useTemplateTagData, useTemplateBodyData,
+  useIsNotFound, useIsLatestRevision, useTemplateTagData, useTemplateBodyData, useHasYjsDraft,
 } from '~/stores/page';
 import { useRedirectFrom } from '~/stores/page-redirect';
 import { useRemoteRevisionId } from '~/stores/remote-latest-page';
@@ -226,6 +226,8 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
   useIsUploadAllFileAllowed(props.isUploadAllFileAllowed);
   useIsUploadEnabled(props.isUploadEnabled);
 
+  useHasYjsDraft(props.hasYjsDraft);
+
   const { pageWithMeta } = props;
 
   const pageId = pageWithMeta?.data._id;

+ 4 - 0
apps/app/src/stores/page.tsx

@@ -52,6 +52,10 @@ export const useTemplateBodyData = (initialData?: string): SWRResponse<string, E
   return useSWRStatic<string, Error>('templateBodyData', initialData);
 };
 
+export const useHasYjsDraft = (initialData?: boolean): SWRResponse<boolean, Error> => {
+  return useSWRStatic<boolean, Error>('hasYjsDraft', initialData);
+};
+
 /** "useSWRxCurrentPage" is intended for initial data retrieval only. Use "useSWRMUTxCurrentPage" for revalidation */
 export const useSWRxCurrentPage = (initialData?: IPagePopulatedToShowRevision|null): SWRResponse<IPagePopulatedToShowRevision|null> => {
   const key = 'currentPage';