From c0dbd5878d3114639aa1ce506a1f5d68c32a6d28 Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Mon, 28 Jun 2021 18:28:54 +0300 Subject: [PATCH] Filtering out clusters by metadata.id (#3200) Signed-off-by: Alex Andreev --- src/migrations/hotbar-store/5.0.0-beta.10.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/migrations/hotbar-store/5.0.0-beta.10.ts b/src/migrations/hotbar-store/5.0.0-beta.10.ts index 34c3aa34f9..41b4aeb081 100644 --- a/src/migrations/hotbar-store/5.0.0-beta.10.ts +++ b/src/migrations/hotbar-store/5.0.0-beta.10.ts @@ -21,7 +21,7 @@ import { app } from "electron"; import fse from "fs-extra"; -import { isNull } from "lodash"; +import { isNull, uniqBy } from "lodash"; import path from "path"; import * as uuid from "uuid"; import type { ClusterStoreModel } from "../../common/cluster-store"; @@ -47,6 +47,7 @@ export default { const workspaceStoreData: Pre500WorkspaceStoreModel = fse.readJsonSync(path.join(userDataPath, "lens-workspace-store.json")); const { clusters }: ClusterStoreModel = fse.readJSONSync(path.join(userDataPath, "lens-cluster-store.json")); const workspaceHotbars = new Map(); // mapping from WorkspaceId to HotBar + const uniqueClusters = uniqBy(clusters, "metadata.id"); // Filtering out duplicated clusters for (const { id, name } of workspaceStoreData.workspaces) { workspaceHotbars.set(id, { @@ -68,7 +69,7 @@ export default { }); } - for (const cluster of clusters) { + for (const cluster of uniqueClusters) { const workspaceHotbar = workspaceHotbars.get(cluster.workspace); if (workspaceHotbar?.items.length < defaultHotbarCells) {