Skip to content

Commit

Permalink
Ensure root knows when note title changes. Fixes dullage#82.
Browse files Browse the repository at this point in the history
  • Loading branch information
dullage authored and Gedulis12 committed Aug 7, 2023
1 parent 15bea9b commit 7702edd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 7 additions & 2 deletions flatnotes/src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 () {
Expand All @@ -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();
Expand Down
8 changes: 5 additions & 3 deletions flatnotes/src/components/NoteViewerEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ export default {
watch: {
titleToLoad: function () {
this.init();
if (this.titleToLoad !== this.currentNote?.title) {
this.init();
}
},
},
Expand All @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7702edd

Please sign in to comment.