change state to store display id only

This commit is contained in:
MrGarlic 2024-05-10 14:37:30 -04:00
parent 7dcf6a153c
commit 5083019fd0
2 changed files with 6 additions and 4 deletions

View file

@ -270,7 +270,9 @@ function getWindowBoundsOptions(): BrowserWindowConstructorOptions {
height: height ?? DEFAULT_HEIGHT height: height ?? DEFAULT_HEIGHT
} as BrowserWindowConstructorOptions; } as BrowserWindowConstructorOptions;
if (x != null && y != null && State.store.display && screen.getAllDisplays().includes(State.store.display)) { const storedDisplay = screen.getAllDisplays().find(display => display.id === State.store.displayid);
if (x != null && y != null && storedDisplay) {
options.x = x; options.x = x;
options.y = y; options.y = y;
} }
@ -318,7 +320,7 @@ function initWindowBoundsListeners(win: BrowserWindow) {
const saveBounds = () => { const saveBounds = () => {
State.store.windowBounds = win.getBounds(); State.store.windowBounds = win.getBounds();
State.store.display = screen.getDisplayMatching(State.store.windowBounds); State.store.displayid = screen.getDisplayMatching(State.store.windowBounds).id;
}; };
win.on("resize", saveBounds); win.on("resize", saveBounds);

View file

@ -4,7 +4,7 @@
* Copyright (c) 2023 Vendicated and Vencord contributors * Copyright (c) 2023 Vendicated and Vencord contributors
*/ */
import type { Display, Rectangle } from "electron"; import type { Rectangle } from "electron";
export interface Settings { export interface Settings {
discordBranch?: "stable" | "canary" | "ptb"; discordBranch?: "stable" | "canary" | "ptb";
@ -36,7 +36,7 @@ export interface State {
maximized?: boolean; maximized?: boolean;
minimized?: boolean; minimized?: boolean;
windowBounds?: Rectangle; windowBounds?: Rectangle;
display?: Display; displayid: int;
skippedUpdate?: string; skippedUpdate?: string;
firstLaunch?: boolean; firstLaunch?: boolean;