Browse Source

Stop treating empty pages as not found pages on the server side

Yuki Takei 3 months ago
parent
commit
5d9290127b

+ 1 - 1
apps/app/src/server/service/page/index.ts

@@ -2585,7 +2585,7 @@ class PageService implements IPageService {
     if (page.isEmpty) {
       return {
         emptyPageId: pageId,
-        isNotFound: true,
+        isNotFound: false,
         isV5Compatible: true,
         isEmpty: true,
         isMovable,

+ 1 - 7
apps/app/src/states/page/hydrate.ts

@@ -2,7 +2,6 @@ import {
   type IPageInfo,
   type IPageNotFoundInfo,
   type IPagePopulatedToShowRevision,
-  isIPageInfo,
   isIPageInfoForEmpty,
   isIPageNotFoundInfo,
 } from '@growi/core';
@@ -60,12 +59,7 @@ export const useHydratePageAtoms = (
     // Core page state - automatically extract from page object
     [currentPageEntityIdAtom, page?._id],
     [currentPageDataAtom, page ?? undefined],
-    [
-      pageNotFoundAtom,
-      isIPageInfo(pageMeta)
-        ? pageMeta.isNotFound
-        : page == null || page.isEmpty,
-    ],
+    [pageNotFoundAtom, isIPageNotFoundInfo(pageMeta)],
     [
       isForbiddenAtom,
       isIPageNotFoundInfo(pageMeta) ? pageMeta.isForbidden : false,

+ 3 - 7
packages/core/src/interfaces/page.ts

@@ -84,12 +84,8 @@ export type PageStatus = (typeof PageStatus)[keyof typeof PageStatus];
 export type IPageHasId = IPage & HasObjectId;
 
 // Special type to represent page is an empty page or not found or forbidden status
-export type IPageNotFoundInfo = (
-  | IPageInfoForEmpty
-  | {
-      isNotFound: true;
-    }
-) & {
+export type IPageNotFoundInfo = {
+  isNotFound: true;
   isForbidden: boolean;
 };
 
@@ -106,7 +102,7 @@ export type IPageInfo = {
 
 export type IPageInfoForEmpty = Omit<IPageInfo, 'isNotFound' | 'isEmpty'> & {
   emptyPageId: string;
-  isNotFound: true;
+  isNotFound: false;
   isEmpty: true;
   isBookmarked?: boolean;
 };