Преглед изворни кода

Merge pull request #5447 from weseek/fix/pagetree-item-state

fix: pagetree item state
Yuki Takei пре 4 година
родитељ
комит
a9e7a1d712

+ 1 - 2
packages/app/src/components/Sidebar/PageTree/Item.tsx

@@ -116,7 +116,6 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
 
   const { page, children } = itemNode;
 
-  const [pageTitle, setPageTitle] = useState(page.path);
   const [currentChildren, setCurrentChildren] = useState(children);
   const [isOpen, setIsOpen] = useState(_isOpen);
   const [isNewPageInputShown, setNewPageInputShown] = useState(false);
@@ -447,7 +446,7 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
         )}
         { !isRenameInputShown && ( */}
         <a href={`/${page._id}`} className="grw-pagetree-title-anchor flex-grow-1">
-          <p className={`text-truncate m-auto ${page.isEmpty && 'text-muted'}`}>{nodePath.basename(pageTitle as string) || '/'}</p>
+          <p className={`text-truncate m-auto ${page.isEmpty && 'text-muted'}`}>{nodePath.basename(page.path ?? '') || '/'}</p>
         </a>
         {/* )} */}
         {(descendantCount > 0) && (

+ 3 - 1
packages/app/src/components/Sidebar/PageTree/ItemsTree.tsx

@@ -181,7 +181,9 @@ const ItemsTree: FC<ItemsTreeProps> = (props: ItemsTreeProps) => {
     const renamedHandler: OnRenamedFunction = (path) => {
       toastSuccess(t('renamed_pages', { path }));
 
-      // TODO: revalidation by https://redmine.weseek.co.jp/issues/89258
+      advancePt();
+      advanceFts();
+      advanceDpl();
     };
 
     openRenameModal(pageToRename, { onRenamed: renamedHandler });

+ 3 - 1
packages/app/src/stores/page-listing.tsx

@@ -27,8 +27,10 @@ export const useSWRxRootPage = (): SWRResponse<RootPageResult, Error> => {
 export const useSWRxPageAncestorsChildren = (
     path: string | null,
 ): SWRResponse<AncestorsChildrenResult, Error> => {
+  const { data: termNumber } = usePageTreeTermManager();
+
   return useSWR(
-    path ? `/page-listing/ancestors-children?path=${path}` : null,
+    path ? [`/page-listing/ancestors-children?path=${path}`, termNumber] : null,
     endpoint => apiv3Get(endpoint).then((response) => {
       return {
         ancestorsChildren: response.data.ancestorsChildren,