Skip to content

Build your personal knowledge base with Trilium Notes

fix error when saving unprotected notes

azivnerc4a9aaa52d5b
diff --git a/services/build.js b/services/build.js
index b1b6aa35ba..0100105209 100644
--- a/services/build.js
+++ b/services/build.js
@@ -1 +1 @@
-module.exports = { build_date:"2017-11-16T19:29:52-05:00", build_revision: "c371ffb5974d8dccaec76c78dfa91dd54fcc624e" };
+module.exports = { build_date:"2017-11-17T00:09:29-05:00", build_revision: "a6bf04f8d4dc92445e6b4decd7dbbaa2f3e3ebaa" };
diff --git a/services/notes.js b/services/notes.js
index 78fafde8d2..cc676c852a 100644
--- a/services/notes.js
+++ b/services/notes.js
@@ -166,7 +166,7 @@ async function updateNote(noteId, newNote, ctx) {
await sync_table.addNoteHistorySync(newNoteHistoryId);
}
- await protectNoteHistory(noteId, ctx.getDataKey(), newNote.detail.is_protected);
+ await protectNoteHistory(noteId, ctx.getDataKeyOrNull(), newNote.detail.is_protected);
await addNoteAudits(origNoteDetail, newNote.detail, ctx.browserId);
diff --git a/services/request_context.js b/services/request_context.js
index f9c83c5966..e1526e98cf 100644
--- a/services/request_context.js
+++ b/services/request_context.js
@@ -17,9 +17,18 @@ module.exports = function(req) {
return protected_session.getDataKey(req);
}
+ function getDataKeyOrNull() {
+ if (!isProtectedSessionAvailable()) {
+ return null;
+ }
+
+ return protected_session.getDataKey(req);
+ }
+
return {
browserId,
isProtectedSessionAvailable,
- getDataKey
+ getDataKey,
+ getDataKeyOrNull
};
};
\ No newline at end of file