|
@@ -50,7 +50,7 @@ import {
|
|
|
import { useRedirectFrom } from '~/stores/page-redirect';
|
|
import { useRedirectFrom } from '~/stores/page-redirect';
|
|
|
import { useRemoteRevisionId } from '~/stores/remote-latest-page';
|
|
import { useRemoteRevisionId } from '~/stores/remote-latest-page';
|
|
|
import { useSetupGlobalSocket, useSetupGlobalSocketForPage } from '~/stores/websocket';
|
|
import { useSetupGlobalSocket, useSetupGlobalSocketForPage } from '~/stores/websocket';
|
|
|
-import { useCurrentPageYjsData } from '~/stores/yjs';
|
|
|
|
|
|
|
+import { useCurrentPageYjsData, useSWRMUTxCurrentPageYjsData } from '~/stores/yjs';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
import { BasicLayout } from '../components/Layout/BasicLayout';
|
|
import { BasicLayout } from '../components/Layout/BasicLayout';
|
|
@@ -236,6 +236,8 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
const { data: currentPage } = useSWRxCurrentPage(pageWithMeta?.data ?? null); // store initial data
|
|
const { data: currentPage } = useSWRxCurrentPage(pageWithMeta?.data ?? null); // store initial data
|
|
|
|
|
|
|
|
const { trigger: mutateCurrentPage } = useSWRMUTxCurrentPage();
|
|
const { trigger: mutateCurrentPage } = useSWRMUTxCurrentPage();
|
|
|
|
|
+ const { trigger: mutateCurrentPageYjsDataFromApi } = useSWRMUTxCurrentPageYjsData();
|
|
|
|
|
+
|
|
|
const { mutate: mutateEditingMarkdown } = useEditingMarkdown();
|
|
const { mutate: mutateEditingMarkdown } = useEditingMarkdown();
|
|
|
const { data: currentPageId, mutate: mutateCurrentPageId } = useCurrentPageId();
|
|
const { data: currentPageId, mutate: mutateCurrentPageId } = useCurrentPageId();
|
|
|
|
|
|
|
@@ -263,13 +265,14 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
const mutatePageData = async() => {
|
|
const mutatePageData = async() => {
|
|
|
const pageData = await mutateCurrentPage();
|
|
const pageData = await mutateCurrentPage();
|
|
|
mutateEditingMarkdown(pageData?.revision?.body);
|
|
mutateEditingMarkdown(pageData?.revision?.body);
|
|
|
|
|
+ mutateCurrentPageYjsDataFromApi();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// If skipSSR is true, use the API to retrieve page data.
|
|
// If skipSSR is true, use the API to retrieve page data.
|
|
|
// Because pageWIthMeta does not contain revision.body
|
|
// Because pageWIthMeta does not contain revision.body
|
|
|
mutatePageData();
|
|
mutatePageData();
|
|
|
}
|
|
}
|
|
|
- }, [currentPageId, mutateCurrentPage, mutateEditingMarkdown, props.isNotFound, props.skipSSR]);
|
|
|
|
|
|
|
+ }, [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
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|