Cleanup iframe when cluster is disconnected (#2120)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen authored and GitHub committed 2021-02-11 17:36:47 +02:00
1 parent d7d4be7375
commit f14f3b3287
1 file changed
+9 -1
@@ -40,7 +40,15 @@ export async function initView(clusterId: ClusterId) {
}
export async function autoCleanOnRemove(clusterId: ClusterId, iframe: HTMLIFrameElement) {
await when(() => !clusterStore.getById(clusterId));
await when(() => {
const cluster = clusterStore.getById(clusterId);
if (!cluster) return true;
const view = lensViews.get(clusterId);
return cluster.disconnected && view?.isLoaded;
});
logger.info(`[LENS-VIEW]: remove dashboard, clusterId=${clusterId}`);
lensViews.delete(clusterId);