mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-21 14:09:34 +01:00
fix: init trash & monographs after notes
This commit is contained in:
@@ -70,6 +70,15 @@ class Database {
|
|||||||
this.syncer.stopAutoSync();
|
this.syncer.stopAutoSync();
|
||||||
this.disconnectSSE();
|
this.disconnectSSE();
|
||||||
});
|
});
|
||||||
|
EV.subscribe(EVENTS.databaseCollectionInitiated, async (collectionName) => {
|
||||||
|
switch (collectionName) {
|
||||||
|
case "notes": {
|
||||||
|
await this.monographs.init();
|
||||||
|
await this.trash.init();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.session = new Session(this.storage);
|
this.session = new Session(this.storage);
|
||||||
await this._validate();
|
await this._validate();
|
||||||
@@ -103,7 +112,6 @@ class Database {
|
|||||||
|
|
||||||
this.trash = new Trash(this);
|
this.trash = new Trash(this);
|
||||||
|
|
||||||
await this.trash.cleanup();
|
|
||||||
await this.settings.init();
|
await this.settings.init();
|
||||||
await this.outbox.init();
|
await this.outbox.init();
|
||||||
await this.user.init();
|
await this.user.init();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class Collection {
|
|||||||
static async new(db, name, cached = true, deferred = false) {
|
static async new(db, name, cached = true, deferred = false) {
|
||||||
const collection = new this(db, name, cached);
|
const collection = new this(db, name, cached);
|
||||||
|
|
||||||
if (!deferred && collection.init) await collection.init();
|
if (!deferred) await collection.init();
|
||||||
else await collection._collection.indexer.init();
|
else await collection._collection.indexer.init();
|
||||||
|
|
||||||
if (collection._collection.clear)
|
if (collection._collection.clear)
|
||||||
@@ -21,6 +21,7 @@ class Collection {
|
|||||||
async init() {
|
async init() {
|
||||||
if (this.initialized) return;
|
if (this.initialized) return;
|
||||||
await this._collection.init();
|
await this._collection.init();
|
||||||
|
EV.publish(EVENTS.databaseCollectionInitiated, this.collectionName);
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,6 +31,7 @@ class Collection {
|
|||||||
*/
|
*/
|
||||||
constructor(db, name, cached) {
|
constructor(db, name, cached) {
|
||||||
this._db = db;
|
this._db = db;
|
||||||
|
this.collectionName = name;
|
||||||
if (cached) this._collection = new CachedCollection(this._db.storage, name);
|
if (cached) this._collection = new CachedCollection(this._db.storage, name);
|
||||||
else this._collection = new IndexedCollection(this._db.storage, name);
|
else this._collection = new IndexedCollection(this._db.storage, name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export const EVENTS = {
|
|||||||
databaseSyncRequested: "db:syncRequested",
|
databaseSyncRequested: "db:syncRequested",
|
||||||
databaseMigrated: "db:migrated",
|
databaseMigrated: "db:migrated",
|
||||||
databaseUpdated: "db:updated",
|
databaseUpdated: "db:updated",
|
||||||
|
databaseCollectionInitiated: "db:collectionInitiated",
|
||||||
appRefreshRequested: "app:refreshRequested",
|
appRefreshRequested: "app:refreshRequested",
|
||||||
noteRemoved: "note:removed",
|
noteRemoved: "note:removed",
|
||||||
tokenRefreshed: "token:refreshed",
|
tokenRefreshed: "token:refreshed",
|
||||||
|
|||||||
Reference in New Issue
Block a user