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