mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
collections: check if collection has clear fn
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@ export default class CachedCollection {
|
||||
if (data.length > 0) this.map = new Map(data);
|
||||
}
|
||||
|
||||
clear = () => {
|
||||
clear() {
|
||||
this.map.clear();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user