From 127bbc09087d621bc9d0218a7e1d382dbcd261f0 Mon Sep 17 00:00:00 2001 From: Jim Ehrismann Date: Thu, 10 Mar 2022 09:51:41 -0500 Subject: [PATCH] restore onbeforeunload behaviour, remove listener for online event Signed-off-by: Jim Ehrismann --- .../init-cluster-frame/init-cluster-frame.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/renderer/frames/cluster-frame/init-cluster-frame/init-cluster-frame.ts b/src/renderer/frames/cluster-frame/init-cluster-frame/init-cluster-frame.ts index 41c76527d7..4fe1081c02 100644 --- a/src/renderer/frames/cluster-frame/init-cluster-frame/init-cluster-frame.ts +++ b/src/renderer/frames/cluster-frame/init-cluster-frame/init-cluster-frame.ts @@ -10,9 +10,10 @@ import { Notifications } from "../../../components/notifications"; import type { AppEvent } from "../../../../common/app-event-bus/event-bus"; import type { CatalogEntity } from "../../../../common/catalog"; import { when } from "mobx"; +import { unmountComponentAtNode } from "react-dom"; import type { ClusterFrameContext } from "../../../cluster-frame-context/cluster-frame-context"; import { KubeObjectStore } from "../../../../common/k8s-api/kube-object.store"; -import { requestClusterDisconnection, requestSetClusterFrameId } from "../../../ipc"; +import { requestSetClusterFrameId } from "../../../ipc"; interface Dependencies { hostedCluster: Cluster; @@ -29,7 +30,7 @@ const logPrefix = "[CLUSTER-FRAME]:"; export const initClusterFrame = ({ hostedCluster, loadExtensions, catalogEntityRegistry, frameRoutingId, emitEvent, clusterFrameContext }: Dependencies) => - async () => { + async (rootElem: HTMLElement) => { // TODO: Make catalogEntityRegistry already initialized when passed as dependency catalogEntityRegistry.init(); @@ -74,16 +75,12 @@ export const initClusterFrame = }); }); - window.addEventListener("online", () => { - window.location.reload(); - }); - window.onbeforeunload = () => { logger.info( `${logPrefix} Unload dashboard, clusterId=${(hostedCluster.id)}, frameId=${frameRoutingId}`, ); - requestClusterDisconnection(hostedCluster.id); + unmountComponentAtNode(rootElem); }; // TODO: Make context dependency of KubeObjectStore