A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
collections: refactor notebooks init
thecodrr3a6a126d5dae
diff --git a/packages/core/api/index.js b/packages/core/api/index.jsindex e49fc8d22..29e3dd6a2 100644--- a/packages/core/api/index.js+++ b/packages/core/api/index.js@@ -17,6 +17,7 @@ class Database {async init() {this.notes = await Notes.new(this);+ this.notebooks = await Notebooks.new(this);/* this.notebooks = new Notebooks(this.context);this.notes = new Notes(this.context);this.trash = new Trash(this.context);diff --git a/packages/core/collections/notebooks.js b/packages/core/collections/notebooks.jsindex c8ad3a872..83b8d3757 100644--- a/packages/core/collections/notebooks.js+++ b/packages/core/collections/notebooks.js@@ -1,29 +1,14 @@-import CachedCollection from "../database/cached-collection";+import Collection from "./collection";import fuzzysearch from "fuzzysearch";import Notebook from "../models/notebook";import sort from "fast-sort";import getId from "../utils/id";-var tfun = require("transfun/transfun.js").tfun;if (!tfun) {tfun = global.tfun;}-export default class Notebooks {- constructor(context) {- this._collection = new CachedCollection(context, "notebooks");- }-- /**- *- * @param {import('./notes').default} notes- * @param {import('./trash').default} trash- */- init(notes, trash) {- this._trash = trash;- this._notes = notes;- return this._collection.init();- }+export default class Notebooks extends Collection {async add(notebookArg) {if (!notebookArg) throw new Error("Notebook cannot be undefined or null.");@@ -97,7 +82,7 @@ export default class Notebooks {notebook.topics.delete(...notebook.data.topics));await this._collection.removeItem(id);- await this._trash.add(notebook.data);+ await this._db.trash.add(notebook.data);}}