fixes to delete notifications

This commit is contained in:
zadam
2019-10-19 00:11:07 +02:00
parent 9f4ca279aa
commit 82bbf4173b
8 changed files with 50 additions and 15 deletions

View File

@@ -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
};
}

View File

@@ -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

View File

@@ -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) {