Add loading status to publish page.

This commit is contained in:
2025-06-03 16:05:26 +08:00
parent 38d5bd3242
commit 4130090fd7
3 changed files with 10 additions and 1 deletions

View File

@@ -158,13 +158,20 @@ export function QuickAddTagDialog({ onAdded }: { onAdded: (tags: Tag[]) => void
const [separator, setSeparator] = useState<string>(",") const [separator, setSeparator] = useState<string>(",")
const [isLoading, setLoading] = useState(false)
const handleSubmit = async () => { const handleSubmit = async () => {
if (isLoading) {
return
}
if (text.trim().length === 0) { if (text.trim().length === 0) {
return return
} }
setError(null) setError(null)
const names = text.split(separator).filter((n) => n.length > 0) const names = text.split(separator).filter((n) => n.length > 0)
setLoading(true)
const res = await network.getOrCreateTags(names, type) const res = await network.getOrCreateTags(names, type)
setLoading(false)
if (!res.success) { if (!res.success) {
setError(res.message) setError(res.message)
return return
@@ -214,7 +221,7 @@ export function QuickAddTagDialog({ onAdded }: { onAdded: (tags: Tag[]) => void
<form method="dialog"> <form method="dialog">
<Button className="btn">{t("Cancel")}</Button> <Button className="btn">{t("Cancel")}</Button>
</form> </form>
<Button className={"btn-primary"} disabled={text === ""} onClick={handleSubmit}>{t("Submit")}</Button> <Button isLoading={isLoading} className={"btn-primary"} disabled={text === ""} onClick={handleSubmit}>{t("Submit")}</Button>
</div> </div>
</div> </div>
</dialog> </dialog>

View File

@@ -72,6 +72,7 @@ export default function EditResourcePage() {
setError(t("Description cannot be empty")) setError(t("Description cannot be empty"))
return return
} }
setSubmitting(true)
const res = await network.editResource(id, { const res = await network.editResource(id, {
title: title, title: title,
alternative_titles: altTitles, alternative_titles: altTitles,

View File

@@ -50,6 +50,7 @@ export default function PublishPage() {
setError(t("Description cannot be empty")) setError(t("Description cannot be empty"))
return return
} }
setSubmitting(true)
const res = await network.createResource({ const res = await network.createResource({
title: title, title: title,
alternative_titles: altTitles, alternative_titles: altTitles,