Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix handling of note history - when saving note history we save previous state, not current
azivnerf1256423ac16
diff --git a/public/javascripts/dialogs/note_history.js b/public/javascripts/dialogs/note_history.jsindex a6da3321b2..3bbbfd2c8e 100644--- a/public/javascripts/dialogs/note_history.js+++ b/public/javascripts/dialogs/note_history.js@@ -27,7 +27,7 @@ const noteHistory = (function() {historyItems = await server.get('notes-history/' + noteId);for (const item of historyItems) {- const dateModified = getDateFromTS(item.date_modified_to);+ const dateModified = getDateFromTS(item.date_modified_from);$("#note-history-list").append($('<option>', {value: item.note_history_id,diff --git a/services/build.js b/services/build.jsindex 3508438684..3581c3965d 100644--- a/services/build.js+++ b/services/build.js@@ -1 +1 @@-module.exports = { build_date:"2017-12-06T21:05:03-05:00", build_revision: "bbd177481523bf6d7c9388b0ddf65af7f5c61e6b" };+module.exports = { build_date:"2017-12-06T21:44:45-05:00", build_revision: "4f47c4d6e919aefd303617ac459cea41a1761385" };diff --git a/services/notes.js b/services/notes.jsindex 95e8cc4fb0..a568f06b51 100644--- a/services/notes.js+++ b/services/notes.js@@ -134,9 +134,6 @@ async function protectNoteHistory(noteId, dataKey, protect) {}async function updateNote(noteId, newNote, ctx) {- let noteTitleForHistory = newNote.detail.note_title;- let noteTextForHistory = newNote.detail.note_text;-if (newNote.detail.is_protected) {await encryptNote(newNote, ctx);}@@ -147,19 +144,21 @@ async function updateNote(noteId, newNote, ctx) {const historyCutoff = now - historySnapshotTimeInterval;- const existingNoteHistoryId = await sql.getSingleValue("SELECT note_history_id FROM notes_history WHERE note_id = ? AND date_modified_from >= ?", [noteId, historyCutoff]);+ const existingNoteHistoryId = await sql.getSingleValue("SELECT note_history_id FROM notes_history WHERE note_id = ? AND date_modified_to >= ?", [noteId, historyCutoff]);await sql.doInTransaction(async () => {if (!existingNoteHistoryId && (now - newNote.detail.date_created) >= historySnapshotTimeInterval) {+ const oldNote = await sql.getSingleResult("SELECT * FROM notes WHERE note_id = ?", [noteId]);+const newNoteHistoryId = utils.newNoteHistoryId();await sql.insert('notes_history', {note_history_id: newNoteHistoryId,note_id: noteId,- note_title: noteTitleForHistory,- note_text: noteTextForHistory,- is_protected: false, // we don't care about encryption - this will be handled in protectNoteHistory()- date_modified_from: now,+ note_title: oldNote.note_title,+ note_text: oldNote.note_text,+ is_protected: oldNote.is_protected,+ date_modified_from: oldNote.date_modified,date_modified_to: now});