|
@@ -30,19 +30,20 @@ import type { PageModel, PageDocument } from '~/server/models/page';
|
|
|
import type { PageRedirectModel } from '~/server/models/page-redirect';
|
|
import type { PageRedirectModel } from '~/server/models/page-redirect';
|
|
|
import {
|
|
import {
|
|
|
useCurrentUser,
|
|
useCurrentUser,
|
|
|
- useIsLatestRevision,
|
|
|
|
|
- useIsForbidden, useIsNotFound, useIsSharedUser,
|
|
|
|
|
|
|
+ useIsForbidden, useIsSharedUser,
|
|
|
useIsEnabledStaleNotification, useIsIdenticalPath,
|
|
useIsEnabledStaleNotification, useIsIdenticalPath,
|
|
|
useIsSearchServiceConfigured, useIsSearchServiceReachable, useDisableLinkSharing,
|
|
useIsSearchServiceConfigured, useIsSearchServiceReachable, useDisableLinkSharing,
|
|
|
useDrawioUri, useHackmdUri, useDefaultIndentSize, useIsIndentSizeForced,
|
|
useDrawioUri, useHackmdUri, useDefaultIndentSize, useIsIndentSizeForced,
|
|
|
useIsAclEnabled, useIsSearchPage, useTemplateTagData, useTemplateBodyData, useIsEnabledAttachTitleHeader,
|
|
useIsAclEnabled, useIsSearchPage, useTemplateTagData, useTemplateBodyData, useIsEnabledAttachTitleHeader,
|
|
|
- useCsrfToken, useIsSearchScopeChildrenAsDefault, useCurrentPageId, useCurrentPathname,
|
|
|
|
|
|
|
+ useCsrfToken, useIsSearchScopeChildrenAsDefault, useCurrentPathname,
|
|
|
useIsSlackConfigured, useRendererConfig,
|
|
useIsSlackConfigured, useRendererConfig,
|
|
|
useEditorConfig, useIsAllReplyShown, useIsUploadableFile, useIsUploadableImage, useIsContainerFluid, useIsNotCreatable,
|
|
useEditorConfig, useIsAllReplyShown, useIsUploadableFile, useIsUploadableImage, useIsContainerFluid, useIsNotCreatable,
|
|
|
} from '~/stores/context';
|
|
} from '~/stores/context';
|
|
|
import { useEditingMarkdown } from '~/stores/editor';
|
|
import { useEditingMarkdown } from '~/stores/editor';
|
|
|
import { useHasDraftOnHackmd, usePageIdOnHackmd, useRevisionIdHackmdSynced } from '~/stores/hackmd';
|
|
import { useHasDraftOnHackmd, usePageIdOnHackmd, useRevisionIdHackmdSynced } from '~/stores/hackmd';
|
|
|
-import { useSWRxCurrentPage, useSWRxIsGrantNormalized } from '~/stores/page';
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ useSWRxCurrentPage, useSWRxIsGrantNormalized, useCurrentPageId, useIsNotFound, useIsLatestRevision,
|
|
|
|
|
+} from '~/stores/page';
|
|
|
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 { useSelectedGrant } from '~/stores/ui';
|
|
import { useSelectedGrant } from '~/stores/ui';
|
|
@@ -190,11 +191,9 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
useCsrfToken(props.csrfToken);
|
|
useCsrfToken(props.csrfToken);
|
|
|
|
|
|
|
|
// page
|
|
// page
|
|
|
- useIsLatestRevision(props.isLatestRevision);
|
|
|
|
|
useIsContainerFluid(props.isContainerFluid);
|
|
useIsContainerFluid(props.isContainerFluid);
|
|
|
// useOwnerOfCurrentPage(props.pageUser != null ? JSON.parse(props.pageUser) : null);
|
|
// useOwnerOfCurrentPage(props.pageUser != null ? JSON.parse(props.pageUser) : null);
|
|
|
useIsForbidden(props.isForbidden);
|
|
useIsForbidden(props.isForbidden);
|
|
|
- useIsNotFound(props.isNotFound);
|
|
|
|
|
useIsNotCreatable(props.isNotCreatable);
|
|
useIsNotCreatable(props.isNotCreatable);
|
|
|
useRedirectFrom(props.redirectFrom ?? null);
|
|
useRedirectFrom(props.redirectFrom ?? null);
|
|
|
useIsSharedUser(false); // this page cann't be routed for '/share'
|
|
useIsSharedUser(false); // this page cann't be routed for '/share'
|
|
@@ -234,14 +233,18 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
const pagePath = pageWithMeta?.data.path ?? props.currentPathname;
|
|
const pagePath = pageWithMeta?.data.path ?? props.currentPathname;
|
|
|
const revisionBody = pageWithMeta?.data.revision?.body;
|
|
const revisionBody = pageWithMeta?.data.revision?.body;
|
|
|
|
|
|
|
|
- useCurrentPageId(pageId ?? null);
|
|
|
|
|
usePageIdOnHackmd(pageWithMeta?.data.pageIdOnHackmd);
|
|
usePageIdOnHackmd(pageWithMeta?.data.pageIdOnHackmd);
|
|
|
useHasDraftOnHackmd(pageWithMeta?.data.hasDraftOnHackmd ?? false);
|
|
useHasDraftOnHackmd(pageWithMeta?.data.hasDraftOnHackmd ?? false);
|
|
|
useCurrentPathname(props.currentPathname);
|
|
useCurrentPathname(props.currentPathname);
|
|
|
|
|
|
|
|
useSWRxCurrentPage(pageWithMeta?.data ?? null); // store initial data
|
|
useSWRxCurrentPage(pageWithMeta?.data ?? null); // store initial data
|
|
|
|
|
|
|
|
|
|
+ const { mutate: mutateIsNotFound } = useIsNotFound();
|
|
|
|
|
+
|
|
|
|
|
+ const { mutate: mutateCurrentPageId } = useCurrentPageId();
|
|
|
|
|
+
|
|
|
const { mutate: mutateEditingMarkdown } = useEditingMarkdown();
|
|
const { mutate: mutateEditingMarkdown } = useEditingMarkdown();
|
|
|
|
|
+ const { mutate: mutateIsLatestRevision } = useIsLatestRevision();
|
|
|
|
|
|
|
|
const { data: grantData } = useSWRxIsGrantNormalized(pageId);
|
|
const { data: grantData } = useSWRxIsGrantNormalized(pageId);
|
|
|
const { mutate: mutateSelectedGrant } = useSelectedGrant();
|
|
const { mutate: mutateSelectedGrant } = useSelectedGrant();
|
|
@@ -286,6 +289,18 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
|
|
|
mutateRevisionIdHackmdSynced(pageWithMeta?.data.revisionHackmdSynced);
|
|
mutateRevisionIdHackmdSynced(pageWithMeta?.data.revisionHackmdSynced);
|
|
|
}, [mutateRemoteRevisionId, mutateRevisionIdHackmdSynced, pageWithMeta?.data.revision?._id, pageWithMeta?.data.revisionHackmdSynced]);
|
|
}, [mutateRemoteRevisionId, mutateRevisionIdHackmdSynced, pageWithMeta?.data.revision?._id, pageWithMeta?.data.revisionHackmdSynced]);
|
|
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ mutateCurrentPageId(pageId ?? null);
|
|
|
|
|
+ }, [mutateCurrentPageId, pageId]);
|
|
|
|
|
+
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ mutateIsNotFound(props.isNotFound);
|
|
|
|
|
+ }, [mutateIsNotFound, props.isNotFound]);
|
|
|
|
|
+
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ mutateIsLatestRevision(props.isLatestRevision);
|
|
|
|
|
+ }, [mutateIsLatestRevision, props.isLatestRevision]);
|
|
|
|
|
+
|
|
|
const title = generateCustomTitleForPage(props, pagePath);
|
|
const title = generateCustomTitleForPage(props, pagePath);
|
|
|
|
|
|
|
|
return (
|
|
return (
|