mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
Merge pull request #562 from Araxeus/fix-window-position-save-spam
fix window position save spam
This commit is contained in:
25
index.js
25
index.js
@ -160,22 +160,39 @@ function createMainWindow() {
|
|||||||
win.on("closed", onClosed);
|
win.on("closed", onClosed);
|
||||||
|
|
||||||
win.on("move", () => {
|
win.on("move", () => {
|
||||||
|
if (win.isMaximized()) return;
|
||||||
let position = win.getPosition();
|
let position = win.getPosition();
|
||||||
config.set("window-position", { x: position[0], y: position[1] });
|
lateSave("window-position", { x: position[0], y: position[1] });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let winWasMaximized;
|
||||||
|
|
||||||
win.on("resize", () => {
|
win.on("resize", () => {
|
||||||
const windowSize = win.getSize();
|
const windowSize = win.getSize();
|
||||||
|
|
||||||
config.set("window-maximized", win.isMaximized());
|
const isMaximized = win.isMaximized();
|
||||||
if (!win.isMaximized()) {
|
if (winWasMaximized !== isMaximized) {
|
||||||
config.set("window-size", {
|
winWasMaximized = isMaximized;
|
||||||
|
config.set("window-maximized", isMaximized);
|
||||||
|
}
|
||||||
|
if (!isMaximized) {
|
||||||
|
lateSave("window-size", {
|
||||||
width: windowSize[0],
|
width: windowSize[0],
|
||||||
height: windowSize[1],
|
height: windowSize[1],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let savedTimeouts = {};
|
||||||
|
function lateSave(key, value) {
|
||||||
|
if (savedTimeouts[key]) clearTimeout(savedTimeouts[key]);
|
||||||
|
|
||||||
|
savedTimeouts[key] = setTimeout(() => {
|
||||||
|
config.set(key, value);
|
||||||
|
savedTimeouts[key] = undefined;
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
|
||||||
win.webContents.on("render-process-gone", (event, webContents, details) => {
|
win.webContents.on("render-process-gone", (event, webContents, details) => {
|
||||||
showUnresponsiveDialog(win, details);
|
showUnresponsiveDialog(win, details);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user