1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2021-04-19 21:06:37 +03:00
parent b0e673e3b0
commit f849a75c7c
2 changed files with 8 additions and 11 deletions

View File

@ -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<HotbarStoreModel> {
@action protected async fromStore(data: Partial<HotbarStoreModel> = {}) {
if (data.hotbars?.length === 0) {
this.hotbars = [{
id: uuid(),
id: uuid.v4(),
name: "Default",
items: []
}];
@ -87,7 +87,7 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
}
add(hotbar: Partial<Hotbar>) {
hotbar.id = uuid();
hotbar.id = uuid.v4();
if (!hotbar.items) {
hotbar.items = [];

View File

@ -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
})));
}
});