Show error on empty message

This commit is contained in:
Jon Staab
2024-10-24 12:55:48 -07:00
parent cad096b019
commit 627407848f
2 changed files with 28 additions and 11 deletions
+15 -2
View File
@@ -9,6 +9,7 @@
import Button from "@lib/components/Button.svelte"
import ModalHeader from "@lib/components/ModalHeader.svelte"
import ModalFooter from "@lib/components/ModalFooter.svelte"
import {pushToast} from '@app/toast'
import {getPubkeyHints} from "@app/commands"
import {getEditorOptions, addFile, uploadFiles, getEditorTags} from "@lib/editor"
@@ -21,9 +22,21 @@
const loading = writable(false)
const submit = () => {
const event = createEvent(NOTE, {content: $editor.getText(), tags: getEditorTags($editor)})
const content = $editor.getText()
const tags = getEditorTags($editor)
if (!content.trim()) {
return pushToast({
theme: 'error',
message: "Please provide a message for your thread.",
})
}
publishThunk({
event: createEvent(NOTE, {content, tags}),
relays: [url],
})
publishThunk({event, relays: [url]})
history.back()
}