Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
delete progress
zadam9f4ca279aa9e
diff --git a/src/public/javascripts/dialogs/export.js b/src/public/javascripts/dialogs/export.jsindex 26be7ac4d8..f491de5bd6 100644--- a/src/public/javascripts/dialogs/export.js+++ b/src/public/javascripts/dialogs/export.js@@ -117,14 +117,18 @@ function makeToast(id, message) {}ws.subscribeToMessages(async message => {- if (message.type === 'task-error' && message.taskType === 'export') {+ if (message.taskType !== 'export') {+ return;+ }++ if (message.type === 'task-error') {infoService.closePersistent(message.taskId);infoService.showError(message.message);}- else if (message.type === 'task-progress-count' && message.taskType === 'export') {+ else if (message.type === 'task-progress-count') {infoService.showPersistent(makeToast(message.taskId, "Export in progress: " + message.progressCount));}- else if (message.type === 'task-succeeded' && message.taskType === 'export') {+ else if (message.type === 'task-succeeded') {const toast = makeToast(message.taskId, "Import finished successfully.");toast.closeAfter = 5000;diff --git a/src/public/javascripts/services/branches.js b/src/public/javascripts/services/branches.jsindex 2de264d3ac..72bc6091a5 100644--- a/src/public/javascripts/services/branches.js+++ b/src/public/javascripts/services/branches.js@@ -6,6 +6,7 @@ import treeCache from "./tree_cache.js";import treeUtils from "./tree_utils.js";import hoistedNoteService from "./hoisted_note.js";import noteDetailService from "./note_detail.js";+import ws from "./ws.js";async function moveBeforeNode(nodesToMove, beforeNode) {nodesToMove = await filterRootNote(nodesToMove);@@ -105,14 +106,16 @@ async function deleteNodes(nodes) {const deleteClones = $deleteClonesCheckbox.find("input").is(":checked");+ const taskId = utils.randomString(10);+for (const node of nodes) {if (deleteClones) {- await server.remove('notes/' + node.data.noteId);+ await server.remove('notes/' + node.data.noteId + '?taskId=' + taskId);noteDetailService.noteDeleted(node.data.noteId);}else {- const {noteDeleted} = await server.remove('branches/' + node.data.branchId);+ const {noteDeleted} = await server.remove('branches/' + node.data.branchId + '?taskId=' + taskId);if (noteDeleted) {noteDetailService.noteDeleted(node.data.noteId);@@ -249,6 +252,33 @@ async function filterRootNote(nodes) {&& node.data.noteId !== hoistedNoteId);}+function makeToast(id, message) {+ return {+ id: id,+ title: "Delete status",+ message: message,+ icon: "trash"+ };+}++ws.subscribeToMessages(async message => {+ if (message.taskType !== 'delete-notes') {+ return;+ }++ if (message.type === 'task-error') {+ infoService.closePersistent(message.taskId);+ infoService.showError(message.message);+ } else if (message.type === 'task-progress-count') {+ infoService.showPersistent(makeToast(message.taskId, "Delete notes in progress: " + message.progressCount));+ } else if (message.type === 'task-succeeded') {+ const toast = makeToast(message.taskId, "Delete finished successfully.");+ toast.closeAfter = 5000;++ infoService.showPersistent(toast);+ }+});+export default {moveBeforeNode,moveAfterNode,diff --git a/src/public/javascripts/services/import.js b/src/public/javascripts/services/import.jsindex 771c9407f8..a67dd08f20 100644--- a/src/public/javascripts/services/import.js+++ b/src/public/javascripts/services/import.js@@ -48,14 +48,16 @@ function makeToast(id, message) {}ws.subscribeToMessages(async message => {- if (message.type === 'task-error' && message.taskType === 'import') {+ if (message.taskType !== 'import') {+ return;+ }++ if (message.type === 'task-error') {infoService.closePersistent(message.taskId);infoService.showError(message.message);- }- else if (message.type === 'task-progress-count' && message.taskType === 'import') {+ } else if (message.type === 'task-progress-count') {infoService.showPersistent(makeToast(message.taskId, "Import in progress: " + message.progressCount));- }- else if (message.type === 'task-succeeded' && message.taskType === 'import') {+ } else if (message.type === 'task-succeeded') {const toast = makeToast(message.taskId, "Import finished successfully.");toast.closeAfter = 5000;diff --git a/src/routes/api/branches.js b/src/routes/api/branches.jsindex f0261820a5..6160f65858 100644--- a/src/routes/api/branches.js+++ b/src/routes/api/branches.js@@ -6,6 +6,7 @@ const sync_table = require('../../services/sync_table');const tree = require('../../services/tree');const notes = require('../../services/notes');const repository = require('../../services/repository');+const TaskContext = require('../../services/task_context');/*** Code in this file deals with moving and cloning branches. Relationship between note and parent note is unique@@ -101,9 +102,10 @@ async function setExpanded(req) {async function deleteBranch(req) {const branch = await repository.getBranch(req.params.branchId);+ const taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes');return {- noteDeleted: await notes.deleteBranch(branch)+ noteDeleted: await notes.deleteBranch(branch, taskContext)};}diff --git a/src/routes/api/import.js b/src/routes/api/import.jsindex 8ca0771e30..65b4e0a7ec 100644--- a/src/routes/api/import.js+++ b/src/routes/api/import.js@@ -43,7 +43,7 @@ async function importToBranch(req) {let note; // typically root of the import - client can show it after finishing the import- const taskContext = TaskContext.getInstance(taskId, options);+ const taskContext = TaskContext.getInstance(taskId, 'import', options);try {if (extension === '.tar' && options.explodeArchives) {diff --git a/src/routes/api/notes.js b/src/routes/api/notes.jsindex 4695cb1e68..1d1c6632c9 100644--- a/src/routes/api/notes.js+++ b/src/routes/api/notes.js@@ -78,7 +78,7 @@ async function deleteNote(req) {const note = await repository.getNote(noteId);- const taskContext = new TaskContext(utils.randomString(10), 'delete-note');+ const taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes');for (const branch of await note.getBranches()) {await noteService.deleteBranch(branch, taskContext);diff --git a/src/services/task_context.js b/src/services/task_context.jsindex ed092cbfa8..2b7f1dbb0d 100644--- a/src/services/task_context.js+++ b/src/services/task_context.js@@ -17,9 +17,9 @@ class TaskContext {}/** @return {TaskContext} */- static getInstance(taskId, data) {+ static getInstance(taskId, taskType, data) {if (!taskContexts[taskId]) {- taskContexts[taskId] = new TaskContext(taskId, 'import', data);+ taskContexts[taskId] = new TaskContext(taskId, taskType, data);}return taskContexts[taskId];