Shun Miyazawa 3 лет назад
Родитель
Сommit
c22510211f
1 измененных файлов с 12 добавлено и 1 удалено
  1. 12 1
      packages/app/src/stores/context.tsx

+ 12 - 1
packages/app/src/stores/context.tsx

@@ -18,7 +18,7 @@ import { useStaticSWR } from './use-static-swr';
 
 type Nullable<T> = T | null;
 
-const { isTrashPage } = pagePathUtils;
+const { isTrashPage, isTrashTopPage } = pagePathUtils;
 
 
 export const useInterceptorManager = (): SWRResponse<InterceptorManager, Error> => {
@@ -282,6 +282,17 @@ export const useIsTrashPage = (): SWRResponse<boolean, Error> => {
   );
 };
 
+export const useIsTrashTopPage = (): SWRResponse<boolean, Error> => {
+  const { data: currentPagePath } = useCurrentPagePath();
+
+  const result = isTrashTopPage(currentPagePath || '');
+
+  return useSWRImmutable(
+    currentPagePath != null ? ['isTrashTopPage', result] : null,
+    (key: Key, isTrashPage: boolean) => isTrashPage,
+  );
+};
+
 export const useIsEditable = (): SWRResponse<boolean, Error> => {
   const { data: isGuestUser } = useIsGuestUser();
   const { data: isNotCreatable } = useIsNotCreatable();