From 6235cd677d195376a1e0d2e1b55cd0fa4e9f94d8 Mon Sep 17 00:00:00 2001 From: Adrian Gruntkowski Date: Sat, 8 Feb 2025 17:43:42 +0100 Subject: [PATCH] Implement saving edited note in progress --- priv/static/js/components.js | 7 +++++++ priv/static/js/jenot.js | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/priv/static/js/components.js b/priv/static/js/components.js index b9fe8d9..563a98f 100644 --- a/priv/static/js/components.js +++ b/priv/static/js/components.js @@ -697,6 +697,13 @@ class NoteForm extends HTMLElement { detail: this.note, }), ); + } else { + this.dispatchEvent( + new CustomEvent("updateNoteInProgress", { + bubbles: true, + detail: this.note, + }), + ); } } diff --git a/priv/static/js/jenot.js b/priv/static/js/jenot.js index 14ccffd..6ad2d93 100644 --- a/priv/static/js/jenot.js +++ b/priv/static/js/jenot.js @@ -127,6 +127,12 @@ newNote.addEventListener("deleteNote", async (e) => { await Notes.clearDraft(); }); +editNote.addEventListener("updateNoteInProgress", async (e) => { + const note = e.detail; + note.updated = Date.now(); + await Notes.update(note, true); +}); + editNote.addEventListener("updateNote", async (e) => { await Notes.update(e.detail); Notes.saveStorage();