Add context clearing on resource deletion and tag editing

This commit is contained in:
2025-06-08 14:07:28 +08:00
parent 3c3f9e9d35
commit b0680fa94f
2 changed files with 11 additions and 1 deletions

View File

@@ -43,6 +43,7 @@ import { Turnstile } from "@marsidev/react-turnstile";
import Button from "../components/button.tsx";
import Badge, { BadgeAccent } from "../components/badge.tsx";
import Input from "../components/input.tsx";
import { useAppContext } from "../components/AppContext.tsx";
export default function ResourcePage() {
const params = useParams();
@@ -257,6 +258,8 @@ function DeleteResourceDialog({
const { t } = useTranslation();
const context = useAppContext();
const handleDelete = async () => {
if (isLoading) {
return;
@@ -272,6 +275,7 @@ function DeleteResourceDialog({
message: t("Resource deleted successfully"),
type: "success",
});
context.clear();
navigate("/", { replace: true });
} else {
showToast({ message: res.message, type: "error" });

View File

@@ -11,6 +11,7 @@ import { app } from "../app.ts";
import Input, { TextArea } from "../components/input.tsx";
import TagInput from "../components/tag_input.tsx";
import Badge from "../components/badge.tsx";
import { useAppContext } from "../components/AppContext.tsx";
export default function TaggedResourcesPage() {
const { tag: tagName } = useParams();
@@ -73,7 +74,8 @@ export default function TaggedResourcesPage() {
</article>
)}
<ResourcesView
storageKey={`tagged-${tagName}`}
key={tag?.name ?? tagName}
storageKey={`tagged-${tag?.name ?? tagName}`}
loader={(page) => {
return network.getResourcesByTag(tagName, page);
}}
@@ -96,6 +98,7 @@ function EditTagButton({
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const { t } = useTranslation();
const context = useAppContext();
useEffect(() => {
setDescription(tag.description);
@@ -120,6 +123,9 @@ function EditTagButton({
"edit_tag_dialog",
) as HTMLDialogElement;
dialog.close();
if (aliasOf) {
context.clear();
}
onEdited(res.data!);
} else {
setError(res.message || t("Unknown error"));