diff --git a/src/app/components/CalendarEventEdit.svelte b/src/app/components/CalendarEventEdit.svelte index 0de7df47..40e666c5 100644 --- a/src/app/components/CalendarEventEdit.svelte +++ b/src/app/components/CalendarEventEdit.svelte @@ -29,7 +29,7 @@ {#if initialValues} - + {#snippet header()} Edit this Event diff --git a/src/app/components/CalendarEventForm.svelte b/src/app/components/CalendarEventForm.svelte index 04dda91a..18f4e005 100644 --- a/src/app/components/CalendarEventForm.svelte +++ b/src/app/components/CalendarEventForm.svelte @@ -53,9 +53,11 @@ defaultEnd, }: Props = $props() - const draftKey = new DraftKey(`calendar:${url}:${h ?? ""}`) + // An edit starts from the event, and saving it as a draft would carry it into the next create. + const editing = Boolean(initialValues) + const draftKey = editing ? undefined : new DraftKey(`calendar:${url}:${h ?? ""}`) - if (!initialValues) { + if (draftKey) { initialValues = draftKey.get() } @@ -123,7 +125,7 @@ return pushToast({theme: "error", message: error}) } - draftKey.clear() + draftKey?.clear() history.back() if (shareToChat) { @@ -153,7 +155,7 @@ const editor = makeEditor({url, submit, uploading, onChange, content}) $effect(() => { - draftKey.set({d, title, location, start, end, content}) + draftKey?.set({d, title, location, start, end, content}) }) diff --git a/src/app/components/ClassifiedEdit.svelte b/src/app/components/ClassifiedEdit.svelte index 5d7e5357..9c7f1f2b 100644 --- a/src/app/components/ClassifiedEdit.svelte +++ b/src/app/components/ClassifiedEdit.svelte @@ -31,7 +31,7 @@ {#if initialValues} - + {#snippet header()} Edit this Listing diff --git a/src/app/components/ClassifiedForm.svelte b/src/app/components/ClassifiedForm.svelte index a3898f9a..c3029f91 100644 --- a/src/app/components/ClassifiedForm.svelte +++ b/src/app/components/ClassifiedForm.svelte @@ -48,9 +48,11 @@ let {url, h, shareToChat = false, header, initialValues}: Props = $props() - const draftKey = new DraftKey(`classified:${url}:${h ?? ""}`) + // An edit starts from the event, and saving it as a draft would carry it into the next create. + const editing = Boolean(initialValues) + const draftKey = editing ? undefined : new DraftKey(`classified:${url}:${h ?? ""}`) - if (!initialValues) { + if (draftKey) { initialValues = draftKey.get() } @@ -125,7 +127,7 @@ return pushToast({theme: "error", message: error}) } - draftKey.clear() + draftKey?.clear() history.back() if (shareToChat) { @@ -157,7 +159,7 @@ const editor = makeEditor({url, submit, onChange, content}) $effect(() => { - draftKey.set({d, title, status, price, currency, images, topics, content}) + draftKey?.set({d, title, status, price, currency, images, topics, content}) }) @@ -227,7 +229,7 @@ {/snippet} - {#if initialValues} + {#if editing} {#snippet label()}

Status*

diff --git a/src/app/components/GoalCreate.svelte b/src/app/components/GoalCreate.svelte index 83377a85..e7cbcd35 100644 --- a/src/app/components/GoalCreate.svelte +++ b/src/app/components/GoalCreate.svelte @@ -40,17 +40,14 @@ type Props = { url: string h?: string - initialValues?: Values shareToChat?: boolean } - let {url, h, initialValues, shareToChat = false}: Props = $props() + const {url, h, shareToChat = false}: Props = $props() const draftKey = new DraftKey(`goal:${url}:${h ?? ""}`) - if (!initialValues) { - initialValues = draftKey.get() - } + const initialValues = draftKey.get() const shouldProtect = $relays.hasNip(url, 70)