mirror of
https://github.com/TriliumNext/Notes.git
synced 2026-04-28 16:29:11 -05:00
simplified updating note content
This commit is contained in:
+4
-28
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user