mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Rename interface for honesty
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
parent
077b2089b3
commit
8a8a188dc3
@ -9,7 +9,7 @@ import { BrowserWindow } from "electron";
|
||||
import { openBrowser } from "../../../../common/utils";
|
||||
import type { SendToViewArgs } from "./lens-window-injection-token";
|
||||
import sendToChannelInElectronBrowserWindowInjectable from "./send-to-channel-in-electron-browser-window.injectable";
|
||||
import type { LensWindow } from "./create-lens-window.injectable";
|
||||
import type { ElectronWindow } from "./create-lens-window.injectable";
|
||||
|
||||
export type ElectronWindowTitleBarStyle = "hiddenInset" | "hidden" | "default" | "customButtonsOnHover";
|
||||
|
||||
@ -30,7 +30,7 @@ export interface ElectronWindowConfiguration {
|
||||
onDomReady?: () => void;
|
||||
}
|
||||
|
||||
export type CreateElectronWindow = () => Promise<LensWindow>;
|
||||
export type CreateElectronWindow = () => Promise<ElectronWindow>;
|
||||
export type CreateElectronWindowFor = (config: ElectronWindowConfiguration) => CreateElectronWindow;
|
||||
|
||||
const createElectronWindowFor = getInjectable({
|
||||
|
||||
@ -3,11 +3,11 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { SendToViewArgs } from "./lens-window-injection-token";
|
||||
import type { LensWindow, SendToViewArgs } from "./lens-window-injection-token";
|
||||
import type { ElectronWindowTitleBarStyle } from "./create-electron-window-for.injectable";
|
||||
import createElectronWindowForInjectable from "./create-electron-window-for.injectable";
|
||||
|
||||
export interface LensWindow {
|
||||
export interface ElectronWindow {
|
||||
show: () => void;
|
||||
close: () => void;
|
||||
send: (args: SendToViewArgs) => void;
|
||||
@ -35,13 +35,14 @@ const createLensWindowInjectable = getInjectable({
|
||||
instantiate: (di) => {
|
||||
const createElectronWindowFor = di.inject(createElectronWindowForInjectable);
|
||||
|
||||
return (configuration: LensWindowConfiguration) => {
|
||||
let browserWindow: LensWindow | undefined;
|
||||
return (configuration: LensWindowConfiguration): LensWindow => {
|
||||
let browserWindow: ElectronWindow | undefined;
|
||||
|
||||
const createElectronWindow = createElectronWindowFor(Object.assign(
|
||||
{
|
||||
onClose: () => browserWindow = undefined,
|
||||
},
|
||||
|
||||
configuration,
|
||||
));
|
||||
|
||||
@ -49,6 +50,7 @@ const createLensWindowInjectable = getInjectable({
|
||||
get visible() {
|
||||
return !!browserWindow;
|
||||
},
|
||||
|
||||
show: async () => {
|
||||
if (!browserWindow) {
|
||||
browserWindow = await createElectronWindow();
|
||||
@ -56,10 +58,12 @@ const createLensWindowInjectable = getInjectable({
|
||||
|
||||
browserWindow.show();
|
||||
},
|
||||
|
||||
close: () => {
|
||||
browserWindow?.close();
|
||||
browserWindow = undefined;
|
||||
},
|
||||
|
||||
send: (args: SendToViewArgs) => {
|
||||
if (!browserWindow) {
|
||||
throw new Error(`Tried to send message to window "${configuration.id}" but the window was closed`);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user