From ad69e32c55b06f408335ac0041e4cab11b5c97a9 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Tue, 3 Aug 2021 14:59:45 -0400 Subject: [PATCH] change when to/fromStore are located Signed-off-by: Sebastian Malton --- src/common/hotbar-store.ts | 72 +++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/common/hotbar-store.ts b/src/common/hotbar-store.ts index c1f5af7991..5bfb1ac73a 100644 --- a/src/common/hotbar-store.ts +++ b/src/common/hotbar-store.ts @@ -69,6 +69,42 @@ export class HotbarStore extends BaseStore { return this.hotbarIndex(this.activeHotbarId); } + @action + protected fromStore(data: Partial = {}) { + if (!data.hotbars || !data.hotbars.length) { + const hotbar = getEmptyHotbar("Default"); + const { metadata: { uid, name, source } } = catalogEntity; + const initialItem = { entity: { uid, name, source } }; + + hotbar.items[0] = initialItem; + + this.hotbars = [hotbar]; + } else { + this.hotbars = data.hotbars; + } + + this.hotbars.forEach(ensureExactHotbarItemLength); + + if (data.activeHotbarId) { + if (this.getById(data.activeHotbarId)) { + this.activeHotbarId = data.activeHotbarId; + } + } + + if (!this.activeHotbarId) { + this.activeHotbarId = this.hotbars[0].id; + } + } + + toJSON(): HotbarStoreModel { + const model: HotbarStoreModel = { + hotbars: this.hotbars, + activeHotbarId: this.activeHotbarId + }; + + return toJS(model); + } + getActive() { return this.getById(this.activeHotbarId); } @@ -238,42 +274,6 @@ export class HotbarStore extends BaseStore { hotbarStore.activeHotbarId = hotbarStore.hotbars[index].id; } - - @action - protected fromStore(data: Partial = {}) { - if (!data.hotbars || !data.hotbars.length) { - const hotbar = getEmptyHotbar("Default"); - const { metadata: { uid, name, source } } = catalogEntity; - const initialItem = { entity: { uid, name, source } }; - - hotbar.items[0] = initialItem; - - this.hotbars = [hotbar]; - } else { - this.hotbars = data.hotbars; - } - - this.hotbars.forEach(ensureExactHotbarItemLength); - - if (data.activeHotbarId) { - if (this.getById(data.activeHotbarId)) { - this.activeHotbarId = data.activeHotbarId; - } - } - - if (!this.activeHotbarId) { - this.activeHotbarId = this.hotbars[0].id; - } - } - - toJSON(): HotbarStoreModel { - const model: HotbarStoreModel = { - hotbars: this.hotbars, - activeHotbarId: this.activeHotbarId - }; - - return toJS(model); - } } /**