post: remove whitespace of textnote content (trim right only)

Send button should be disabled if there are only white spaces or
newlines, trimming only right as white spaces at the beginning
could mean somethig i.e in markdown.
pull/13/head
OFF0 1 year ago
parent 8081d12254
commit 3ab815c30e
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -427,7 +427,8 @@ writeForm.addEventListener('submit', async (e) => {
if (!pubkey || !privatekey) {
return onSendError(new Error('no pubkey/privatekey'));
}
if (!writeInput.value) {
const content = writeInput.value.trimRight();
if (!content) {
return onSendError(new Error('message is empty'));
}
const replyTo = localStorage.getItem('reply_to');
@ -435,7 +436,7 @@ writeForm.addEventListener('submit', async (e) => {
const newEvent = {
kind: 1,
pubkey,
content: writeInput.value,
content,
tags,
created_at: Math.floor(Date.now() * 0.001),
};
@ -462,7 +463,7 @@ writeForm.addEventListener('submit', async (e) => {
});
writeInput.addEventListener('input', () => {
publish.disabled = !writeInput.value;
publish.disabled = !writeInput.value.trimRight();
updateElemHeight(writeInput);
});
writeInput.addEventListener('blur', () => sendStatus.textContent = '');

Loading…
Cancel
Save