mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-09-27 20:11:15 +02:00
refactor: systemTray window logic. Window reference is now dynamic and guarded against destroyed states. Minimize can now put window in the systemTray if option is active
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
const { ipcMain, dialog, shell } = require("electron");
|
||||
const fs = require("fs");
|
||||
const { logger, logDir } = require("../server/logger");
|
||||
const { configFeatures, featuresPath } = require("../config");
|
||||
const {configFeatures, featuresPath, devMode} = require("../config");
|
||||
const { getThemes, reloadThemes } = require("./themeManager");
|
||||
const config = require("../config");
|
||||
const { validateDownloadPath, getDefaultDownloadPath } = require("./pathValidator");
|
||||
@@ -114,7 +114,16 @@ function registerIpcHandlers(getMainWindow) {
|
||||
/**
|
||||
* Window minimize request from renderer.
|
||||
*/
|
||||
ipcMain.on("window-minimize", () => getMainWindow()?.minimize());
|
||||
ipcMain.on("window-minimize", () => {
|
||||
// Minimize to tray
|
||||
if (configFeatures.systemTray) {
|
||||
getMainWindow()?.hide()
|
||||
} else {
|
||||
// Native minimize
|
||||
getMainWindow()?.minimize()
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Toggles maximize/unmaximize state of main window.
|
||||
@@ -223,7 +232,7 @@ function registerIpcHandlers(getMainWindow) {
|
||||
if (key === "systemTray") {
|
||||
if (value === true) {
|
||||
logger.info("System Tray enabled dynamically.");
|
||||
createSystemTray(getMainWindow(), config.devMode);
|
||||
createSystemTray(devMode);
|
||||
} else {
|
||||
logger.info("System Tray disabled dynamically.");
|
||||
destroyTray();
|
||||
|
||||
Reference in New Issue
Block a user