Просмотр исходного кода

not limit the number of pages to fetch if the path is /trash

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

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

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

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

@@ -1,4 +1,4 @@
-import { Nullable, HasObjectId } from '@growi/core';
+import { Nullable, HasObjectId, pagePathUtils } from '@growi/core';
 import useSWR, { SWRResponse } from 'swr';
 import useSWRImmutable from 'swr/immutable';
 import useSWRInfinite, { SWRInfiniteResponse } from 'swr/infinite';
@@ -13,9 +13,11 @@ import {
   AncestorsChildrenResult, ChildrenResult, V5MigrationStatus, RootPageResult,
 } from '../interfaces/page-listing-results';
 
-import { useCurrentPagePath } from './context';
+import { useCurrentPagePath, useShowPageLimitationXL } 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>(
@@ -76,9 +78,13 @@ export const useDescendantsPageListForCurrentPathTermManager = (isDisabled?: boo
   return useTermNumberManager(isDisabled === true ? null : 'descendantsPageListForCurrentPathTermNumber');
 };
 
-export const useSWRxDescendantsPageListForCurrrentPath = (pageNumber?: number, limit?: number): SWRResponse<IPagingResult<IPageHasId>, Error> => {
+export const useSWRxDescendantsPageListForCurrrentPath = (pageNumber?: 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