From 06a79a2e37606f4a9e5d0abadc9fad446ad80b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=98=8E=E9=87=8E?= <898310895@qq.com> Date: Sat, 20 Apr 2024 21:16:17 +0800 Subject: [PATCH] fix: tag dependencies (#3251) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: 修改tag名称后重新请求数据 --- web/src/components/HomeSidebar/TagsSection.tsx | 11 ++--------- web/src/components/RenameTagDialog.tsx | 3 +++ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/web/src/components/HomeSidebar/TagsSection.tsx b/web/src/components/HomeSidebar/TagsSection.tsx index 48a7895bc..ce1256bb3 100644 --- a/web/src/components/HomeSidebar/TagsSection.tsx +++ b/web/src/components/HomeSidebar/TagsSection.tsx @@ -56,14 +56,7 @@ const TagsSection = () => { tagText += "/" + key; } - let obj = null; - - for (const t of tempObj.subTags) { - if (t.text === tagText) { - obj = t; - break; - } - } + let obj = tempObj.subTags.find((t: Tag) => t.text === tagText); if (!obj) { obj = { @@ -79,7 +72,7 @@ const TagsSection = () => { } setTags(root.subTags as Tag[]); - }, [tagsText]); + }, [tagsText.join(",")]); return (
diff --git a/web/src/components/RenameTagDialog.tsx b/web/src/components/RenameTagDialog.tsx index 5d7227336..ac9d5c747 100644 --- a/web/src/components/RenameTagDialog.tsx +++ b/web/src/components/RenameTagDialog.tsx @@ -5,6 +5,7 @@ import { tagServiceClient } from "@/grpcweb"; import useCurrentUser from "@/hooks/useCurrentUser"; import useLoading from "@/hooks/useLoading"; import { useFilterStore } from "@/store/module"; +import { useTagStore } from "@/store/v1"; import { useTranslate } from "@/utils/i18n"; import { generateDialog } from "./Dialog"; import Icon from "./Icon"; @@ -16,6 +17,7 @@ interface Props extends DialogProps { const RenameTagDialog: React.FC = (props: Props) => { const { tag, destroy } = props; const t = useTranslate(); + const tagStore = useTagStore(); const filterStore = useFilterStore(); const currentUser = useCurrentUser(); const [newName, setNewName] = useState(tag); @@ -43,6 +45,7 @@ const RenameTagDialog: React.FC = (props: Props) => { }); toast.success("Rename tag successfully"); filterStore.setTagFilter(newName); + tagStore.fetchTags({ skipCache: true }); } catch (error: any) { console.error(error); toast.error(error.details);