diff --git a/src/app/config-handler.ts b/src/app/config-handler.ts index 5c933372..17605793 100644 --- a/src/app/config-handler.ts +++ b/src/app/config-handler.ts @@ -39,7 +39,7 @@ export interface IConfig { permissions: IPermission; customFlags: ICustomFlag; crashReporter: ICrashReporter; - mainWinPos: ICustomRectangle; + mainWinPos?: ICustomRectangle; } export interface IPermission { @@ -69,7 +69,7 @@ export interface INotificationSetting { display: string; } -export interface ICustomRectangle extends Electron.Rectangle { +export interface ICustomRectangle extends Partial { isMaximized: boolean; isFullScreen: boolean; } diff --git a/src/app/window-handler.ts b/src/app/window-handler.ts index 84beda2b..5617cb2e 100644 --- a/src/app/window-handler.ts +++ b/src/app/window-handler.ts @@ -232,7 +232,7 @@ export class WindowHandler { ...this.windowOpts, ...getBounds(this.config.mainWinPos, DEFAULT_WIDTH, DEFAULT_HEIGHT), }) as ICustomBrowserWindow; this.mainWindow.winName = apiName.mainWindowName; - const { isFullScreen, isMaximized } = this.config.mainWinPos; + const { isFullScreen, isMaximized } = this.config.mainWinPos ? this.config.mainWinPos : { isFullScreen: false, isMaximized: false }; if (isMaximized) { this.mainWindow.maximize(); } diff --git a/src/app/window-utils.ts b/src/app/window-utils.ts index 2d8d2504..1def86a2 100644 --- a/src/app/window-utils.ts +++ b/src/app/window-utils.ts @@ -11,7 +11,7 @@ import { i18n, LocaleType } from '../common/i18n'; import { logger } from '../common/logger'; import { getGuid } from '../common/utils'; import { whitelistHandler } from '../common/whitelist-handler'; -import { config } from './config-handler'; +import { config, ICustomRectangle } from './config-handler'; import { screenSnippet } from './screen-snippet-handler'; import { ICustomBrowserWindow, windowHandler } from './window-handler'; @@ -286,8 +286,8 @@ export const sanitize = async (windowName: string): Promise => { * @param defaultHeight * @return {x?: Number, y?: Number, width: Number, height: Number} */ -export const getBounds = (winPos: Electron.Rectangle, defaultWidth: number, defaultHeight: number): Partial => { - if (!winPos) { +export const getBounds = (winPos: ICustomRectangle | Electron.Rectangle | undefined, defaultWidth: number, defaultHeight: number): Partial => { + if (!winPos || !winPos.x || !winPos.y || !winPos.width || !winPos.height) { return { width: defaultWidth, height: defaultHeight }; } const displays = electron.screen.getAllDisplays();