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()
}
+13 -9
View File
@@ -9,6 +9,7 @@
import ModalFooter from "@lib/components/ModalFooter.svelte"
import {getPubkeyHints, publishReply} from "@app/commands"
import {getEditorOptions, addFile, uploadFiles, getEditorTags} from "@lib/editor"
import {pushToast} from '@app/toast'
export let url
export let event
@@ -20,14 +21,17 @@
const loading = writable(false)
const submit = () => {
onSubmit(
publishReply({
event,
content: $editor.getText(),
tags: getEditorTags($editor),
relays: [url],
}),
)
const content = $editor.getText()
const tags = getEditorTags($editor)
if (!content.trim()) {
return pushToast({
theme: 'error',
message: "Please provide a message for your reply.",
})
}
onSubmit(publishReply({event, content, tags, relays: [url]}))
}
let editor: Readable<Editor>
@@ -38,9 +42,9 @@
</script>
<form
on:submit|preventDefault={startSubmit}
in:fly
out:slideAndFade
on:submit|preventDefault={startSubmit}
class="card2 sticky bottom-2 z-feature mx-2 mt-2 bg-neutral">
<div class="relative">
<div class="note-editor flex-grow overflow-hidden">