فهرست منبع

imprv useSWRxTagsInfo key

kaori 3 سال پیش
والد
کامیت
6ac3f13442

+ 2 - 2
packages/app/src/components/Navbar/GrowiContextualSubNavigation.tsx

@@ -172,8 +172,8 @@ const GrowiContextualSubNavigation = (props) => {
   const { data: isAbleToShowPageEditorModeManager } = useIsAbleToShowPageEditorModeManager();
   const { data: isAbleToShowPageAuthors } = useIsAbleToShowPageAuthors();
 
-  const { mutate: mutateSWRTagsInfo, data: tagsInfoData } = useSWRxTagsInfo(pageId);
-  const { data: tagsForEditors, mutate: mutatePageTagsForEditors, sync: syncPageTagsForEditors } = usePageTagsForEditors(pageId);
+  const { mutate: mutateSWRTagsInfo, data: tagsInfoData } = useSWRxTagsInfo(pageId, path);
+  const { data: tagsForEditors, mutate: mutatePageTagsForEditors, sync: syncPageTagsForEditors } = usePageTagsForEditors(pageId, path);
 
   const { open: openDuplicateModal } = usePageDuplicateModal();
   const { open: openRenameModal } = usePageRenameModal();

+ 2 - 2
packages/app/src/stores/editor.tsx

@@ -96,8 +96,8 @@ export type IPageTagsForEditorsOption = {
   sync: (tags?: string[]) => void;
 }
 
-export const usePageTagsForEditors = (pageId: Nullable<string>): SWRResponse<string[], Error> & IPageTagsForEditorsOption => {
-  const { data: tagsInfoData } = useSWRxTagsInfo(pageId);
+export const usePageTagsForEditors = (pageId: Nullable<string>, pagePath: Nullable<string>): SWRResponse<string[], Error> & IPageTagsForEditorsOption => {
+  const { data: tagsInfoData } = useSWRxTagsInfo(pageId, pagePath);
   const swrResult = useStaticSWR<string[], Error>('pageTags', undefined);
 
   return {

+ 5 - 4
packages/app/src/stores/page.tsx

@@ -96,13 +96,14 @@ export const useSWRxDescendantsPageListForCurrrentPath = (pageNumber?: number):
 };
 
 
-export const useSWRxTagsInfo = (pageId: Nullable<string>): SWRResponse<IPageTagsInfo | undefined, Error> => {
-  const key = pageId == null ? 'tmpPage' : `/pages.getPageTag?pageId=${pageId}`;
-
+export const useSWRxTagsInfo = (pageId: Nullable<string>, pagePath: Nullable<string>): SWRResponse<IPageTagsInfo | undefined, Error> => {
   const { data: templateTagData } = useTemplateTagData();
   const { data: shareLinkId } = useShareLinkId();
 
-  const fetcher = async(endpoint: string) => {
+  const key = [`/pages.getPageTag?pageId=${pageId}`, pageId, shareLinkId, pagePath];
+
+
+  const fetcher = async(endpoint: string, pageId: Nullable<string>, shareLinkId: Nullable<string>) => {
     if (shareLinkId != null) {
       return;
     }