mirror of
https://github.com/zadam/trilium.git
synced 2025-06-05 09:28:45 +02:00
fixes to delete notifications
This commit is contained in:
parent
9f4ca279aa
commit
82bbf4173b
@ -108,14 +108,21 @@ async function deleteNodes(nodes) {
|
||||
|
||||
const taskId = utils.randomString(10);
|
||||
|
||||
let counter = 0;
|
||||
|
||||
for (const node of nodes) {
|
||||
counter++;
|
||||
|
||||
const last = counter === nodes.length;
|
||||
const query = `?taskId=${taskId}&last=${last ? 'true' : 'false'}`;
|
||||
|
||||
if (deleteClones) {
|
||||
await server.remove('notes/' + node.data.noteId + '?taskId=' + taskId);
|
||||
await server.remove(`notes/${node.data.noteId}` + query);
|
||||
|
||||
noteDetailService.noteDeleted(node.data.noteId);
|
||||
}
|
||||
else {
|
||||
const {noteDeleted} = await server.remove('branches/' + node.data.branchId + '?taskId=' + taskId);
|
||||
const {noteDeleted} = await server.remove(`branches/${node.data.branchId}` + query);
|
||||
|
||||
if (noteDeleted) {
|
||||
noteDetailService.noteDeleted(node.data.noteId);
|
||||
@ -167,8 +174,6 @@ async function deleteNodes(nodes) {
|
||||
node.setFocus(true);
|
||||
}
|
||||
|
||||
infoService.showMessage("Note(s) has been deleted.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -65,8 +65,8 @@ ws.subscribeToMessages(async message => {
|
||||
|
||||
await treeService.reloadNote(message.parentNoteId);
|
||||
|
||||
if (message.importedNoteId) {
|
||||
const node = await treeService.activateNote(message.importedNoteId);
|
||||
if (message.result.importedNoteId) {
|
||||
const node = await treeService.activateNote(message.result.importedNoteId);
|
||||
|
||||
node.setExpanded(true);
|
||||
}
|
||||
|
@ -98,7 +98,14 @@ async function getNodeFromPath(notePath, expand = false, expandOpts = {}) {
|
||||
const hoistedNoteId = await hoistedNoteService.getHoistedNoteId();
|
||||
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) {
|
||||
// there must be exactly one node with given hoistedNoteId
|
||||
parentNode = getNodesByNoteId(childNoteId)[0];
|
||||
|
@ -864,4 +864,14 @@ a.external:not(.no-arrow):after, a[href^="http://"]:not(.no-arrow):after, a[href
|
||||
width: 100%;
|
||||
top: 20px;
|
||||
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) {
|
||||
const last = req.query.last === 'true';
|
||||
const branch = await repository.getBranch(req.params.branchId);
|
||||
const taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes');
|
||||
|
||||
const noteDeleted = await notes.deleteBranch(branch, taskContext);
|
||||
|
||||
if (last) {
|
||||
taskContext.taskSucceeded();
|
||||
}
|
||||
|
||||
return {
|
||||
noteDeleted: await notes.deleteBranch(branch, taskContext)
|
||||
noteDeleted: noteDeleted
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,10 @@ async function importToBranch(req) {
|
||||
|
||||
if (last === "true") {
|
||||
// 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
|
||||
|
@ -75,14 +75,20 @@ async function updateNote(req) {
|
||||
|
||||
async function deleteNote(req) {
|
||||
const noteId = req.params.noteId;
|
||||
const taskId = req.query.taskId;
|
||||
const last = req.query.last === 'true';
|
||||
|
||||
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()) {
|
||||
await noteService.deleteBranch(branch, taskContext);
|
||||
}
|
||||
|
||||
if (last) {
|
||||
await taskContext.taskSucceeded();
|
||||
}
|
||||
}
|
||||
|
||||
async function sortNotes(req) {
|
||||
|
@ -40,7 +40,6 @@ class TaskContext {
|
||||
}
|
||||
}
|
||||
|
||||
// must remaing non-static
|
||||
async reportError(message) {
|
||||
await ws.sendMessageToAllClients({
|
||||
type: 'task-error',
|
||||
@ -50,14 +49,12 @@ class TaskContext {
|
||||
});
|
||||
}
|
||||
|
||||
// must remaing non-static
|
||||
async taskSucceeded(parentNoteId, importedNoteId) {
|
||||
async taskSucceeded(result) {
|
||||
await ws.sendMessageToAllClients({
|
||||
type: 'task-succeeded',
|
||||
taskId: this.taskId,
|
||||
taskType: this.taskType,
|
||||
parentNoteId: parentNoteId,
|
||||
importedNoteId: importedNoteId
|
||||
result: result
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user