persist drafts in memory (#155)
Co-authored-by: userAdityaa <aditya.chaudhary1558@gmail.com> Co-committed-by: userAdityaa <aditya.chaudhary1558@gmail.com>
This commit was merged in pull request #155.
This commit is contained in:
@@ -10,10 +10,14 @@
|
||||
import {publishComment, canEnforceNip70} from "@app/core/commands"
|
||||
import {PROTECTED} from "@app/core/state"
|
||||
import {makeEditor} from "@app/editor"
|
||||
import {DraftKey} from "@app/util/drafts"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
|
||||
const {url, event, onClose, onSubmit} = $props()
|
||||
|
||||
const draftKey = new DraftKey<{content?: unknown}>(`reply:${event.id}`)
|
||||
const draft = draftKey.get()
|
||||
|
||||
const shouldProtect = canEnforceNip70(url)
|
||||
|
||||
const uploading = writable(false)
|
||||
@@ -38,10 +42,20 @@
|
||||
})
|
||||
}
|
||||
|
||||
draftKey.clear()
|
||||
onSubmit(publishComment({event, content, tags, relays: [url]}))
|
||||
}
|
||||
|
||||
const editor = makeEditor({url, submit, uploading, autofocus: !isMobile})
|
||||
const onChange = (json: unknown) => draftKey.set({content: json})
|
||||
|
||||
const editor = makeEditor({
|
||||
url,
|
||||
submit,
|
||||
uploading,
|
||||
autofocus: !isMobile,
|
||||
content: draft?.content as string | object | undefined,
|
||||
onChange,
|
||||
})
|
||||
|
||||
let form: HTMLElement
|
||||
let spacer: HTMLElement
|
||||
|
||||
Reference in New Issue
Block a user