mirror of
https://github.com/PrimalHQ/primal-web-app.git
synced 2024-10-01 17:31:13 +00:00
Fix draft and quote interaction
This commit is contained in:
parent
e665562db7
commit
36ed0d79f6
@ -487,7 +487,7 @@ const EditBox: Component<{
|
|||||||
position = isEmptyMessage ? 0 : position + quote.length + 1;
|
position = isEmptyMessage ? 0 : position + quote.length + 1;
|
||||||
|
|
||||||
textArea.value = newMsg;
|
textArea.value = newMsg;
|
||||||
// account.actions.quoteNote(undefined);
|
account?.actions.quoteNote(undefined);
|
||||||
|
|
||||||
onExpandableTextareaInput(new InputEvent('input'));
|
onExpandableTextareaInput(new InputEvent('input'));
|
||||||
|
|
||||||
@ -499,20 +499,37 @@ const EditBox: Component<{
|
|||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
if (props.open) {
|
if (props.open) {
|
||||||
if (account?.quotedNote) {
|
|
||||||
addQuote(account.quotedNote);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const draft = readNoteDraft(account?.publicKey, props.replyToNote?.post.noteId);
|
const draft = readNoteDraft(account?.publicKey, props.replyToNote?.post.noteId);
|
||||||
|
|
||||||
setMessage(draft);
|
setMessage((msg) => {
|
||||||
if (textArea)
|
if (msg.length > 0) return msg;
|
||||||
textArea.value = draft;
|
const newMsg = `${msg}${draft}`;
|
||||||
|
|
||||||
|
if (textArea) {
|
||||||
|
textArea.value = newMsg;
|
||||||
|
textArea.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
textArea.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
return newMsg;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (account?.quotedNote) {
|
||||||
|
addQuote(account.quotedNote);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
account?.actions.quoteNote(undefined)
|
account?.actions.quoteNote(undefined);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
createEffect(() => {
|
||||||
|
if (message().length === 0) return;
|
||||||
|
|
||||||
|
// save draft just in case there is an unintended interuption
|
||||||
|
saveNoteDraft(account?.publicKey, message(), props.replyToNote?.post.noteId);
|
||||||
|
});
|
||||||
|
|
||||||
const onEscape = (e: KeyboardEvent) => {
|
const onEscape = (e: KeyboardEvent) => {
|
||||||
if (isConfirmEditorClose()) return;
|
if (isConfirmEditorClose()) return;
|
||||||
|
|
||||||
@ -1004,10 +1021,7 @@ const EditBox: Component<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (textArea) {
|
if (textArea) {
|
||||||
textArea && setMessage(textArea.value);
|
setMessage(textArea.value);
|
||||||
|
|
||||||
// save draft just in case there is an unintended interuption
|
|
||||||
saveNoteDraft(account?.publicKey, textArea?.value, props.replyToNote?.post.noteId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user