From e25f7fc6557990713313659e637ef42b41cccfc4 Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Thu, 6 May 2021 11:48:31 +0300 Subject: [PATCH] Saving more entity data to HotbarItem Signed-off-by: Alex Andreev --- src/common/hotbar-store.ts | 10 +++++++++- src/migrations/hotbar-store/5.0.0-alpha.0.ts | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/common/hotbar-store.ts b/src/common/hotbar-store.ts index e4a871f093..216c363088 100644 --- a/src/common/hotbar-store.ts +++ b/src/common/hotbar-store.ts @@ -8,6 +8,8 @@ import isNull from "lodash/isNull"; export interface HotbarItem { entity: { uid: string; + name: string; + source: string; }; params?: { [key: string]: string; @@ -123,9 +125,14 @@ export class HotbarStore extends BaseStore { } } + @action addToHotbar(item: CatalogEntityItem, cellIndex = -1) { const hotbar = this.getActive(); - const newItem = { entity: { uid: item.id }}; + const newItem = { entity: { + uid: item.id, + name: item.name, + source: item.source + }}; if (hotbar.items.find(i => i?.entity.uid === item.id)) { return; @@ -146,6 +153,7 @@ export class HotbarStore extends BaseStore { } } + @action removeFromHotbar(uid: string) { const hotbar = this.getActive(); const index = hotbar.items.findIndex((i) => i?.entity.uid === uid); diff --git a/src/migrations/hotbar-store/5.0.0-alpha.0.ts b/src/migrations/hotbar-store/5.0.0-alpha.0.ts index 58d7073761..b9ec80103b 100644 --- a/src/migrations/hotbar-store/5.0.0-alpha.0.ts +++ b/src/migrations/hotbar-store/5.0.0-alpha.0.ts @@ -22,7 +22,11 @@ export default migration({ } hotbar.items.push({ - entity: { uid: cluster.id }, + entity: { + uid: cluster.id, + name: cluster.name, + source: cluster.source + }, params: {} }); });