Skip to content

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

core: make max note versions configurable

Abdullah Attab03a4559c5dd
diff --git a/packages/core/src/api/index.ts b/packages/core/src/api/index.ts
index e081b4f11..40070c8eb 100644
--- a/packages/core/src/api/index.ts
+++ b/packages/core/src/api/index.ts
@@ -93,6 +93,7 @@ type Options = {
eventsource?: EventSourceConstructor;
fs: IFileStorage;
compressor: () => Promise<ICompressor>;
+ maxNoteVersions: () => Promise<number | undefined>;
batchSize: number;
};
diff --git a/packages/core/src/collections/note-history.ts b/packages/core/src/collections/note-history.ts
index 270d8ee01..bcbd8b8ba 100644
--- a/packages/core/src/collections/note-history.ts
+++ b/packages/core/src/collections/note-history.ts
@@ -27,7 +27,6 @@ import { SessionContent } from "./session-content.js";
export class NoteHistory implements ICollection {
name = "notehistory";
- versionsLimit = 100;
sessionContent;
readonly collection: SQLCollection<"notehistory", HistorySession>;
constructor(private readonly db: Database) {
@@ -100,7 +99,9 @@ export class NoteHistory implements ICollection {
return sessionId;
}
- private async cleanup(noteId: string, limit = this.versionsLimit) {
+ private async cleanup(noteId: string) {
+ const limit = await this.db.options.maxNoteVersions();
+ if (!limit) return;
const history = await this.db
.sql()
.selectFrom("notehistory")