fix: tag dependencies (#3251)

fix: 修改tag名称后重新请求数据
This commit is contained in:
刘明野 2024-04-20 21:16:17 +08:00 committed by GitHub
parent 330cc3dc89
commit 06a79a2e37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 9 deletions

View file

@ -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 (
<div className="flex flex-col justify-start items-start w-full mt-3 px-1 h-auto shrink-0 flex-nowrap hide-scrollbar">

View file

@ -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: 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: Props) => {
});
toast.success("Rename tag successfully");
filterStore.setTagFilter(newName);
tagStore.fetchTags({ skipCache: true });
} catch (error: any) {
console.error(error);
toast.error(error.details);