mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
cleanup
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
b0e673e3b0
commit
f849a75c7c
@ -1,7 +1,7 @@
|
|||||||
import { action, comparer, observable, toJS } from "mobx";
|
import { action, comparer, observable, toJS } from "mobx";
|
||||||
import { BaseStore } from "./base-store";
|
import { BaseStore } from "./base-store";
|
||||||
import migrations from "../migrations/hotbar-store";
|
import migrations from "../migrations/hotbar-store";
|
||||||
import { v4 as uuid } from "uuid";
|
import uuid from "uuid";
|
||||||
|
|
||||||
export interface HotbarItem {
|
export interface HotbarItem {
|
||||||
entity: {
|
entity: {
|
||||||
@ -55,7 +55,7 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
|
|||||||
@action protected async fromStore(data: Partial<HotbarStoreModel> = {}) {
|
@action protected async fromStore(data: Partial<HotbarStoreModel> = {}) {
|
||||||
if (data.hotbars?.length === 0) {
|
if (data.hotbars?.length === 0) {
|
||||||
this.hotbars = [{
|
this.hotbars = [{
|
||||||
id: uuid(),
|
id: uuid.v4(),
|
||||||
name: "Default",
|
name: "Default",
|
||||||
items: []
|
items: []
|
||||||
}];
|
}];
|
||||||
@ -87,7 +87,7 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
add(hotbar: Partial<Hotbar>) {
|
add(hotbar: Partial<Hotbar>) {
|
||||||
hotbar.id = uuid();
|
hotbar.id = uuid.v4();
|
||||||
|
|
||||||
if (!hotbar.items) {
|
if (!hotbar.items) {
|
||||||
hotbar.items = [];
|
hotbar.items = [];
|
||||||
|
|||||||
@ -1,19 +1,16 @@
|
|||||||
// Cleans up a store that had the state related data stored
|
// Cleans up a store that had the state related data stored
|
||||||
import { Hotbar } from "../../common/hotbar-store";
|
import { Hotbar } from "../../common/hotbar-store";
|
||||||
import { migration } from "../migration-wrapper";
|
import { migration } from "../migration-wrapper";
|
||||||
import { v4 as uuid } from "uuid";
|
import uuid from "uuid";
|
||||||
|
|
||||||
export default migration({
|
export default migration({
|
||||||
version: "5.0.0-alpha.2",
|
version: "5.0.0-alpha.2",
|
||||||
run(store) {
|
run(store) {
|
||||||
const hotbars = (store.get("hotbars") || []) as Hotbar[];
|
const hotbars = (store.get("hotbars") || []) as Hotbar[];
|
||||||
|
|
||||||
hotbars.forEach((hotbar) => {
|
store.set("hotbars", hotbars.map((hotbar) => ({
|
||||||
if (!hotbar.id) {
|
id: uuid.v4(),
|
||||||
hotbar.id = uuid();
|
...hotbar
|
||||||
}
|
})));
|
||||||
});
|
|
||||||
|
|
||||||
store.set("hotbars", hotbars);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user