From f849a75c7c80f9513d5b27fe15b8541d7f203588 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Mon, 19 Apr 2021 21:06:37 +0300 Subject: [PATCH] cleanup Signed-off-by: Jari Kolehmainen --- src/common/hotbar-store.ts | 6 +++--- src/migrations/hotbar-store/5.0.0-alpha.2.ts | 13 +++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/common/hotbar-store.ts b/src/common/hotbar-store.ts index 67d436b177..5b84be9b9d 100644 --- a/src/common/hotbar-store.ts +++ b/src/common/hotbar-store.ts @@ -1,7 +1,7 @@ import { action, comparer, observable, toJS } from "mobx"; import { BaseStore } from "./base-store"; import migrations from "../migrations/hotbar-store"; -import { v4 as uuid } from "uuid"; +import uuid from "uuid"; export interface HotbarItem { entity: { @@ -55,7 +55,7 @@ export class HotbarStore extends BaseStore { @action protected async fromStore(data: Partial = {}) { if (data.hotbars?.length === 0) { this.hotbars = [{ - id: uuid(), + id: uuid.v4(), name: "Default", items: [] }]; @@ -87,7 +87,7 @@ export class HotbarStore extends BaseStore { } add(hotbar: Partial) { - hotbar.id = uuid(); + hotbar.id = uuid.v4(); if (!hotbar.items) { hotbar.items = []; diff --git a/src/migrations/hotbar-store/5.0.0-alpha.2.ts b/src/migrations/hotbar-store/5.0.0-alpha.2.ts index 03b8b6526f..306879202e 100644 --- a/src/migrations/hotbar-store/5.0.0-alpha.2.ts +++ b/src/migrations/hotbar-store/5.0.0-alpha.2.ts @@ -1,19 +1,16 @@ // Cleans up a store that had the state related data stored import { Hotbar } from "../../common/hotbar-store"; import { migration } from "../migration-wrapper"; -import { v4 as uuid } from "uuid"; +import uuid from "uuid"; export default migration({ version: "5.0.0-alpha.2", run(store) { const hotbars = (store.get("hotbars") || []) as Hotbar[]; - hotbars.forEach((hotbar) => { - if (!hotbar.id) { - hotbar.id = uuid(); - } - }); - - store.set("hotbars", hotbars); + store.set("hotbars", hotbars.map((hotbar) => ({ + id: uuid.v4(), + ...hotbar + }))); } });