getting rid of attributes like data-note-path in favor of the whole nav state in URLs

This commit is contained in:
zadam
2023-05-07 21:18:21 +02:00
parent 291f0e79d9
commit f85209a72f
16 changed files with 96 additions and 133 deletions

View File

@@ -52,14 +52,13 @@ export default class TabManager extends Component {
async loadTabs() {
try {
const noteContextsToOpen = appContext.isMainWindow
? (options.getJson('openNoteContexts') || [])
: [];
const noteContextsToOpen = (appContext.isMainWindow && options.getJson('openNoteContexts')) || [];
// preload all notes at once
await froca.getNotes([
...noteContextsToOpen.map(tab => treeService.getNoteIdFromNotePath(tab.notePath)),
...noteContextsToOpen.map(tab => tab.hoistedNoteId),
...noteContextsToOpen.flatMap(tab =>
[ treeService.getNoteIdFromNotePath(tab.notePath), tab.hoistedNoteId]
),
], true);
const filteredNoteContexts = noteContextsToOpen.filter(openTab => {
@@ -81,7 +80,7 @@ export default class TabManager extends Component {
});
// resolve before opened tabs can change this
const parsedFromUrl = treeService.parseNavigationStateFromAddress();
const parsedFromUrl = linkService.parseNavigationStateFromUrl(window.location.href);
if (filteredNoteContexts.length === 0) {
parsedFromUrl.ntxId = parsedFromUrl.ntxId || NoteContext.generateNtxId(); // generate already here, so that we later know which one to activate
@@ -109,8 +108,8 @@ export default class TabManager extends Component {
}
});
// 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 there's a 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 (parsedFromUrl.notePath) {
await appContext.tabManager.switchToNoteContext(
parsedFromUrl.ntxId,