From 4130090fd7452fc588b0dda136a2db9c7504b84b Mon Sep 17 00:00:00 2001 From: nyne Date: Tue, 3 Jun 2025 16:05:26 +0800 Subject: [PATCH] Add loading status to publish page. --- frontend/src/components/tag_input.tsx | 9 ++++++++- frontend/src/pages/edit_resource_page.tsx | 1 + frontend/src/pages/publish_page.tsx | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/tag_input.tsx b/frontend/src/components/tag_input.tsx index 7a488b2..4c98c11 100644 --- a/frontend/src/components/tag_input.tsx +++ b/frontend/src/components/tag_input.tsx @@ -158,13 +158,20 @@ export function QuickAddTagDialog({ onAdded }: { onAdded: (tags: Tag[]) => void const [separator, setSeparator] = useState(",") + const [isLoading, setLoading] = useState(false) + const handleSubmit = async () => { + if (isLoading) { + return + } if (text.trim().length === 0) { return } setError(null) const names = text.split(separator).filter((n) => n.length > 0) + setLoading(true) const res = await network.getOrCreateTags(names, type) + setLoading(false) if (!res.success) { setError(res.message) return @@ -214,7 +221,7 @@ export function QuickAddTagDialog({ onAdded }: { onAdded: (tags: Tag[]) => void
- + diff --git a/frontend/src/pages/edit_resource_page.tsx b/frontend/src/pages/edit_resource_page.tsx index 1b8a826..2f1369e 100644 --- a/frontend/src/pages/edit_resource_page.tsx +++ b/frontend/src/pages/edit_resource_page.tsx @@ -72,6 +72,7 @@ export default function EditResourcePage() { setError(t("Description cannot be empty")) return } + setSubmitting(true) const res = await network.editResource(id, { title: title, alternative_titles: altTitles, diff --git a/frontend/src/pages/publish_page.tsx b/frontend/src/pages/publish_page.tsx index 34b139a..3f75807 100644 --- a/frontend/src/pages/publish_page.tsx +++ b/frontend/src/pages/publish_page.tsx @@ -50,6 +50,7 @@ export default function PublishPage() { setError(t("Description cannot be empty")) return } + setSubmitting(true) const res = await network.createResource({ title: title, alternative_titles: altTitles,