mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
change when to/fromStore are located
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
d21ce7e7e1
commit
ad69e32c55
@ -69,6 +69,42 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
|
|||||||
return this.hotbarIndex(this.activeHotbarId);
|
return this.hotbarIndex(this.activeHotbarId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
protected fromStore(data: Partial<HotbarStoreModel> = {}) {
|
||||||
|
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() {
|
getActive() {
|
||||||
return this.getById(this.activeHotbarId);
|
return this.getById(this.activeHotbarId);
|
||||||
}
|
}
|
||||||
@ -238,42 +274,6 @@ export class HotbarStore extends BaseStore<HotbarStoreModel> {
|
|||||||
|
|
||||||
hotbarStore.activeHotbarId = hotbarStore.hotbars[index].id;
|
hotbarStore.activeHotbarId = hotbarStore.hotbars[index].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
|
||||||
protected fromStore(data: Partial<HotbarStoreModel> = {}) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user