refactored TabContext => NoteContext

This commit is contained in:
zadam
2021-05-22 12:26:45 +02:00
parent 29e4e2afbb
commit 274cf7312c
54 changed files with 470 additions and 459 deletions

View File

@@ -2,16 +2,16 @@ import appContext from "./app_context.js";
import treeService from "./tree.js";
function getHoistedNoteId() {
const activeTabContext = appContext.tabManager.getActiveTabContext();
const activeNoteContext = appContext.tabManager.getActiveNoteContext();
return activeTabContext ? activeTabContext.hoistedNoteId : 'root';
return activeNoteContext ? activeNoteContext.hoistedNoteId : 'root';
}
async function unhoist() {
const activeTabContext = appContext.tabManager.getActiveTabContext();
const activeNoteContext = appContext.tabManager.getActiveNoteContext();
if (activeTabContext) {
await activeTabContext.unhoist();
if (activeNoteContext) {
await activeNoteContext.unhoist();
}
}
@@ -25,15 +25,15 @@ function isHoistedNode(node) {
|| node.data.noteId === getHoistedNoteId();
}
async function checkNoteAccess(notePath, tabContext) {
const resolvedNotePath = await treeService.resolveNotePath(notePath, tabContext.hoistedNoteId);
async function checkNoteAccess(notePath, noteContext) {
const resolvedNotePath = await treeService.resolveNotePath(notePath, noteContext.hoistedNoteId);
if (!resolvedNotePath) {
console.log("Cannot activate " + notePath);
return false;
}
const hoistedNoteId = tabContext.hoistedNoteId;
const hoistedNoteId = noteContext.hoistedNoteId;
if (!resolvedNotePath.includes(hoistedNoteId)) {
const confirmDialog = await import('../dialogs/confirm.js');