WIP per-tab hoisting

This commit is contained in:
zadam 2020-11-23 23:11:21 +01:00
parent 52b8162d01
commit ac636b6649
5 changed files with 11 additions and 7 deletions

View File

@ -25,7 +25,7 @@ function isRootNode(node) {
|| node.data.noteId === getHoistedNoteId();
}
async function checkNoteAccess(notePath) {
async function checkNoteAccess(notePath, tabContext) {
// notePath argument can contain only noteId which is not good when hoisted since
// then we need to check the whole note path
const resolvedNotePath = await treeService.resolveNotePath(notePath);
@ -35,11 +35,11 @@ async function checkNoteAccess(notePath) {
return false;
}
const hoistedNoteId = getHoistedNoteId();
const hoistedNoteId = tabContext.hoistedNoteId;
if (hoistedNoteId !== 'root' && !resolvedNotePath.includes(hoistedNoteId)) {
const confirmDialog = await import('../dialogs/confirm.js');
console.trace("HI!", hoistedNoteId, notePath);
if (!await confirmDialog.confirm("Requested note is outside of hoisted note subtree and you must unhoist to access the note. Do you want to proceed with unhoisting?")) {
return false;
}

View File

@ -45,7 +45,7 @@ class TabContext extends Component {
return;
}
if (await hoistedNoteService.checkNoteAccess(resolvedNotePath) === false) {
if (await hoistedNoteService.checkNoteAccess(resolvedNotePath, this) === false) {
return; // note is outside of hoisted subtree and user chose not to unhoist
}

View File

@ -5,7 +5,7 @@ const searchService = require('../../services/search/services/search.js');
const repository = require('../../services/repository');
const log = require('../../services/log');
const utils = require('../../services/utils');
const optionService = require('../../services/options');
const cls = require('../../services/cls');
function getAutocomplete(req) {
const query = req.query.query.trim();
@ -35,7 +35,7 @@ function getRecentNotes(activeNoteId) {
let extraCondition = '';
const params = [activeNoteId];
const hoistedNoteId = optionService.getOption('hoistedNoteId');
const hoistedNoteId = cls.getHoistedNoteId();
if (hoistedNoteId !== 'root') {
extraCondition = `AND recent_notes.notePath LIKE ?`;
params.push(hoistedNoteId + '%');

View File

@ -84,7 +84,7 @@ function getTree(req) {
)
SELECT noteId FROM treeWithDescendantsAscendantsAndTemplates`, [subTreeNoteId, subTreeNoteId]);
noteIds.push(subTreeNoteId);console.log("noteIds", noteIds);
noteIds.push(subTreeNoteId);
return getNotesAndBranchesAndAttributes(noteIds);
}

View File

@ -86,6 +86,10 @@ function getNoteTitle(childNoteId, parentNoteId) {
}
function getNoteTitleArrayForPath(notePathArray) {
if (notePathArray.length === 1 && notePathArray[0] === cls.getHoistedNoteId()) {
return [getNoteTitle(cls.getHoistedNoteId())];
}
const titles = [];
let parentNoteId = 'root';