mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-19 16:02:14 +00:00
fix(drafts): wait for the fork POST to land before navigating
OtherUsersDraftsModal's Fork action called UserDraft.save, which routes through the autosave debouncer (1500ms). The subsequent goto fired within the same tick, so the destination editor's get_draft=true read ran before the POST landed and 404'd — refreshing worked because by then the debounced save had fired. Call UserDraftDbSyncer.save with immediate: true and await it. The syncer cancels any queued debouncer task for the key and resolves the promise only after the POST completes, so the route load can find the forked draft on the first try.
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
import Modal2 from '$lib/components/common/modal/Modal2.svelte'
|
||||
import Button from '$lib/components/common/button/Button.svelte'
|
||||
import Tooltip from '$lib/components/Tooltip.svelte'
|
||||
import { UserDraft } from '$lib/userDraft.svelte'
|
||||
import { UserDraftDbSyncer } from '$lib/userDraftDbSyncer.svelte'
|
||||
|
||||
export type OtherDraftUser = { username?: string | null }
|
||||
|
||||
@@ -94,7 +94,19 @@
|
||||
try {
|
||||
const value = await fetchDraft(owner)
|
||||
const target = forkPath(owner)
|
||||
UserDraft.save(itemKind, target, value, { workspace })
|
||||
// Bypass the autosave debouncer so the fork lands on the
|
||||
// server BEFORE we navigate. The destination route loads
|
||||
// via `getDraft=true` and 404s if no draft yet exists at
|
||||
// the fork path — the prior `UserDraft.save` call
|
||||
// scheduled a debounced POST 1.5s out, so a fresh nav was
|
||||
// always too early.
|
||||
await UserDraftDbSyncer.save({
|
||||
workspace,
|
||||
itemKind,
|
||||
path: target,
|
||||
value,
|
||||
immediate: true
|
||||
})
|
||||
isOpen = false
|
||||
goto(editPathFor(target))
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user