mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	WIP per-tab hoisting
This commit is contained in:
		| @@ -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; | ||||
|         } | ||||
|   | ||||
| @@ -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 | ||||
|             } | ||||
|  | ||||
|   | ||||
| @@ -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 + '%'); | ||||
|   | ||||
| @@ -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); | ||||
| } | ||||
|   | ||||
| @@ -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'; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user