From f084b721ecf28b76c1d922320cc0e2b4c1771c56 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Wed, 11 Nov 2020 19:38:56 +0200 Subject: [PATCH] revert navigation changes Signed-off-by: Jari Kolehmainen --- src/renderer/navigation.ts | 40 +++++++++++++------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/src/renderer/navigation.ts b/src/renderer/navigation.ts index 83d2579a2a..f0d37ac097 100644 --- a/src/renderer/navigation.ts +++ b/src/renderer/navigation.ts @@ -3,24 +3,13 @@ import { ipcRenderer } from "electron"; import { matchPath } from "react-router"; import { reaction } from "mobx"; -import { createObservableHistory, IObservableHistory } from "mobx-observable-history"; -import { createBrowserHistory, createMemoryHistory, LocationDescriptor, History } from "history"; +import { createObservableHistory } from "mobx-observable-history"; +import { createBrowserHistory, createMemoryHistory, LocationDescriptor } from "history"; import logger from "../main/logger"; import { clusterViewRoute, IClusterViewRouteParams } from "./components/cluster-manager/cluster-view.route"; -let history: History -let navigation: IObservableHistory - -if (ipcRenderer) { - history = typeof window !== "undefined" ? createBrowserHistory() : createMemoryHistory(); - navigation = createObservableHistory(history); -} - -export { - history, - navigation -} - +export const history = typeof window !== "undefined" ? createBrowserHistory() : createMemoryHistory(); +export const navigation = createObservableHistory(history); export function navigate(location: LocationDescriptor) { const currentLocation = navigation.getPath(); @@ -116,15 +105,14 @@ if (process.isMainFrame) { fireImmediately: true }) } -if (ipcRenderer) { - // Handle navigation via IPC (e.g. from top menu) - ipcRenderer.on("menu:navigate", (event, location: LocationDescriptor) => { - logger.info(`[IPC]: ${event.type} ${JSON.stringify(location)}`, event); - navigate(location); - }); - // Reload dashboard window - ipcRenderer.on("menu:reload", () => { - location.reload(); - }); -} +// Handle navigation via IPC (e.g. from top menu) +ipcRenderer.on("menu:navigate", (event, location: LocationDescriptor) => { + logger.info(`[IPC]: ${event.type} ${JSON.stringify(location)}`, event); + navigate(location); +}); + +// Reload dashboard window +ipcRenderer.on("menu:reload", () => { + location.reload(); +});