2
0
Shun Miyazawa 1 жил өмнө
parent
commit
477131bce8

+ 6 - 7
apps/app/src/pages/[[...path]].page.tsx

@@ -245,6 +245,7 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
   const { pageWithMeta } = props;
   const { pageWithMeta } = props;
 
 
   const pageId = pageWithMeta?.data._id;
   const pageId = pageWithMeta?.data._id;
+  const revisionId = pageWithMeta?.data.revision?._id;
   const revisionBody = pageWithMeta?.data.revision?.body;
   const revisionBody = pageWithMeta?.data.revision?.body;
 
 
   useCurrentPathname(props.currentPathname);
   useCurrentPathname(props.currentPathname);
@@ -277,7 +278,7 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
       return;
       return;
     }
     }
 
 
-    if (currentPageId != null && !props.isNotFound) {
+    if (currentPageId != null && revisionId != null && !props.isNotFound) {
       const mutatePageData = async() => {
       const mutatePageData = async() => {
         const pageData = await mutateCurrentPage();
         const pageData = await mutateCurrentPage();
         mutateEditingMarkdown(pageData?.revision?.body);
         mutateEditingMarkdown(pageData?.revision?.body);
@@ -288,11 +289,9 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
       // Because pageWIthMeta does not contain revision.body
       // Because pageWIthMeta does not contain revision.body
       mutatePageData();
       mutatePageData();
     }
     }
-
-  // Add pageWithMeta?.data.revision?._id to the dependency array as it should mutate when revisionId changes
   }, [
   }, [
-    currentPageId, mutateCurrentPage, mutateCurrentPageYjsDataFromApi, mutateEditingMarkdown,
-    props.isNotFound, props.skipSSR, pageWithMeta?.data.revision?._id,
+    revisionId, currentPageId, mutateCurrentPage,
+    mutateCurrentPageYjsDataFromApi, mutateEditingMarkdown, props.isNotFound, props.skipSSR,
   ]);
   ]);
 
 
   // sync pathname by Shallow Routing https://nextjs.org/docs/routing/shallow-routing
   // sync pathname by Shallow Routing https://nextjs.org/docs/routing/shallow-routing
@@ -313,8 +312,8 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
   }, [mutateEditingMarkdown, revisionBody, props.currentPathname]);
   }, [mutateEditingMarkdown, revisionBody, props.currentPathname]);
 
 
   useEffect(() => {
   useEffect(() => {
-    mutateRemoteRevisionId(pageWithMeta?.data.revision?._id);
-  }, [mutateRemoteRevisionId, pageWithMeta?.data.revision?._id]);
+    mutateRemoteRevisionId(revisionId);
+  }, [mutateRemoteRevisionId, revisionId]);
 
 
   useEffect(() => {
   useEffect(() => {
     mutateCurrentPageId(pageId ?? null);
     mutateCurrentPageId(pageId ?? null);