Yohei-Shiina 3 лет назад
Родитель
Сommit
f48fa3a003

+ 6 - 2
packages/app/src/components/DescendantsPageList.tsx

@@ -10,7 +10,9 @@ import {
 } from '~/interfaces/page';
 import { IPagingResult } from '~/interfaces/paging-result';
 import { OnDeletedFunction, OnPutBackedFunction } from '~/interfaces/ui';
-import { useIsGuestUser, useIsSharedUser, useIsTrashPage } from '~/stores/context';
+import {
+  useIsGuestUser, useIsSharedUser, useIsTrashPage, useShowPageLimitationXL,
+} from '~/stores/context';
 import {
   usePageTreeTermManager, useDescendantsPageListForCurrentPathTermManager, useSWRxDescendantsPageListForCurrrentPath,
   useSWRxPageInfoForList, useSWRxPageList,
@@ -167,7 +169,9 @@ export const DescendantsPageListForCurrentPath = (): JSX.Element => {
   const [activePage, setActivePage] = useState(1);
 
   const { data: isTrashPage } = useIsTrashPage();
-  const { data: pagingResult, error, mutate } = useSWRxDescendantsPageListForCurrrentPath(activePage);
+  const { data: limit } = useShowPageLimitationXL();
+  const { data: pagingResult, error, mutate } = useSWRxDescendantsPageListForCurrrentPath(activePage, limit);
+
   if (error != null) {
     return (
       <div className="my-5">

+ 3 - 9
packages/app/src/stores/page-listing.tsx

@@ -1,4 +1,4 @@
-import { Nullable, HasObjectId, pagePathUtils } from '@growi/core';
+import { Nullable, HasObjectId } from '@growi/core';
 import useSWR, { SWRResponse } from 'swr';
 import useSWRImmutable from 'swr/immutable';
 import useSWRInfinite, { SWRInfiniteResponse } from 'swr/infinite';
@@ -13,11 +13,9 @@ import {
   AncestorsChildrenResult, ChildrenResult, V5MigrationStatus, RootPageResult,
 } from '../interfaces/page-listing-results';
 
-import { useCurrentPagePath, useShowPageLimitationXL } from './context';
+import { useCurrentPagePath } from './context';
 import { ITermNumberManagerUtil, useTermNumberManager } from './use-static-swr';
 
-const { isTrashTopPage } = pagePathUtils;
-
 export const useSWRxPagesByPath = (path?: Nullable<string>): SWRResponse<IPageHasId[], Error> => {
   const findAll = true;
   return useSWR<IPageHasId[], Error>(
@@ -78,13 +76,9 @@ export const useDescendantsPageListForCurrentPathTermManager = (isDisabled?: boo
   return useTermNumberManager(isDisabled === true ? null : 'descendantsPageListForCurrentPathTermNumber');
 };
 
-export const useSWRxDescendantsPageListForCurrrentPath = (pageNumber?: number): SWRResponse<IPagingResult<IPageHasId>, Error> => {
+export const useSWRxDescendantsPageListForCurrrentPath = (pageNumber?: number, limit?:number): SWRResponse<IPagingResult<IPageHasId>, Error> => {
   const { data: currentPagePath } = useCurrentPagePath();
   const { data: termNumber } = useDescendantsPageListForCurrentPathTermManager();
-  const { data: pageLimitation } = useShowPageLimitationXL();
-
-  // if the curretPath is /trash, then it should not limit the number of pages to fetch.
-  const limit = isTrashTopPage(currentPagePath || '') ? undefined : pageLimitation;
 
   const path = currentPagePath == null || termNumber == null
     ? null