diff --git a/src/common/base-store.ts b/src/common/base-store.ts index d30725d6bb..095e0c1877 100644 --- a/src/common/base-store.ts +++ b/src/common/base-store.ts @@ -56,9 +56,15 @@ export abstract class BaseStore extends Singleton { cwd: this.cwd(), }); - logger.info(`[STORE]: LOADED from ${this.path}`); - this.fromStore(this.storeConfig.store); + const res: any = this.fromStore(this.storeConfig.store); + + if (res instanceof Promise || (typeof res === "object" && res && typeof res.then === "function")) { + console.error(`${this.name} extends BaseStore's fromStore method returns a Promise or promise-like object. This is an error and must be fixed.`); + } + this.enableSync(); + + logger.info(`[STORE]: LOADED from ${this.path}`); } get name() { @@ -157,6 +163,9 @@ export abstract class BaseStore extends Singleton { /** * fromStore is called internally when a child class syncs with the file * system. + * + * Note: This function **must** be synchronous. + * * @param data the parsed information read from the stored JSON file */ protected abstract fromStore(data: T): void; diff --git a/src/common/hotbar-store.ts b/src/common/hotbar-store.ts index bad8b95a31..90694e9976 100644 --- a/src/common/hotbar-store.ts +++ b/src/common/hotbar-store.ts @@ -94,7 +94,7 @@ export class HotbarStore extends BaseStore { } @action - protected async fromStore(data: Partial = {}) { + protected fromStore(data: Partial = {}) { if (!data.hotbars || !data.hotbars.length) { this.hotbars = [{ id: uuid.v4(), diff --git a/src/common/user-store/user-store.ts b/src/common/user-store/user-store.ts index 1c0a5852c9..e4f9a8a007 100644 --- a/src/common/user-store/user-store.ts +++ b/src/common/user-store/user-store.ts @@ -155,7 +155,7 @@ export class UserStore extends BaseStore /* implements UserStore } @action - protected async fromStore(data: Partial = {}) { + protected fromStore(data: Partial = {}) { const { lastSeenAppVersion, preferences } = data; if (lastSeenAppVersion) { diff --git a/src/common/weblink-store.ts b/src/common/weblink-store.ts index 7b3a62f946..a91f83afa2 100644 --- a/src/common/weblink-store.ts +++ b/src/common/weblink-store.ts @@ -58,7 +58,8 @@ export class WeblinkStore extends BaseStore { this.load(); } - @action protected async fromStore(data: Partial = {}) { + @action + protected fromStore(data: Partial = {}) { this.weblinks = data.weblinks || []; }