Skip to content

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

collections: check if collection has clear fn

thecodrr14b72ee2f41f
diff --git a/packages/core/collections/collection.js b/packages/core/collections/collection.js
index d64a56191..713c876fc 100644
--- a/packages/core/collections/collection.js
+++ b/packages/core/collections/collection.js
@@ -7,8 +7,8 @@ class Collection {
await collection._collection.init();
if (collection.init) await collection.init();
- if (collection.clear)
- this._db.ev.subscribe("clear", collection._collection.clear);
+ if (collection._collection.clear)
+ this._db.ev.subscribe("clear", () => collection._collection.clear());
return collection;
}
diff --git a/packages/core/database/cached-collection.js b/packages/core/database/cached-collection.js
index 33f854674..4736b7993 100644
--- a/packages/core/database/cached-collection.js
+++ b/packages/core/database/cached-collection.js
@@ -14,9 +14,9 @@ export default class CachedCollection {
if (data.length > 0) this.map = new Map(data);
}
- clear = () => {
+ clear() {
this.map.clear();
- };
+ }
/**
*