mirror of
https://github.com/zadam/trilium.git
synced 2025-11-14 09:15:50 +01:00
use .markAsDeleted() instead of setting .isDeleted manually
This commit is contained in:
@@ -36,8 +36,7 @@ function updateNoteAttribute(req) {
|
||||
newAttribute.save();
|
||||
}
|
||||
|
||||
attribute.isDeleted = true;
|
||||
attribute.save();
|
||||
attribute.markAsDeleted();
|
||||
|
||||
return {
|
||||
attributeId: newAttribute ? newAttribute.attributeId : null
|
||||
@@ -61,7 +60,7 @@ function updateNoteAttribute(req) {
|
||||
}
|
||||
else {
|
||||
// relations should never have empty target
|
||||
attribute.isDeleted = true;
|
||||
attribute.markAsDeleted();
|
||||
}
|
||||
|
||||
attribute.save();
|
||||
@@ -108,7 +107,7 @@ function deleteNoteAttribute(req) {
|
||||
return [400, `Attribute ${attributeId} is not owned by ${noteId}`];
|
||||
}
|
||||
|
||||
attribute.markAttributeAsDeleted();
|
||||
attribute.markAsDeleted();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,8 +173,7 @@ function updateNoteAttributes(req) {
|
||||
// all the remaining existing attributes are not defined anymore and should be deleted
|
||||
for (const toDeleteAttr of existingAttrs) {
|
||||
if (!toDeleteAttr.isAutoLink()) {
|
||||
toDeleteAttr.isDeleted = true;
|
||||
toDeleteAttr.save();
|
||||
toDeleteAttr.markAsDeleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,8 +219,7 @@ function deleteRelation(req) {
|
||||
let attribute = repository.getEntity(`SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ? AND type = 'relation' AND name = ? AND value = ?`, [sourceNoteId, name, targetNoteId]);
|
||||
|
||||
if (attribute) {
|
||||
attribute.isDeleted = true;
|
||||
attribute.save();
|
||||
attribute.markAsDeleted();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ function moveBranchToParent(req) {
|
||||
const newBranch = branchToMove.createClone(parentBranch.noteId, newNotePos);
|
||||
newBranch.save();
|
||||
|
||||
branchToMove.isDeleted = true;
|
||||
branchToMove.markAsDeleted();
|
||||
branchToMove.save();
|
||||
|
||||
return { success: true };
|
||||
@@ -85,8 +85,7 @@ function moveBranchBeforeNote(req) {
|
||||
const newBranch = branchToMove.createClone(beforeBranch.parentNoteId, beforeBranch.notePosition);
|
||||
newBranch.save();
|
||||
|
||||
branchToMove.isDeleted = true;
|
||||
branchToMove.save();
|
||||
branchToMove.markAsDeleted();
|
||||
}
|
||||
|
||||
return { success: true };
|
||||
@@ -121,8 +120,7 @@ function moveBranchAfterNote(req) {
|
||||
const newBranch = branchToMove.createClone(afterNote.parentNoteId, movedNotePosition);
|
||||
newBranch.save();
|
||||
|
||||
branchToMove.isDeleted = true;
|
||||
branchToMove.save();
|
||||
branchToMove.markAsDeleted();
|
||||
}
|
||||
|
||||
return { success: true };
|
||||
|
||||
@@ -59,22 +59,19 @@ async function searchFromNote(req) {
|
||||
|
||||
const ACTION_HANDLERS = {
|
||||
deleteNote: (action, note) => {
|
||||
note.isDeleted = true;
|
||||
note.save();
|
||||
note.markAsDeleted();
|
||||
},
|
||||
deleteNoteRevisions: (action, note) => {
|
||||
noteRevisionService.eraseNoteRevisions(note.getNoteRevisions().map(rev => rev.noteRevisionId));
|
||||
},
|
||||
deleteLabel: (action, note) => {
|
||||
for (const label of note.getOwnedLabels(action.labelName)) {
|
||||
label.isDeleted = true;
|
||||
label.save();
|
||||
label.markAsDeleted();
|
||||
}
|
||||
},
|
||||
deleteRelation: (action, note) => {
|
||||
for (const relation of note.getOwnedRelations(action.relationName)) {
|
||||
relation.isDeleted = true;
|
||||
relation.save();
|
||||
relation.markAsDeleted();
|
||||
}
|
||||
},
|
||||
renameLabel: (action, note) => {
|
||||
|
||||
Reference in New Issue
Block a user