Browse Source

fix useSWRxIsGrantNormalized for not found page

Yuki Takei 3 years ago
parent
commit
2cc0827c4e
1 changed files with 5 additions and 2 deletions
  1. 5 2
      packages/app/src/stores/page.tsx

+ 5 - 2
packages/app/src/stores/page.tsx

@@ -19,7 +19,7 @@ import { IRevisionsForPagination } from '~/interfaces/revision';
 import { IPageTagsInfo } from '../interfaces/tag';
 import { IPageTagsInfo } from '../interfaces/tag';
 
 
 import {
 import {
-  useCurrentPageId, useCurrentPathname, useShareLinkId, useIsGuestUser,
+  useCurrentPageId, useCurrentPathname, useShareLinkId, useIsGuestUser, useIsNotFound,
 } from './context';
 } from './context';
 
 
 const { isPermalink: _isPermalink } = pagePathUtils;
 const { isPermalink: _isPermalink } = pagePathUtils;
@@ -163,8 +163,11 @@ export const useSWRxIsGrantNormalized = (
 ): SWRResponse<IResIsGrantNormalized, Error> => {
 ): SWRResponse<IResIsGrantNormalized, Error> => {
 
 
   const { data: isGuestUser } = useIsGuestUser();
   const { data: isGuestUser } = useIsGuestUser();
+  const { data: isNotFound } = useIsNotFound();
 
 
-  const key = !isGuestUser && pageId != null ? ['/page/is-grant-normalized', pageId] : null;
+  const key = !isGuestUser && !isNotFound && pageId != null
+    ? ['/page/is-grant-normalized', pageId]
+    : null;
 
 
   return useSWRImmutable(
   return useSWRImmutable(
     key,
     key,