Remove ClusterStore.removedClusters and correctly delete lens storage file (#4077)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-10-20 08:51:26 -04:00
1 parent b4a4cc6be4
commit 32562b11a4
5 files changed
+19 -40

No files matched your search

@@ -116,6 +116,7 @@ export class DeleteClusterDialog extends React.Component {
await requestMain(clusterDeleteHandler, cluster.id);
} catch(error) {
Notifications.error(`Cannot remove cluster, failed to process config file. ${error}`);
} finally {
await requestMain(clusterClearDeletingHandler, cluster.id);
}
-11
View File
@@ -25,7 +25,6 @@ import path from "path";
import { comparer, observable, reaction, toJS, when } from "mobx";
import fse from "fs-extra";
import { StorageHelper } from "./storageHelper";
import { ClusterStore } from "../../common/cluster-store";
import logger from "../../main/logger";
import { getHostedClusterId, getPath } from "../../common/utils";
import { isTestEnv } from "../../common/vars";
@@ -75,11 +74,6 @@ export function createAppStorage<T>(key: string, defaultValue: T, clusterId?: st
equals: comparer.structural, // save only when something really changed
});
// remove json-file when cluster deleted
if (clusterId !== undefined) {
when(() => ClusterStore.getInstance(false)?.removedClusters.has(clusterId)).then(removeFile);
}
async function saveFile(state: Record<string, any> = {}) {
logger.info(`${logPrefix} saving ${filePath}`);
@@ -92,11 +86,6 @@ export function createAppStorage<T>(key: string, defaultValue: T, clusterId?: st
});
}
}
function removeFile() {
logger.debug(`${logPrefix} removing ${filePath}`);
fse.unlink(filePath).catch(Function);
}
}
return new StorageHelper<T>(key, {