Skip to content

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

core: restoring a history session should create a new version

Abdullah Atta80a77871a0a2
diff --git a/packages/core/src/collections/note-history.ts b/packages/core/src/collections/note-history.ts
index 0312b44ad..bb1dc2729 100644
--- a/packages/core/src/collections/note-history.ts
+++ b/packages/core/src/collections/note-history.ts
@@ -129,6 +129,12 @@ export class NoteHistory implements ICollection {
return await this.sessionContent.get(session.sessionContentId);
}
+ async session(sessionId: string) {
+ const session = await this.collection.get(sessionId);
+ if (!session || isDeleted(session)) return;
+ return session;
+ }
+
async remove(sessionId: string) {
const session = await this.collection.get(sessionId);
if (!session || isDeleted(session)) return;
@@ -175,12 +181,15 @@ export class NoteHistory implements ICollection {
if (session.locked && isCipher(content.data)) {
await this.db.content.add({
id: note.contentId,
+ noteId: session.noteId,
+ sessionId: `${Date.now()}`,
data: content.data,
type: content.type
});
} else if (content.data && !isCipher(content.data)) {
await this.db.notes.add({
id: session.noteId,
+ sessionId: `${Date.now()}`,
content: {
data: content.data,
type: content.type