yohei0125 %!s(int64=4) %!d(string=hai) anos
pai
achega
269d26da8a

+ 1 - 0
packages/app/src/components/Navbar/GrowiSubNavigation.jsx

@@ -53,6 +53,7 @@ const GrowiSubNavigation = (props) => {
   const isTagLabelHidden = (editorMode !== EditorMode.Editor && !isPageExist);
 
   const { data: isAbleToShowPageManagement } = useIsAbleToShowPageManagement();
+  console.log(isAbleToShowPageManagement);
   const { data: isAbleToShowTagLabel } = useIsAbleToShowTagLabel();
   const { data: isAbleToShowPageEditorModeManager } = useIsAbleToShowPageEditorModeManager();
   const { data: isAbleToShowPageAuthors } = useIsAbleToShowPageAuthors();

+ 25 - 6
packages/app/src/stores/ui.tsx

@@ -1,5 +1,5 @@
 import useSWR, {
-  useSWRConfig, SWRResponse, Key, Fetcher,
+  useSWRConfig, SWRResponse, Key, Fetcher, mutate,
 } from 'swr';
 import useSWRImmutable from 'swr/immutable';
 
@@ -314,33 +314,52 @@ export const useGlobalSearchFormRef = (initialData?: RefObject<IFocusable>): SWR
 
 export const useIsEditorMode = (): SWRResponse<Nullable<boolean>, Error> => {
   const { data: editorMode } = useEditorMode();
-  return useStaticSWR('isEditorMode', editorMode !== EditorMode.View);
+  const key = 'isEditorMode';
+
+  mutate(key, editorMode !== EditorMode.View);
+
+  return useStaticSWR(key);
 };
 
 export const useIsAbleToShowPageManagement = (): SWRResponse<Nullable<boolean>, Error> => {
+  const key = 'isAbleToShowPageManagement';
   const { data: isPageExist } = useIsPageExist();
   const { data: isTrashPage } = useIsTrashPage();
   const { data: isSharedUser } = useIsSharedUser();
   const { data: isEditorMode } = useIsEditorMode();
 
-  return useStaticSWR('isAbleToShowPageManagement', isPageExist && !isTrashPage && !isSharedUser && !isEditorMode);
+  mutate(key, isPageExist && !isTrashPage && !isSharedUser && !isEditorMode);
+
+  return useStaticSWR(key);
 };
 
 export const useIsAbleToShowTagLabel = (): SWRResponse<Nullable<boolean>, Error> => {
+  const key = 'isAbleToShowTagLabel';
   const { data: isUserPage } = useIsUserPage();
   const { data: isSharedUser } = useIsSharedUser();
-  return useStaticSWR('isAbleToShowTagLabel', !isUserPage && !isSharedUser);
+
+  mutate(key, !isUserPage && !isSharedUser);
+
+  return useStaticSWR(key, !isUserPage && !isSharedUser);
 };
 
 export const useIsAbleToShowPageEditorModeManager = (): SWRResponse<Nullable<boolean>, Error> => {
+  const key = 'isAbleToShowPageEditorModeManager';
   const { data: isNotCreatable } = useIsNotCreatable();
   const { data: isTrashPage } = useIsTrashPage();
   const { data: isSharedUser } = useIsSharedUser();
-  return useStaticSWR('isAbleToShowPageEditorModeManager', (!isNotCreatable && !isTrashPage && !isSharedUser));
+
+  mutate(key, (!isNotCreatable && !isTrashPage && !isSharedUser));
+
+  return useStaticSWR(key);
 };
 
 export const useIsAbleToShowPageAuthors = (): SWRResponse<Nullable<boolean>, Error> => {
+  const key = 'isAbleToShowPageAuthors';
   const { data: isPageExist } = useIsPageExist();
   const { data: isUserPage } = useIsUserPage();
-  return useStaticSWR('isAbleToShowPageAuthors', (isPageExist && !isUserPage));
+
+  mutate(key, (isPageExist && !isUserPage));
+
+  return useStaticSWR(key);
 };