simplified updating note content

This commit is contained in:
zadam
2022-06-13 22:38:59 +02:00
parent 7edcd5d746
commit 4cec856e21
12 changed files with 23 additions and 51 deletions
+4 -28
View File
@@ -520,7 +520,7 @@ function saveNoteRevisionIfNeeded(note) {
}
}
function updateNote(noteId, noteUpdates) {
function updateNoteContent(noteId, content) {
const note = becca.getNote(noteId);
if (!note.isContentAvailable()) {
@@ -529,33 +529,9 @@ function updateNote(noteId, noteUpdates) {
saveNoteRevisionIfNeeded(note);
// if protected status changed, then we need to encrypt/decrypt the content anyway
if (['file', 'image'].includes(note.type) && note.isProtected !== noteUpdates.isProtected) {
noteUpdates.content = note.getContent();
}
content = saveLinks(note, content);
const noteTitleChanged = note.title !== noteUpdates.title;
note.title = noteUpdates.title;
note.isProtected = noteUpdates.isProtected;
note.save();
if (noteUpdates.content !== undefined && noteUpdates.content !== null) {
noteUpdates.content = saveLinks(note, noteUpdates.content);
note.setContent(noteUpdates.content);
}
if (noteTitleChanged) {
triggerNoteTitleChanged(note);
}
noteRevisionService.protectNoteRevisions(note);
return {
dateModified: note.dateModified,
utcDateModified: note.utcDateModified
};
note.setContent(content);
}
/**
@@ -908,7 +884,7 @@ sqlInit.dbReady.then(() => {
module.exports = {
createNewNote,
createNewNoteWithTarget,
updateNote,
updateNoteContent,
undeleteNote,
protectNoteRecursively,
scanForLinks,