mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Add context clearing on resource deletion and tag editing
This commit is contained in:
@@ -43,6 +43,7 @@ import { Turnstile } from "@marsidev/react-turnstile";
|
|||||||
import Button from "../components/button.tsx";
|
import Button from "../components/button.tsx";
|
||||||
import Badge, { BadgeAccent } from "../components/badge.tsx";
|
import Badge, { BadgeAccent } from "../components/badge.tsx";
|
||||||
import Input from "../components/input.tsx";
|
import Input from "../components/input.tsx";
|
||||||
|
import { useAppContext } from "../components/AppContext.tsx";
|
||||||
|
|
||||||
export default function ResourcePage() {
|
export default function ResourcePage() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
@@ -257,6 +258,8 @@ function DeleteResourceDialog({
|
|||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const context = useAppContext();
|
||||||
|
|
||||||
const handleDelete = async () => {
|
const handleDelete = async () => {
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return;
|
return;
|
||||||
@@ -272,6 +275,7 @@ function DeleteResourceDialog({
|
|||||||
message: t("Resource deleted successfully"),
|
message: t("Resource deleted successfully"),
|
||||||
type: "success",
|
type: "success",
|
||||||
});
|
});
|
||||||
|
context.clear();
|
||||||
navigate("/", { replace: true });
|
navigate("/", { replace: true });
|
||||||
} else {
|
} else {
|
||||||
showToast({ message: res.message, type: "error" });
|
showToast({ message: res.message, type: "error" });
|
||||||
|
@@ -11,6 +11,7 @@ import { app } from "../app.ts";
|
|||||||
import Input, { TextArea } from "../components/input.tsx";
|
import Input, { TextArea } from "../components/input.tsx";
|
||||||
import TagInput from "../components/tag_input.tsx";
|
import TagInput from "../components/tag_input.tsx";
|
||||||
import Badge from "../components/badge.tsx";
|
import Badge from "../components/badge.tsx";
|
||||||
|
import { useAppContext } from "../components/AppContext.tsx";
|
||||||
|
|
||||||
export default function TaggedResourcesPage() {
|
export default function TaggedResourcesPage() {
|
||||||
const { tag: tagName } = useParams();
|
const { tag: tagName } = useParams();
|
||||||
@@ -73,7 +74,8 @@ export default function TaggedResourcesPage() {
|
|||||||
</article>
|
</article>
|
||||||
)}
|
)}
|
||||||
<ResourcesView
|
<ResourcesView
|
||||||
storageKey={`tagged-${tagName}`}
|
key={tag?.name ?? tagName}
|
||||||
|
storageKey={`tagged-${tag?.name ?? tagName}`}
|
||||||
loader={(page) => {
|
loader={(page) => {
|
||||||
return network.getResourcesByTag(tagName, page);
|
return network.getResourcesByTag(tagName, page);
|
||||||
}}
|
}}
|
||||||
@@ -96,6 +98,7 @@ function EditTagButton({
|
|||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const context = useAppContext();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setDescription(tag.description);
|
setDescription(tag.description);
|
||||||
@@ -120,6 +123,9 @@ function EditTagButton({
|
|||||||
"edit_tag_dialog",
|
"edit_tag_dialog",
|
||||||
) as HTMLDialogElement;
|
) as HTMLDialogElement;
|
||||||
dialog.close();
|
dialog.close();
|
||||||
|
if (aliasOf) {
|
||||||
|
context.clear();
|
||||||
|
}
|
||||||
onEdited(res.data!);
|
onEdited(res.data!);
|
||||||
} else {
|
} else {
|
||||||
setError(res.message || t("Unknown error"));
|
setError(res.message || t("Unknown error"));
|
||||||
|
Reference in New Issue
Block a user