فهرست منبع

call mutate when tags updated on edit mode

kaori 3 سال پیش
والد
کامیت
56a8523345
2فایلهای تغییر یافته به همراه8 افزوده شده و 7 حذف شده
  1. 6 5
      packages/app/src/components/Navbar/GrowiContextualSubNavigation.tsx
  2. 2 2
      packages/app/src/stores/editor.tsx

+ 6 - 5
packages/app/src/components/Navbar/GrowiContextualSubNavigation.tsx

@@ -169,7 +169,7 @@ const GrowiContextualSubNavigation = (props) => {
   const { data: isAbleToShowPageAuthors } = useIsAbleToShowPageAuthors();
 
   const { mutate: mutateSWRTagsInfo, data: tagsInfoData } = useSWRxTagsInfo(pageId);
-  const { data: tagsForEditors, sync: syncPageTagsForEditors } = usePageTagsForEditors(pageId);
+  const { data: tagsForEditors, mutate: mutatePageTagsForEditors, sync: syncPageTagsForEditors } = usePageTagsForEditors(pageId);
 
   const { open: openDuplicateModal } = usePageDuplicateModal();
   const { open: openRenameModal } = usePageRenameModal();
@@ -195,7 +195,7 @@ const GrowiContextualSubNavigation = (props) => {
 
       // revalidate SWRTagsInfo
       mutateSWRTagsInfo();
-      syncPageTagsForEditors(newTags);
+      mutatePageTagsForEditors(newTags);
 
       toastSuccess('updated tags successfully');
     }
@@ -203,12 +203,13 @@ const GrowiContextualSubNavigation = (props) => {
       toastError(err, 'fail to update tags');
     }
 
-  }, [pageId, revisionId, mutateSWRTagsInfo, syncPageTagsForEditors]);
+  }, [pageId, revisionId, mutateSWRTagsInfo, mutatePageTagsForEditors]);
 
   const tagsUpdatedHandlerForEditMode = useCallback((newTags: string[]): void => {
     // It will not be reflected in the DB until the page is refreshed
-    return syncPageTagsForEditors(newTags);
-  }, [syncPageTagsForEditors]);
+    mutatePageTagsForEditors(newTags);
+    return;
+  }, [mutatePageTagsForEditors]);
 
   const duplicateItemClickedHandler = useCallback(async(page: IPageForPageDuplicateModal) => {
     const duplicatedHandler: OnDuplicatedFunction = (fromPath, toPath) => {

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

@@ -102,9 +102,9 @@ export const usePageTagsForEditors = (pageId: Nullable<string>): SWRResponse<str
 
   return {
     ...swrResult,
-    sync: (newTagsOnEdit?: string[]): void => {
+    sync: (): void => {
       const { mutate } = swrResult;
-      mutate(newTagsOnEdit || tagsInfoData?.tags || [], false);
+      mutate(tagsInfoData?.tags || [], false);
     },
   };
 };