Преглед изворни кода

support includeShortBody option

Yuki Takei пре 4 година
родитељ
комит
6a94e6ec3d

+ 1 - 1
packages/app/src/components/DescendantsPageList.tsx

@@ -37,7 +37,7 @@ export const DescendantsPageListSubstance = (props: SubstanceProps): JSX.Element
   const { data: isGuestUser } = useIsGuestUser();
 
   const pageIds = pagingResult?.items?.map(page => page._id);
-  const { data: idToPageInfo } = useSWRxPageInfoForList(pageIds);
+  const { data: idToPageInfo } = useSWRxPageInfoForList(pageIds, true);
 
   let pagingResultWithMeta: IPagingResult<IPageWithMeta> | undefined;
 

+ 1 - 1
packages/app/src/components/IdenticalPathPage.tsx

@@ -66,7 +66,7 @@ const IdenticalPathPage:FC<IdenticalPathPageProps> = (props: IdenticalPathPagePr
   const { data: currentPath } = useCurrentPagePath();
   const { data: isSharedUser } = useIsSharedUser();
 
-  const { data: idToPageInfoMap } = useSWRxPageInfoForList(pageIds);
+  const { data: idToPageInfoMap } = useSWRxPageInfoForList(pageIds, true);
 
   const { open: openDescendantPageListModal } = useDescendantsPageListModal();
 

+ 1 - 1
packages/app/src/components/SearchPage/SearchResultList.tsx

@@ -34,7 +34,7 @@ const SearchResultListSubstance: ForwardRefRenderFunction<ISelectableAll, Props>
     .map(page => page.pageData._id);
 
   const { data: isGuestUser } = useIsGuestUser();
-  const { data: idToPageInfo } = useSWRxPageInfoForList(pageIdsWithNoSnippet);
+  const { data: idToPageInfo } = useSWRxPageInfoForList(pageIdsWithNoSnippet, true);
 
   // for mutation
   const { advance: advancePt } = usePageTreeTermManager();

+ 6 - 3
packages/app/src/stores/page.tsx

@@ -91,12 +91,15 @@ export const useSWRxPageInfo = (
   );
 };
 
-export const useSWRxPageInfoForList = (pageIds: string[] | null | undefined): SWRResponse<Record<string, IPageInfo | IPageInfoForListing>, Error> => {
+export const useSWRxPageInfoForList = (
+    pageIds: string[] | null | undefined,
+    includeShortBody = false,
+): SWRResponse<Record<string, IPageInfo | IPageInfoForListing>, Error> => {
 
   const shouldFetch = pageIds != null && pageIds.length > 0;
 
   return useSWRImmutable(
-    shouldFetch ? ['/page-listing/info', pageIds] : null,
-    (endpoint, pageIds) => apiv3Get(endpoint, { pageIds }).then(response => response.data),
+    shouldFetch ? ['/page-listing/info', pageIds, includeShortBody] : null,
+    (endpoint, pageIds, includeShortBody) => apiv3Get(endpoint, { pageIds, includeShortBody }).then(response => response.data),
   );
 };