mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	deleting a note will close all tabs containing the note
This commit is contained in:
		| @@ -4,6 +4,7 @@ import server from './server.js'; | ||||
| import infoService from "./info.js"; | ||||
| import treeCache from "./tree_cache.js"; | ||||
| import hoistedNoteService from "./hoisted_note.js"; | ||||
| import noteDetailService from "./note_detail.js"; | ||||
|  | ||||
| async function moveBeforeNode(nodesToMove, beforeNode) { | ||||
|     nodesToMove = await filterRootNote(nodesToMove); | ||||
| @@ -85,7 +86,11 @@ async function deleteNodes(nodes) { | ||||
|     } | ||||
|  | ||||
|     for (const node of nodes) { | ||||
|         await server.remove('branches/' + node.data.branchId); | ||||
|         const {noteDeleted} = await server.remove('branches/' + node.data.branchId); | ||||
|  | ||||
|         if (noteDeleted) { | ||||
|             noteDetailService.noteDeleted(node.data.noteId); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // following code assumes that nodes contain only top-most selected nodes - getSelectedNodes has been | ||||
|   | ||||
| @@ -267,7 +267,7 @@ async function loadNote(noteId) { | ||||
| async function filterTabs(noteId) { | ||||
|     for (const tc of tabContexts) { | ||||
|         if (tc.notePath && !tc.notePath.split("/").includes(noteId)) { | ||||
|             await tabRow.removeTab(tc.tab); | ||||
|             await tabRow.removeTab(tc.$tab[0]); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -281,6 +281,14 @@ async function filterTabs(noteId) { | ||||
|     await saveOpenTabs(); | ||||
| } | ||||
|  | ||||
| async function noteDeleted(noteId) { | ||||
|     for (const tc of tabContexts) { | ||||
|         if (tc.notePath && tc.notePath.split("/").includes(noteId)) { | ||||
|             await tabRow.removeTab(tc.$tab[0]); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| function focusOnTitle() { | ||||
|     getActiveTabContext().$noteTitle.focus(); | ||||
| } | ||||
| @@ -496,5 +504,6 @@ export default { | ||||
|     activateTabContext, | ||||
|     clearOpenTabsTask, | ||||
|     filterTabs, | ||||
|     openEmptyTab | ||||
|     openEmptyTab, | ||||
|     noteDeleted | ||||
| }; | ||||
| @@ -853,7 +853,6 @@ export default { | ||||
|     loadTree, | ||||
|     treeInitialized, | ||||
|     setExpandedToServer, | ||||
|     getHashValueFromAddress, | ||||
|     getNodesByNoteId, | ||||
|     checkFolderStatus, | ||||
|     reloadNote, | ||||
|   | ||||
| @@ -102,7 +102,9 @@ async function setExpanded(req) { | ||||
| async function deleteBranch(req) { | ||||
|     const branch = await repository.getBranch(req.params.branchId); | ||||
|  | ||||
|     await notes.deleteNote(branch); | ||||
|     return { | ||||
|         noteDeleted: await notes.deleteNote(branch) | ||||
|     }; | ||||
| } | ||||
|  | ||||
| async function setPrefix(req) { | ||||
|   | ||||
| @@ -373,9 +373,10 @@ async function updateNote(noteId, noteUpdates) { | ||||
|     await protectNoteRevisions(note); | ||||
| } | ||||
|  | ||||
| /** @return {boolean} - true if note has been deleted, false otherwise */ | ||||
| async function deleteNote(branch) { | ||||
|     if (!branch || branch.isDeleted) { | ||||
|         return; | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     if (branch.branchId === 'root' | ||||
| @@ -418,6 +419,11 @@ async function deleteNote(branch) { | ||||
|             link.isDeleted = true; | ||||
|             await link.save(); | ||||
|         } | ||||
|  | ||||
|         return true; | ||||
|     } | ||||
|     else { | ||||
|         return false; | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user