mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	fixes to delete notifications
This commit is contained in:
		| @@ -108,14 +108,21 @@ async function deleteNodes(nodes) { | |||||||
|  |  | ||||||
|     const taskId = utils.randomString(10); |     const taskId = utils.randomString(10); | ||||||
|  |  | ||||||
|  |     let counter = 0; | ||||||
|  |  | ||||||
|     for (const node of nodes) { |     for (const node of nodes) { | ||||||
|  |         counter++; | ||||||
|  |  | ||||||
|  |         const last = counter === nodes.length; | ||||||
|  |         const query = `?taskId=${taskId}&last=${last ? 'true' : 'false'}`; | ||||||
|  |  | ||||||
|         if (deleteClones) { |         if (deleteClones) { | ||||||
|             await server.remove('notes/' + node.data.noteId + '?taskId=' + taskId); |             await server.remove(`notes/${node.data.noteId}` + query); | ||||||
|  |  | ||||||
|             noteDetailService.noteDeleted(node.data.noteId); |             noteDetailService.noteDeleted(node.data.noteId); | ||||||
|         } |         } | ||||||
|         else { |         else { | ||||||
|             const {noteDeleted} = await server.remove('branches/' + node.data.branchId + '?taskId=' + taskId); |             const {noteDeleted} = await server.remove(`branches/${node.data.branchId}` + query); | ||||||
|  |  | ||||||
|             if (noteDeleted) { |             if (noteDeleted) { | ||||||
|                 noteDetailService.noteDeleted(node.data.noteId); |                 noteDetailService.noteDeleted(node.data.noteId); | ||||||
| @@ -167,8 +174,6 @@ async function deleteNodes(nodes) { | |||||||
|         node.setFocus(true); |         node.setFocus(true); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     infoService.showMessage("Note(s) has been deleted."); |  | ||||||
|  |  | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -65,8 +65,8 @@ ws.subscribeToMessages(async message => { | |||||||
|  |  | ||||||
|         await treeService.reloadNote(message.parentNoteId); |         await treeService.reloadNote(message.parentNoteId); | ||||||
|  |  | ||||||
|         if (message.importedNoteId) { |         if (message.result.importedNoteId) { | ||||||
|             const node = await treeService.activateNote(message.importedNoteId); |             const node = await treeService.activateNote(message.result.importedNoteId); | ||||||
|  |  | ||||||
|             node.setExpanded(true); |             node.setExpanded(true); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -98,7 +98,14 @@ async function getNodeFromPath(notePath, expand = false, expandOpts = {}) { | |||||||
|     const hoistedNoteId = await hoistedNoteService.getHoistedNoteId(); |     const hoistedNoteId = await hoistedNoteService.getHoistedNoteId(); | ||||||
|     let parentNode = null; |     let parentNode = null; | ||||||
|  |  | ||||||
|     for (const childNoteId of await getRunPath(notePath)) { |     const runPath = await getRunPath(notePath); | ||||||
|  |  | ||||||
|  |     if (!runPath) { | ||||||
|  |         console.error("Could not find run path for notePath:", notePath); | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     for (const childNoteId of runPath) { | ||||||
|         if (childNoteId === hoistedNoteId) { |         if (childNoteId === hoistedNoteId) { | ||||||
|             // there must be exactly one node with given hoistedNoteId |             // there must be exactly one node with given hoistedNoteId | ||||||
|             parentNode = getNodesByNoteId(childNoteId)[0]; |             parentNode = getNodesByNoteId(childNoteId)[0]; | ||||||
|   | |||||||
| @@ -865,3 +865,13 @@ a.external:not(.no-arrow):after, a[href^="http://"]:not(.no-arrow):after, a[href | |||||||
|     top: 20px; |     top: 20px; | ||||||
|     z-index: 10000; |     z-index: 10000; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | .toast { | ||||||
|  |     background-color: var(--accented-background-color) !important; | ||||||
|  |     color: var(--main-text-color) !important; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | .toast-header { | ||||||
|  |     background-color: var(--more-accented-background-color) !important; | ||||||
|  |     color: var(--main-text-color) !important; | ||||||
|  | } | ||||||
| @@ -101,11 +101,18 @@ async function setExpanded(req) { | |||||||
| } | } | ||||||
|  |  | ||||||
| async function deleteBranch(req) { | async function deleteBranch(req) { | ||||||
|  |     const last = req.query.last === 'true'; | ||||||
|     const branch = await repository.getBranch(req.params.branchId); |     const branch = await repository.getBranch(req.params.branchId); | ||||||
|     const taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes'); |     const taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes'); | ||||||
|  |  | ||||||
|  |     const noteDeleted = await notes.deleteBranch(branch, taskContext); | ||||||
|  |  | ||||||
|  |     if (last) { | ||||||
|  |         taskContext.taskSucceeded(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     return { |     return { | ||||||
|         noteDeleted: await notes.deleteBranch(branch, taskContext) |         noteDeleted: noteDeleted | ||||||
|     }; |     }; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -67,7 +67,10 @@ async function importToBranch(req) { | |||||||
|  |  | ||||||
|     if (last === "true") { |     if (last === "true") { | ||||||
|         // small timeout to avoid race condition (message is received before the transaction is committed) |         // small timeout to avoid race condition (message is received before the transaction is committed) | ||||||
|         setTimeout(() => taskContext.taskSucceeded(parentNoteId, note.noteId), 1000); |         setTimeout(() => taskContext.taskSucceeded({ | ||||||
|  |             parentNoteId: parentNoteId, | ||||||
|  |             importedNoteId: note.noteId | ||||||
|  |         }), 1000); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // import has deactivated note events so note cache is not updated |     // import has deactivated note events so note cache is not updated | ||||||
|   | |||||||
| @@ -75,14 +75,20 @@ async function updateNote(req) { | |||||||
|  |  | ||||||
| async function deleteNote(req) { | async function deleteNote(req) { | ||||||
|     const noteId = req.params.noteId; |     const noteId = req.params.noteId; | ||||||
|  |     const taskId = req.query.taskId; | ||||||
|  |     const last = req.query.last === 'true'; | ||||||
|  |  | ||||||
|     const note = await repository.getNote(noteId); |     const note = await repository.getNote(noteId); | ||||||
|  |  | ||||||
|     const taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes'); |     const taskContext = TaskContext.getInstance(taskId, 'delete-notes'); | ||||||
|  |  | ||||||
|     for (const branch of await note.getBranches()) { |     for (const branch of await note.getBranches()) { | ||||||
|         await noteService.deleteBranch(branch, taskContext); |         await noteService.deleteBranch(branch, taskContext); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     if (last) { | ||||||
|  |         await taskContext.taskSucceeded(); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| async function sortNotes(req) { | async function sortNotes(req) { | ||||||
|   | |||||||
| @@ -40,7 +40,6 @@ class TaskContext { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // must remaing non-static |  | ||||||
|     async reportError(message) { |     async reportError(message) { | ||||||
|         await ws.sendMessageToAllClients({ |         await ws.sendMessageToAllClients({ | ||||||
|             type: 'task-error', |             type: 'task-error', | ||||||
| @@ -50,14 +49,12 @@ class TaskContext { | |||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // must remaing non-static |     async taskSucceeded(result) { | ||||||
|     async taskSucceeded(parentNoteId, importedNoteId) { |  | ||||||
|         await ws.sendMessageToAllClients({ |         await ws.sendMessageToAllClients({ | ||||||
|             type: 'task-succeeded', |             type: 'task-succeeded', | ||||||
|             taskId: this.taskId, |             taskId: this.taskId, | ||||||
|             taskType: this.taskType, |             taskType: this.taskType, | ||||||
|             parentNoteId: parentNoteId, |             result: result | ||||||
|             importedNoteId: importedNoteId |  | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user