Răsfoiți Sursa

clean codes

kosei-n 2 ani în urmă
părinte
comite
d55ace19fb
1 a modificat fișierele cu 2 adăugiri și 6 ștergeri
  1. 2 6
      apps/app/src/components/PageHeader/page-header-utils.ts

+ 2 - 6
apps/app/src/components/PageHeader/page-header-utils.ts

@@ -17,8 +17,6 @@ export const usePagePathRenameHandler = (
   const { trigger: mutateCurrentPage } = useSWRMUTxCurrentPage();
   const { t } = useTranslation();
 
-  const currentPagePath = currentPage?.path;
-
   const pagePathRenameHandler = useCallback(async(newPagePath, onRenameFinish, onRenameFailure) => {
 
     if (currentPage == null) {
@@ -29,7 +27,7 @@ export const usePagePathRenameHandler = (
       mutatePageTree();
       mutatePageList();
 
-      if (currentPagePath === fromPath || currentPagePath === toPath) {
+      if (currentPage.path === fromPath || currentPage.path === toPath) {
         mutateCurrentPage();
       }
     };
@@ -49,15 +47,13 @@ export const usePagePathRenameHandler = (
       onRenamed(currentPage.path, newPagePath);
       onRenameFinish?.();
 
-      onRenameFinish?.();
-
       toastSuccess(t('renamed_pages', { path: currentPage.path }));
     }
     catch (err) {
       onRenameFailure?.();
       toastError(err);
     }
-  }, [currentPage, currentPagePath, mutateCurrentPage, t]);
+  }, [currentPage, mutateCurrentPage, t]);
 
   return pagePathRenameHandler;
 };