From f4c81ecefb9435111413cb88553fe13be18c9230 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 3 Jan 2022 19:52:24 +0100 Subject: [PATCH] fix setting window title when renaming notes --- src/public/app/services/tab_manager.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/public/app/services/tab_manager.js b/src/public/app/services/tab_manager.js index 37e206ab3..3fc634ca5 100644 --- a/src/public/app/services/tab_manager.js +++ b/src/public/app/services/tab_manager.js @@ -129,12 +129,7 @@ export default class TabManager extends Component { window.history.pushState(null, "", url); } - const titleFragments = [ - // it helps navigating in history if note title is included in the title - activeNoteContext.note?.title, - "Trilium Notes" - ].filter(Boolean); - document.title = titleFragments.join(" - "); + this.updateDocumentTitle(activeNoteContext); this.triggerEvent('activeNoteChanged'); // trigger this even in on popstate event } @@ -453,4 +448,22 @@ export default class TabManager extends Component { hoistedNoteChangedEvent() { this.tabsUpdate.scheduleUpdate(); } + + updateDocumentTitle(activeNoteContext) { + const titleFragments = [ + // it helps navigating in history if note title is included in the title + activeNoteContext.note?.title, + "Trilium Notes" + ].filter(Boolean); + + document.title = titleFragments.join(" - "); + } + + entitiesReloadedEvent({loadResults}) { + const activeContext = this.getActiveContext(); + + if (activeContext && loadResults.isNoteReloaded(activeContext.noteId)) { + this.updateDocumentTitle(activeContext); + } + } }