diff --git a/app/(ui)/artifact/form.tsx b/app/(ui)/artifact/form.tsx index 50501e0..71fe9b0 100755 --- a/app/(ui)/artifact/form.tsx +++ b/app/(ui)/artifact/form.tsx @@ -61,8 +61,7 @@ export function ArtifactFormWrapper({ } catch {} router.refresh(); }) - .catch((e) => toast.error(`${e.message || e}`)) - .finally(callback.current); + .catch((e) => toast.error(`${e.message || e}`)); } return ( @@ -70,7 +69,9 @@ export function ArtifactFormWrapper({ {...props} onSubmit={(e) => { e.preventDefault(); - submit(new FormData(e.target as HTMLFormElement)); + submit(new FormData(e.target as HTMLFormElement)).finally( + callback.current, + ); }} /> diff --git a/app/(ui)/artifact/page.tsx b/app/(ui)/artifact/page.tsx index 0d58b87..644c65d 100755 --- a/app/(ui)/artifact/page.tsx +++ b/app/(ui)/artifact/page.tsx @@ -40,6 +40,7 @@ import { import { ArtifactFormWrapper } from "./form"; import { LiveButton } from "./live"; import { RulesDialog } from "./rules"; +import { ActionButton } from "@/components/action-button"; export const metadata: Metadata = { title: "เสือกไอดีชาวบ้าน", @@ -257,9 +258,10 @@ export default async function ArtifactFormPage({ {count} / {config.limit < 0 ? "∞" : config.limit} คิว - + diff --git a/components/action-button.tsx b/components/action-button.tsx index 817bdcf..d90377b 100644 --- a/components/action-button.tsx +++ b/components/action-button.tsx @@ -32,12 +32,12 @@ export function ActionButton({ disabled={state > 0} {...props} onClick={async (ev) => { - onClick?.(ev); setState(1); + if (action === "provider") + await new Promise(ctx.listenForComplete); + onClick?.(ev); try { - if (action === "provider") - await new Promise(ctx.listenForComplete); - else await action(); + if (action !== "provider") await action(); setState(2); } catch (e) { toast.error("An error occured!");