Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: merge dateCreated when upserting session

thecodrre7b34bdbc7e1
diff --git a/packages/core/collections/note-history.js b/packages/core/collections/note-history.js
index 0a7a88c0f..beacdc458 100644
--- a/packages/core/collections/note-history.js
+++ b/packages/core/collections/note-history.js
@@ -65,17 +65,15 @@ export default class NoteHistory extends Collection {
async add(noteId, dateEdited, content) {
if (!noteId || !dateEdited || !content) return;
let sessionId = `${noteId}_${dateEdited}`;
- let exists = await this._collection.exists(sessionId);
+ let oldSession = await this._collection.getItem(sessionId);
let locked = this._db.notes.note(noteId)?.data?.locked;
let session = {
id: sessionId,
sessionContentId: makeSessionContentId(sessionId),
noteId,
+ dateCreated: oldSession ? oldSession.dateCreated : Date.now(),
};
- if (!exists) {
- session.dateCreated = Date.now();
- }
if (locked) {
session.locked = true;