Ensure root knows when note title changes. Fixes #82.
authorAdam Dullage <redacted>
Sun, 2 Jul 2023 11:51:14 +0000 (12:51 +0100)
committerAdam Dullage <redacted>
Sun, 2 Jul 2023 11:51:14 +0000 (12:51 +0100)
flatnotes/src/components/App.js
flatnotes/src/components/NoteViewerEditor.vue

index 55d56479113f15d49448e53c119adfd8d2efdba6..a6b766d66d219bf87390811841d086e0d50f9131 100644 (file)
@@ -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();
index 344f03fcfd4110ac1401d72657e17a368fd15890..b1a42e47d06992c07e9b4aad5c0960cdd3c2e777 100644 (file)
@@ -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();
git clone https://git.99rst.org/PROJECT