mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Migration for adding extra data to hotbar items
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
c679a88ff1
commit
3a2b8eb4b8
@ -22,11 +22,7 @@ export default migration({
|
||||
}
|
||||
|
||||
hotbar.items.push({
|
||||
entity: {
|
||||
uid: cluster.id,
|
||||
name: cluster.name,
|
||||
source: cluster.source
|
||||
},
|
||||
entity: { uid: cluster.id },
|
||||
params: {}
|
||||
});
|
||||
});
|
||||
|
||||
30
src/migrations/hotbar-store/5.0.0-beta.4.ts
Normal file
30
src/migrations/hotbar-store/5.0.0-beta.4.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { Hotbar } from "../../common/hotbar-store";
|
||||
import { migration } from "../migration-wrapper";
|
||||
import { catalogEntityRegistry } from "../../renderer/api/catalog-entity-registry";
|
||||
|
||||
export default migration({
|
||||
version: "5.0.0-beta.4",
|
||||
run(store) {
|
||||
const hotbars: Hotbar[] = store.get("hotbars");
|
||||
|
||||
hotbars.forEach((hotbar, hotbarIndex) => {
|
||||
hotbar.items.forEach((item, itemIndex) => {
|
||||
const entity = catalogEntityRegistry.items.find((entity) => entity.metadata.uid === item?.entity.uid);
|
||||
|
||||
if (!entity) {
|
||||
// Clear disabled item
|
||||
hotbars[hotbarIndex].items[itemIndex] = null;
|
||||
} else {
|
||||
// Save additional data
|
||||
hotbars[hotbarIndex].items[itemIndex].entity = {
|
||||
...item.entity,
|
||||
name: entity.metadata.name,
|
||||
source: entity.metadata.source
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
store.set("hotbars", hotbars);
|
||||
}
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user