Sfoglia il codice sorgente

refactor useIsAbleToShowPageManagement

yuken 3 anni fa
parent
commit
a7a38a8cfb
1 ha cambiato i file con 4 aggiunte e 2 eliminazioni
  1. 4 2
      packages/app/src/stores/ui.tsx

+ 4 - 2
packages/app/src/stores/ui.tsx

@@ -413,14 +413,16 @@ export const useIsAbleToShowTrashPageManagementButtons = (): SWRResponse<boolean
 };
 
 export const useIsAbleToShowPageManagement = (): SWRResponse<boolean, Error> => {
-  const key = 'isAbleToShowPageManagement';
   const { data: currentPageId } = useCurrentPageId();
   const { data: isTrashPage } = useIsTrashPage();
   const { data: isSharedUser } = useIsSharedUser();
+  const { data: isEmpty } = useIsEmpty();
+
+  const key = `isAbleToShowPageManagement ${currentPageId}`;
 
   const pageId = currentPageId;
   const includesUndefined = [pageId, isTrashPage, isSharedUser].some(v => v === undefined);
-  const isPageExist = pageId != null;
+  const isPageExist = (pageId != null) && !isEmpty;
 
   return useSWRImmutable(
     includesUndefined ? null : key,