diff --git a/src/common/ipc/window.ts b/src/common/ipc/window.ts index 23a83177c6..f314f3cc42 100644 --- a/src/common/ipc/window.ts +++ b/src/common/ipc/window.ts @@ -5,7 +5,6 @@ export const windowActionHandleChannel = "window:window-action"; export const windowOpenAppMenuAsContextMenuChannel = "window:open-app-context-menu"; -export const windowLocationChangedChannel = "window:location-changed"; /** * The supported actions on the current window. The argument for `windowActionHandleChannel` diff --git a/src/common/utils/sync-box/sync-box-injection-token.ts b/src/common/utils/sync-box/sync-box-injection-token.ts index 8db80243d3..f8be98fc6a 100644 --- a/src/common/utils/sync-box/sync-box-injection-token.ts +++ b/src/common/utils/sync-box/sync-box-injection-token.ts @@ -5,8 +5,8 @@ import { getInjectionToken } from "@ogre-tools/injectable"; import type { IComputedValue } from "mobx"; export interface SyncBox { - id: string; - value: IComputedValue; + readonly id: string; + readonly value: IComputedValue; set: (value: Value) => void; } diff --git a/src/features/helm-charts/listing-active-helm-repositories-in-preferences.test.ts b/src/features/helm-charts/listing-active-helm-repositories-in-preferences.test.ts index 5158a18c48..0ec76cea1c 100644 --- a/src/features/helm-charts/listing-active-helm-repositories-in-preferences.test.ts +++ b/src/features/helm-charts/listing-active-helm-repositories-in-preferences.test.ts @@ -43,7 +43,7 @@ describe("listing active helm repositories in preferences", () => { builder.beforeApplicationStart((mainDi) => { mainDi.override(readYamlFileInjectable, () => readYamlFileMock); - mainDi.override(execFileInjectable, () => execFileMock); + mainDi.override(exrequestPublicHelmRepositoriesInjectable mainDi.override(helmBinaryPathInjectable, () => "some-helm-binary-path"); mainDi.override(loggerInjectable, () => loggerStub); }); diff --git a/src/features/preferences/navigation-to-kubernetes-preferences.test.ts b/src/features/preferences/navigation-to-kubernetes-preferences.test.ts index d02bc80532..6035f923dc 100644 --- a/src/features/preferences/navigation-to-kubernetes-preferences.test.ts +++ b/src/features/preferences/navigation-to-kubernetes-preferences.test.ts @@ -30,7 +30,7 @@ describe("preferences - navigation to kubernetes preferences", () => { mainDi.override( getActiveHelmRepositoriesInjectable, () => async () => ({ callWasSuccessful: true, response: [] }), - ); + );requestPublicHelmRepositoriesInjectable; }); builder.beforeWindowStart((windowDi) => { diff --git a/src/features/top-bar/common/state.injectable.ts b/src/features/top-bar/common/state.injectable.ts new file mode 100644 index 0000000000..51a5e6b274 --- /dev/null +++ b/src/features/top-bar/common/state.injectable.ts @@ -0,0 +1,27 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import { getInjectable } from "@ogre-tools/injectable"; +import createSyncBoxInjectable from "../../../common/utils/sync-box/create-sync-box.injectable"; +import { syncBoxInjectionToken } from "../../../common/utils/sync-box/sync-box-injection-token"; + +export interface TopBarState { + prevEnabled: boolean; + nextEnabled: boolean; +} + +const topBarStateInjectable = getInjectable({ + id: "top-bar-state", + instantiate: (di) => { + const createSyncBox = di.inject(createSyncBoxInjectable); + + return createSyncBox("top-bar-state", { + prevEnabled: false, + nextEnabled: false, + }); + }, + injectionToken: syncBoxInjectionToken, +}); + +export default topBarStateInjectable; diff --git a/src/features/window-location/common/channel.ts b/src/features/window-location/common/channel.ts new file mode 100644 index 0000000000..2ae9e4669c --- /dev/null +++ b/src/features/window-location/common/channel.ts @@ -0,0 +1,11 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import type { MessageChannel } from "../../../common/utils/channel/message-channel-listener-injection-token"; +import type { Location } from "history"; + +export const windowLocationChangedChannel: MessageChannel = { + id: "window-location-changed", +}; diff --git a/src/features/window-location/main/for-top-bar-state-handler.injectable.ts b/src/features/window-location/main/for-top-bar-state-handler.injectable.ts new file mode 100644 index 0000000000..8d8701ece8 --- /dev/null +++ b/src/features/window-location/main/for-top-bar-state-handler.injectable.ts @@ -0,0 +1,28 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import { getMessageChannelListenerInjectable } from "../../../common/utils/channel/message-channel-listener-injection-token"; +import getVisibleWindowsInjectable from "../../../main/start-main-application/lens-window/get-visible-windows.injectable"; +import topBarStateInjectable from "../../top-bar/common/state.injectable"; +import { windowLocationChangedChannel } from "../common/channel"; + +const windowLocationHasChangedForTopBarStateHandlerInjectable = getMessageChannelListenerInjectable({ + id: "for-top-bar-state", + channel: windowLocationChangedChannel, + handler: (di) => { + const getVisibleWindows = di.inject(getVisibleWindowsInjectable); + const topBarState = di.inject(topBarStateInjectable); + + return () => { + const windows = getVisibleWindows(); + + topBarState.set({ + prevEnabled: windows.some(window => window.canGoBack()), + nextEnabled: windows.some(window => window.canGoForward()), + }); + }; + }, +}); + +export default windowLocationHasChangedForTopBarStateHandlerInjectable; diff --git a/src/features/window-location/renderer/emit.injectable.ts b/src/features/window-location/renderer/emit.injectable.ts new file mode 100644 index 0000000000..e9ce8a2c8d --- /dev/null +++ b/src/features/window-location/renderer/emit.injectable.ts @@ -0,0 +1,21 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import { getInjectable } from "@ogre-tools/injectable"; +import type { MessageChannelSender } from "../../../common/utils/channel/message-to-channel-injection-token"; +import { sendMessageToChannelInjectionToken } from "../../../common/utils/channel/message-to-channel-injection-token"; +import { windowLocationChangedChannel } from "../common/channel"; + +export type EmitWindowLocationChanged = MessageChannelSender; + +const emitWindowLocationChangedInjectable = getInjectable({ + id: "emit-window-location-changed", + instantiate: (di): EmitWindowLocationChanged => { + const sendMessageToChannel = di.inject(sendMessageToChannelInjectionToken); + + return (location) => sendMessageToChannel(windowLocationChangedChannel, location); + }, +}); + +export default emitWindowLocationChangedInjectable; diff --git a/src/main/electron-app/runnables/setup-ipc-main-handlers/setup-ipc-main-handlers.ts b/src/main/electron-app/runnables/setup-ipc-main-handlers/setup-ipc-main-handlers.ts index 4ae020c42d..909409c7eb 100644 --- a/src/main/electron-app/runnables/setup-ipc-main-handlers/setup-ipc-main-handlers.ts +++ b/src/main/electron-app/runnables/setup-ipc-main-handlers/setup-ipc-main-handlers.ts @@ -10,8 +10,8 @@ import type { ClusterId } from "../../../../common/cluster-types"; import type { ClusterStore } from "../../../../common/cluster-store/cluster-store"; import { broadcastMainChannel, broadcastMessage, ipcMainHandle, ipcMainOn } from "../../../../common/ipc"; import type { IComputedValue } from "mobx"; -import { windowActionHandleChannel, windowLocationChangedChannel, windowOpenAppMenuAsContextMenuChannel } from "../../../../common/ipc/window"; -import { handleWindowAction, onLocationChange } from "../../../ipc/window"; +import { windowActionHandleChannel, windowOpenAppMenuAsContextMenuChannel } from "../../../../common/ipc/window"; +import { handleWindowAction } from "../../../ipc/window"; import type { ApplicationMenuItemTypes } from "../../../../features/application-menu/main/menu-items/application-menu-item-injection-token"; import type { Composite } from "../../../../common/utils/composite/get-composite/get-composite"; import { getApplicationMenuTemplate } from "../../../../features/application-menu/main/populate-application-menu.injectable"; @@ -59,8 +59,6 @@ export const setupIpcMainHandlers = ({ ipcMainHandle(windowActionHandleChannel, (event, action) => handleWindowAction(action)); - ipcMainOn(windowLocationChangedChannel, () => onLocationChange()); - ipcMainHandle(broadcastMainChannel, (event, channel, ...args) => broadcastMessage(channel, ...args)); ipcMainOn(windowOpenAppMenuAsContextMenuChannel, async (event) => { diff --git a/src/main/ipc/window.ts b/src/main/ipc/window.ts index b111eab243..b1b1b9dbef 100644 --- a/src/main/ipc/window.ts +++ b/src/main/ipc/window.ts @@ -3,8 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ -import { BrowserWindow, webContents } from "electron"; -import { broadcastMessage } from "../../common/ipc"; +import { BrowserWindow } from "electron"; import { WindowAction } from "../../common/ipc/window"; export function handleWindowAction(action: WindowAction) { @@ -46,26 +45,3 @@ export function handleWindowAction(action: WindowAction) { throw new Error(`Attemped window action ${action} is unknown`); } } - -export function onLocationChange(): void { - const getAllWebContents = webContents.getAllWebContents(); - - const canGoBack = getAllWebContents.some((webContent) => { - if (webContent.getType() === "window") { - return webContent.canGoBack(); - } - - return false; - }); - - const canGoForward = getAllWebContents.some((webContent) => { - if (webContent.getType() === "window") { - return webContent.canGoForward(); - } - - return false; - }); - - broadcastMessage("history:can-go-back", canGoBack); - broadcastMessage("history:can-go-forward", canGoForward); -} diff --git a/src/main/start-main-application/lens-window/application-window/create-electron-window.injectable.ts b/src/main/start-main-application/lens-window/application-window/create-electron-window.injectable.ts index bd84909a49..a77eb3fb6c 100644 --- a/src/main/start-main-application/lens-window/application-window/create-electron-window.injectable.ts +++ b/src/main/start-main-application/lens-window/application-window/create-electron-window.injectable.ts @@ -7,7 +7,6 @@ import { timingSafeEqual, X509Certificate } from "crypto"; import loggerInjectable from "../../../../common/logger.injectable"; import applicationWindowStateInjectable from "./application-window-state.injectable"; import { BrowserWindow } from "electron"; -import type { ElectronWindow } from "./create-lens-window.injectable"; import type { RequireExactlyOne } from "type-fest"; import openLinkInBrowserInjectable from "../../../../common/utils/open-link-in-browser.injectable"; import getAbsolutePathInjectable from "../../../../common/path/get-absolute-path.injectable"; @@ -16,6 +15,24 @@ import isLinuxInjectable from "../../../../common/vars/is-linux.injectable"; import applicationInformationToken from "../../../../common/vars/application-information-token"; import pathExistsSyncInjectable from "../../../../common/fs/path-exists-sync.injectable"; import lensProxyCertificateInjectable from "../../../../common/certificate/lens-proxy-certificate.injectable"; +import type { ClusterFrameInfo } from "../../../../common/cluster-frames"; + +export interface SendToViewArgs { + channel: string; + frameInfo?: ClusterFrameInfo; + data?: unknown; +} + +export interface ElectronWindow { + show: () => void; + close: () => void; + send: (args: SendToViewArgs) => void; + loadFile: (filePath: string) => Promise; + loadUrl: (url: string) => Promise; + reload: () => void; + canGoBack: () => boolean; + canGoForward: () => boolean; +} export type ElectronWindowTitleBarStyle = "hiddenInset" | "hidden" | "default" | "customButtonsOnHover"; @@ -165,7 +182,6 @@ const createElectronWindowInjectable = getInjectable({ await browserWindow.loadFile(filePath); }, - loadUrl: async (url) => { logger.info( `[CREATE-ELECTRON-WINDOW]: Loading content for window "${configuration.id}" from url: ${url}...`, @@ -173,7 +189,8 @@ const createElectronWindowInjectable = getInjectable({ await browserWindow.loadURL(url); }, - + canGoBack: () => browserWindow.webContents.canGoBack(), + canGoForward: () => browserWindow.webContents.canGoForward(), show: () => browserWindow.show(), close: () => browserWindow.close(), send: ({ channel, data, frameInfo }) => { @@ -187,7 +204,6 @@ const createElectronWindowInjectable = getInjectable({ browserWindow.webContents.send(channel, data); } }, - reload: () => { const wc = browserWindow.webContents; diff --git a/src/main/start-main-application/lens-window/application-window/create-lens-window.injectable.ts b/src/main/start-main-application/lens-window/application-window/create-lens-window.injectable.ts index d2d8f344eb..7c64748749 100644 --- a/src/main/start-main-application/lens-window/application-window/create-lens-window.injectable.ts +++ b/src/main/start-main-application/lens-window/application-window/create-lens-window.injectable.ts @@ -3,24 +3,8 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import type { ContentSource, ElectronWindowTitleBarStyle } from "./create-electron-window.injectable"; +import type { ContentSource, ElectronWindow, ElectronWindowTitleBarStyle, SendToViewArgs } from "./create-electron-window.injectable"; import createElectronWindowForInjectable from "./create-electron-window.injectable"; -import type { ClusterFrameInfo } from "../../../../common/cluster-frames"; - -export interface ElectronWindow { - show: () => void; - close: () => void; - send: (args: SendToViewArgs) => void; - loadFile: (filePath: string) => Promise; - loadUrl: (url: string) => Promise; - reload: () => void; -} - -export interface SendToViewArgs { - channel: string; - frameInfo?: ClusterFrameInfo; - data?: unknown; -} export interface LensWindow { id: string; @@ -31,6 +15,8 @@ export interface LensWindow { isVisible: boolean; isStarting: boolean; reload: () => void; + canGoBack: () => boolean; + canGoForward: () => boolean; } export interface LensWindowConfiguration { @@ -78,15 +64,14 @@ const createLensWindowInjectable = getInjectable({ return { id: configuration.id, - get isVisible() { return windowIsShown; }, - get isStarting() { return windowIsStarting; }, - + canGoBack: () => Boolean(browserWindow?.canGoBack()), + canGoForward: () => Boolean(browserWindow?.canGoForward()), start: async () => { if (!browserWindow) { windowIsStarting = true; diff --git a/src/renderer/components/layout/top-bar/start-state-sync.injectable.ts b/src/renderer/components/layout/top-bar/start-state-sync.injectable.ts deleted file mode 100644 index 92488851c5..0000000000 --- a/src/renderer/components/layout/top-bar/start-state-sync.injectable.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) OpenLens Authors. All rights reserved. - * Licensed under MIT License. See LICENSE in root directory for more information. - */ -import { getInjectable } from "@ogre-tools/injectable"; -import { action } from "mobx"; -import { beforeFrameStartsSecondInjectionToken } from "../../../before-frame-starts/tokens"; -import ipcRendererInjectable from "../../../utils/channel/ipc-renderer.injectable"; -import topBarStateInjectable from "./state.injectable"; - -// TODO: replace with a SyncBox -const startTopbarStateSyncInjectable = getInjectable({ - id: "start-topbar-state-sync", - instantiate: (di) => ({ - id: "start-topbar-state-sync", - run: () => { - const state = di.inject(topBarStateInjectable); - const ipcRenderer = di.inject(ipcRendererInjectable); - - ipcRenderer.on("history:can-go-back", action((event, canGoBack: boolean) => { - state.prevEnabled = canGoBack; - })); - - ipcRenderer.on("history:can-go-forward", action((event, canGoForward: boolean) => { - state.nextEnabled = canGoForward; - })); - }, - }), - injectionToken: beforeFrameStartsSecondInjectionToken, - causesSideEffects: true, -}); - -export default startTopbarStateSyncInjectable; diff --git a/src/renderer/components/layout/top-bar/state.injectable.ts b/src/renderer/components/layout/top-bar/state.injectable.ts deleted file mode 100644 index afc826a607..0000000000 --- a/src/renderer/components/layout/top-bar/state.injectable.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) OpenLens Authors. All rights reserved. - * Licensed under MIT License. See LICENSE in root directory for more information. - */ -import { getInjectable } from "@ogre-tools/injectable"; -import { observable } from "mobx"; - -const topBarStateInjectable = getInjectable({ - id: "top-bar-state", - instantiate: () => observable.object({ - prevEnabled: false, - nextEnabled: false, - }), -}); - -export default topBarStateInjectable; diff --git a/src/renderer/components/layout/top-bar/top-bar-items/navigation-to-back/prev-enabled.injectable.ts b/src/renderer/components/layout/top-bar/top-bar-items/navigation-to-back/prev-enabled.injectable.ts index 56012ffd13..934b0de7f7 100644 --- a/src/renderer/components/layout/top-bar/top-bar-items/navigation-to-back/prev-enabled.injectable.ts +++ b/src/renderer/components/layout/top-bar/top-bar-items/navigation-to-back/prev-enabled.injectable.ts @@ -4,14 +4,14 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import topBarStateInjectable from "../../state.injectable"; +import topBarStateInjectable from "../../../../../../features/top-bar/common/state.injectable"; const topBarPrevEnabledInjectable = getInjectable({ id: "top-bar-prev-enabled", instantiate: (di) => { const state = di.inject(topBarStateInjectable); - return computed(() => state.prevEnabled); + return computed(() => state.value.get().prevEnabled); }, }); diff --git a/src/renderer/components/layout/top-bar/top-bar-items/navigation-to-forward/next-enabled.injectable.ts b/src/renderer/components/layout/top-bar/top-bar-items/navigation-to-forward/next-enabled.injectable.ts index 496c7de6d0..bc8527823f 100644 --- a/src/renderer/components/layout/top-bar/top-bar-items/navigation-to-forward/next-enabled.injectable.ts +++ b/src/renderer/components/layout/top-bar/top-bar-items/navigation-to-forward/next-enabled.injectable.ts @@ -4,14 +4,14 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import topBarStateInjectable from "../../state.injectable"; +import topBarStateInjectable from "../../../../../../features/top-bar/common/state.injectable"; const topBarNextEnabledInjectable = getInjectable({ id: "top-bar-next-enabled", instantiate: (di) => { const state = di.inject(topBarStateInjectable); - return computed(() => state.nextEnabled); + return computed(() => state.value.get().nextEnabled); }, }); diff --git a/src/renderer/components/layout/top-bar/top-bar.test.tsx b/src/renderer/components/layout/top-bar/top-bar.test.tsx index 10a1ec11d4..f911ec615a 100644 --- a/src/renderer/components/layout/top-bar/top-bar.test.tsx +++ b/src/renderer/components/layout/top-bar/top-bar.test.tsx @@ -11,17 +11,17 @@ import { getDiForUnitTesting } from "../../../getDiForUnitTesting"; import type { DiContainer } from "@ogre-tools/injectable"; import type { DiRender } from "../../test-utils/renderFor"; import { renderFor } from "../../test-utils/renderFor"; -import { computed, observable } from "mobx"; +import { computed } from "mobx"; import rendererExtensionsInjectable from "../../../../extensions/renderer-extensions.injectable"; import closeWindowInjectable from "./top-bar-items/window-controls/close-window/close-window.injectable"; import goBackInjectable from "./top-bar-items/navigation-to-back/go-back/go-back.injectable"; import maximizeWindowInjectable from "./top-bar-items/window-controls/maximize-window/maximize-window.injectable"; import openAppContextMenuInjectable from "./top-bar-items/context-menu/open-app-context-menu/open-app-context-menu.injectable"; import toggleMaximizeWindowInjectable from "./toggle-maximize-window/toggle-maximize-window.injectable"; -import topBarStateInjectable from "./state.injectable"; import platformInjectable from "../../../../common/vars/platform.injectable"; import goForwardInjectable from "./top-bar-items/navigation-to-forward/go-forward/go-forward.injectable"; import currentlyInClusterFrameInjectable from "../../../routes/currently-in-cluster-frame.injectable"; +import topBarStateInjectable from "../../../../features/top-bar/common/state.injectable"; describe("", () => { let di: DiContainer; @@ -50,10 +50,10 @@ describe("", () => { describe("with both previous and next history enabled", () => { beforeEach(() => { - di.override(topBarStateInjectable, () => observable.object({ + di.inject(topBarStateInjectable).set({ prevEnabled: true, nextEnabled: true, - })); + }); }); it("renders w/o errors", () => { diff --git a/src/renderer/getDiForUnitTesting.tsx b/src/renderer/getDiForUnitTesting.tsx index 4691c0352f..2696d26d41 100644 --- a/src/renderer/getDiForUnitTesting.tsx +++ b/src/renderer/getDiForUnitTesting.tsx @@ -12,9 +12,7 @@ import { getOverrideFsWithFakes } from "../test-utils/override-fs-with-fakes"; import hostedClusterIdInjectable from "./cluster-frame-context/hosted-cluster-id.injectable"; import { runInAction } from "mobx"; import requestAnimationFrameInjectable from "./components/animate/request-animation-frame.injectable"; -import startTopbarStateSyncInjectable from "./components/layout/top-bar/start-state-sync.injectable"; import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx"; -import watchHistoryStateInjectable from "./remote-helpers/watch-history-state.injectable"; import legacyOnChannelListenInjectable from "./ipc/legacy-channel-listen.injectable"; import type { GlobalOverride } from "../common/test-utils/get-global-override"; import applicationInformationInjectable from "../common/vars/application-information-injectable"; @@ -60,21 +58,11 @@ export const getDiForUnitTesting = ( di.override(globalOverride.injectable, globalOverride.overridingInstantiate); } - [ - startTopbarStateSyncInjectable, - ].forEach((injectable) => { - di.override(injectable, () => ({ - id: injectable.id, - run: () => {}, - })); - }); - di.override(hostedClusterIdInjectable, () => undefined); di.override(legacyOnChannelListenInjectable, () => () => noop); di.override(requestAnimationFrameInjectable, () => (callback) => callback()); - di.override(watchHistoryStateInjectable, () => () => () => {}); di.override(requestFromChannelInjectable, () => () => Promise.resolve(undefined as never)); diff --git a/src/renderer/ipc/index.ts b/src/renderer/ipc/index.ts index 4bbf473515..04a727251e 100644 --- a/src/renderer/ipc/index.ts +++ b/src/renderer/ipc/index.ts @@ -5,12 +5,11 @@ import { clusterActivateHandler, clusterDisconnectHandler, clusterSetFrameIdHandler, clusterStates } from "../../common/ipc/cluster"; import type { ClusterId, ClusterState } from "../../common/cluster-types"; -import { windowActionHandleChannel, windowLocationChangedChannel, windowOpenAppMenuAsContextMenuChannel, type WindowAction } from "../../common/ipc/window"; +import { windowActionHandleChannel, windowOpenAppMenuAsContextMenuChannel, type WindowAction } from "../../common/ipc/window"; import { extensionDiscoveryStateChannel, extensionLoaderFromMainChannel } from "../../common/ipc/extension-handling"; import type { InstalledExtension } from "../../extensions/extension-discovery/extension-discovery"; import type { LensExtensionId } from "../../extensions/lens-extension"; import { toJS } from "../utils"; -import type { Location } from "history"; import { getLegacyGlobalDiForExtensionApi } from "../../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api"; import ipcRendererInjectable from "../utils/channel/ipc-renderer.injectable"; @@ -34,10 +33,6 @@ export function emitOpenAppMenuAsContextMenu(): void { emitToMain(windowOpenAppMenuAsContextMenuChannel); } -export function emitWindowLocationChanged(location: Location): void { - emitToMain(windowLocationChangedChannel, location); -} - export function requestWindowAction(type: WindowAction): Promise { return requestMain(windowActionHandleChannel, type); } diff --git a/src/renderer/remote-helpers/watch-history-state.injectable.ts b/src/renderer/remote-helpers/watch-history-state.injectable.ts index f878b7d20c..a0c1e981bd 100644 --- a/src/renderer/remote-helpers/watch-history-state.injectable.ts +++ b/src/renderer/remote-helpers/watch-history-state.injectable.ts @@ -4,23 +4,22 @@ */ import { getInjectable } from "@ogre-tools/injectable"; -import { emitWindowLocationChanged } from "../ipc"; import { reaction } from "mobx"; import observableHistoryInjectable from "../navigation/observable-history.injectable"; +import emitWindowLocationChangedInjectable from "../../features/window-location/renderer/emit.injectable"; const watchHistoryStateInjectable = getInjectable({ id: "watch-history-state", instantiate: (di) => { const observableHistory = di.inject(observableHistoryInjectable); + const emitWindowLocationChanged = di.inject(emitWindowLocationChangedInjectable); return () => reaction( () => observableHistory.location, emitWindowLocationChanged, ); }, - - causesSideEffects: true, }); export default watchHistoryStateInjectable;