always open the note in URL, closes #3571

This commit is contained in:
zadam 2023-01-31 23:20:11 +01:00
parent 2e181d0fb1
commit 7b2c3afe4c
2 changed files with 8 additions and 11 deletions

5
package-lock.json generated
View File

@ -1,12 +1,11 @@
{ {
"name": "trilium", "name": "trilium",
"version": "0.58.6", "version": "0.58.7",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "trilium", "version": "0.58.7",
"version": "0.58.6",
"hasInstallScript": true, "hasInstallScript": true,
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"dependencies": { "dependencies": {

View File

@ -79,11 +79,12 @@ export default class TabManager extends Component {
filteredTabs = filteredTabs.filter(tab => tab.active); filteredTabs = filteredTabs.filter(tab => tab.active);
} }
if (filteredTabs.length === 0) { // resolve before opened tabs can change this
const [notePath] = treeService.getHashValueFromAddress(); const [notePathInUrl, ntxIdInUrl] = treeService.getHashValueFromAddress();
if (filteredTabs.length === 0) {
filteredTabs.push({ filteredTabs.push({
notePath: notePath || 'root', notePath: notePathInUrl || 'root',
active: true, active: true,
hoistedNoteId: glob.extraHoistedNoteId || 'root' hoistedNoteId: glob.extraHoistedNoteId || 'root'
}); });
@ -95,17 +96,14 @@ export default class TabManager extends Component {
await this.tabsUpdate.allowUpdateWithoutChange(async () => { await this.tabsUpdate.allowUpdateWithoutChange(async () => {
for (const tab of filteredTabs) { for (const tab of filteredTabs) {
await this.openContextWithNote(tab.notePath, tab.active, tab.ntxId, tab.hoistedNoteId, tab.mainNtxId); 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 // 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) // (useful, for e.g. opening clipped notes from clipper or opening link in an extra window)
if (treeService.isNotePathInAddress()) { if (notePathInUrl) {
const [notePath, ntxId] = treeService.getHashValueFromAddress(); await appContext.tabManager.switchToNoteContext(ntxIdInUrl, notePathInUrl);
await appContext.tabManager.switchToNoteContext(ntxId, notePath);
} }
} }
catch (e) { catch (e) {