mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix watch leak on window unload (#3858)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
1 parent
d7746bb15f
commit
5b562836a4
3 files changed
+28
-13
No files matched your search
@@ -73,6 +73,7 @@ import { getHostedClusterId } from "../utils";
|
||||
import { ClusterStore } from "../../common/cluster-store";
|
||||
import type { ClusterId } from "../../common/cluster-types";
|
||||
import { watchHistoryState } from "../remote-helpers/history-updater";
|
||||
import { unmountComponentAtNode } from "react-dom";
|
||||
|
||||
@observer
|
||||
export class App extends React.Component {
|
||||
@@ -83,7 +84,7 @@ export class App extends React.Component {
|
||||
makeObservable(this);
|
||||
}
|
||||
|
||||
static async init() {
|
||||
static async init(rootElem: HTMLElement) {
|
||||
catalogEntityRegistry.init();
|
||||
const frameId = webFrame.routingId;
|
||||
|
||||
@@ -112,6 +113,20 @@ export class App extends React.Component {
|
||||
window.addEventListener("online", () => {
|
||||
window.location.reload();
|
||||
});
|
||||
|
||||
window.addEventListener("message", (ev: MessageEvent) => {
|
||||
if (ev.data === "teardown") {
|
||||
unmountComponentAtNode(rootElem);
|
||||
window.location.href = "about:blank";
|
||||
}
|
||||
});
|
||||
|
||||
window.onbeforeunload = () => {
|
||||
logger.info(`[APP]: Unload dashboard, clusterId=${App.clusterId}, frameId=${frameId}`);
|
||||
|
||||
unmountComponentAtNode(rootElem);
|
||||
};
|
||||
|
||||
whatInput.ask(); // Start to monitor user input device
|
||||
|
||||
// Setup hosted cluster context
|
||||
|
||||
Reference in new issue
Block a user