From d4b449e617c3377389f5cd282cc49daf2f69be6d Mon Sep 17 00:00:00 2001 From: liumingye <898310895@qq.com> Date: Sat, 20 Apr 2024 20:54:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DTagsSection=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E6=8A=A5=E9=94=99Maximum=20update=20depth=20exceeded?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20fix:=20=E4=BF=AE=E6=94=B9tag?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E5=90=8E=E9=87=8D=E6=96=B0=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 48a7895bca61e..ce1256bb3667b 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 5d72273360d39..ac9d5c747dcb8 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);