From 7b2c3afe4c3737ddb106d3c1ef084371fcbb3edf Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 31 Jan 2023 23:20:11 +0100 Subject: [PATCH] always open the note in URL, closes #3571 --- package-lock.json | 5 ++--- src/public/app/components/tab_manager.js | 14 ++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4a0cd9448..22de73d4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,11 @@ { "name": "trilium", - "version": "0.58.6", + "version": "0.58.7", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "trilium", - "version": "0.58.6", + "version": "0.58.7", "hasInstallScript": true, "license": "AGPL-3.0-only", "dependencies": { diff --git a/src/public/app/components/tab_manager.js b/src/public/app/components/tab_manager.js index b84c2fcd3..b398d06c1 100644 --- a/src/public/app/components/tab_manager.js +++ b/src/public/app/components/tab_manager.js @@ -79,11 +79,12 @@ export default class TabManager extends Component { filteredTabs = filteredTabs.filter(tab => tab.active); } - if (filteredTabs.length === 0) { - const [notePath] = treeService.getHashValueFromAddress(); + // resolve before opened tabs can change this + const [notePathInUrl, ntxIdInUrl] = treeService.getHashValueFromAddress(); + if (filteredTabs.length === 0) { filteredTabs.push({ - notePath: notePath || 'root', + notePath: notePathInUrl || 'root', active: true, hoistedNoteId: glob.extraHoistedNoteId || 'root' }); @@ -95,17 +96,14 @@ export default class TabManager extends Component { await this.tabsUpdate.allowUpdateWithoutChange(async () => { for (const tab of filteredTabs) { - await this.openContextWithNote(tab.notePath, tab.active, tab.ntxId, tab.hoistedNoteId, tab.mainNtxId); } }); // if there's notePath in the URL, make sure it's open and active // (useful, for e.g. opening clipped notes from clipper or opening link in an extra window) - if (treeService.isNotePathInAddress()) { - const [notePath, ntxId] = treeService.getHashValueFromAddress(); - - await appContext.tabManager.switchToNoteContext(ntxId, notePath); + if (notePathInUrl) { + await appContext.tabManager.switchToNoteContext(ntxIdInUrl, notePathInUrl); } } catch (e) {