mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Replace last use of customRequestPromise with di
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
3c9791e81e
commit
c3402562a1
20 files changed
+130
-136
No files matched your search
@@ -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) => {
|
||||
|
||||
+1
-25
@@ -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);
|
||||
}
|
||||
+20
-4
@@ -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<void>;
|
||||
loadUrl: (url: string) => Promise<void>;
|
||||
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;
|
||||
|
||||
|
||||
+5
-20
@@ -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<void>;
|
||||
loadUrl: (url: string) => Promise<void>;
|
||||
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;
|
||||
|
||||
Reference in new issue
Block a user