fixup: always schedule callback first
This commit is contained in:
@@ -61,8 +61,7 @@ export function ArtifactFormWrapper({
|
|||||||
} catch {}
|
} catch {}
|
||||||
router.refresh();
|
router.refresh();
|
||||||
})
|
})
|
||||||
.catch((e) => toast.error(`${e.message || e}`))
|
.catch((e) => toast.error(`${e.message || e}`));
|
||||||
.finally(callback.current);
|
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<ActionSubmitContext.Provider value={context}>
|
<ActionSubmitContext.Provider value={context}>
|
||||||
@@ -70,7 +69,9 @@ export function ArtifactFormWrapper({
|
|||||||
{...props}
|
{...props}
|
||||||
onSubmit={(e) => {
|
onSubmit={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
submit(new FormData(e.target as HTMLFormElement));
|
submit(new FormData(e.target as HTMLFormElement)).finally(
|
||||||
|
callback.current,
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</ActionSubmitContext.Provider>
|
</ActionSubmitContext.Provider>
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import {
|
|||||||
import { ArtifactFormWrapper } from "./form";
|
import { ArtifactFormWrapper } from "./form";
|
||||||
import { LiveButton } from "./live";
|
import { LiveButton } from "./live";
|
||||||
import { RulesDialog } from "./rules";
|
import { RulesDialog } from "./rules";
|
||||||
|
import { ActionButton } from "@/components/action-button";
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "เสือกไอดีชาวบ้าน",
|
title: "เสือกไอดีชาวบ้าน",
|
||||||
@@ -257,9 +258,10 @@ export default async function ArtifactFormPage({
|
|||||||
{count} / {config.limit < 0 ? "∞" : config.limit} คิว
|
{count} / {config.limit < 0 ? "∞" : config.limit} คิว
|
||||||
</Kbd>
|
</Kbd>
|
||||||
<SimpleTooltip text="ส่งเลยจัฟลูกพี่">
|
<SimpleTooltip text="ส่งเลยจัฟลูกพี่">
|
||||||
<Button
|
<ActionButton
|
||||||
type="submit"
|
type="submit"
|
||||||
form="mainform"
|
form="mainform"
|
||||||
|
action="provider"
|
||||||
disabled={
|
disabled={
|
||||||
(!!q ||
|
(!!q ||
|
||||||
config.locked ||
|
config.locked ||
|
||||||
@@ -268,7 +270,7 @@ export default async function ArtifactFormPage({
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{editing ? <PencilIcon /> : <SendHorizonal />}
|
{editing ? <PencilIcon /> : <SendHorizonal />}
|
||||||
</Button>
|
</ActionButton>
|
||||||
</SimpleTooltip>
|
</SimpleTooltip>
|
||||||
</div>
|
</div>
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ export function ActionButton({
|
|||||||
disabled={state > 0}
|
disabled={state > 0}
|
||||||
{...props}
|
{...props}
|
||||||
onClick={async (ev) => {
|
onClick={async (ev) => {
|
||||||
onClick?.(ev);
|
|
||||||
setState(1);
|
setState(1);
|
||||||
|
if (action === "provider")
|
||||||
|
await new Promise<void>(ctx.listenForComplete);
|
||||||
|
onClick?.(ev);
|
||||||
try {
|
try {
|
||||||
if (action === "provider")
|
if (action !== "provider") await action();
|
||||||
await new Promise<void>(ctx.listenForComplete);
|
|
||||||
else await action();
|
|
||||||
setState(2);
|
setState(2);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast.error("An error occured!");
|
toast.error("An error occured!");
|
||||||
|
|||||||
Reference in New Issue
Block a user