From: Adam Dullage Date: Sun, 2 Jul 2023 11:51:14 +0000 (+0100) Subject: Ensure root knows when note title changes. Fixes #82. X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=94b329d9cf1c88df2cdf76d4e670e084c5defde1;p=flatnotes.git Ensure root knows when note title changes. Fixes #82. --- diff --git a/flatnotes/src/components/App.js b/flatnotes/src/components/App.js index 55d5647..a6b766d 100644 --- a/flatnotes/src/components/App.js +++ b/flatnotes/src/components/App.js @@ -100,8 +100,8 @@ export default { // Note else if (basePath == constants.basePaths.note) { - this.updateDocumentTitle(); this.noteTitle = decodeURIComponent(path[2]); + this.updateDocumentTitle(this.noteTitle); this.currentView = this.views.note; } @@ -172,6 +172,11 @@ export default { this.darkTheme = !this.darkTheme; localStorage.setItem("darkTheme", this.darkTheme); }, + + updateNoteTitle: function (title) { + this.noteTitle = title; + this.updateDocumentTitle(title); + }, }, created: function () { @@ -181,7 +186,7 @@ export default { EventBus.$on("navigate", this.navigate); EventBus.$on("unhandledServerError", this.unhandledServerErrorToast); - EventBus.$on("updateDocumentTitle", this.updateDocumentTitle); + EventBus.$on("updateNoteTitle", this.updateNoteTitle); Mousetrap.bind("/", function () { parent.openSearch(); diff --git a/flatnotes/src/components/NoteViewerEditor.vue b/flatnotes/src/components/NoteViewerEditor.vue index 344f03f..b1a42e4 100644 --- a/flatnotes/src/components/NoteViewerEditor.vue +++ b/flatnotes/src/components/NoteViewerEditor.vue @@ -209,7 +209,9 @@ export default { watch: { titleToLoad: function () { - this.init(); + if (this.titleToLoad !== this.currentNote?.title) { + this.init(); + } }, }, @@ -225,7 +227,7 @@ export default { response.data.lastModified, response.data.content ); - EventBus.$emit("updateDocumentTitle", parent.currentNote.title); + // EventBus.$emit("updateDocumentTitle", parent.currentNote.title); }) .catch(function (error) { if (error.handled) { @@ -446,7 +448,7 @@ export default { response.data.lastModified, response.data.content ); - EventBus.$emit("updateDocumentTitle", this.currentNote.title); + EventBus.$emit("updateNoteTitle", this.currentNote.title); history.replaceState(null, "", this.currentNote.href); this.setEditMode(false); this.noteSavedToast();