mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-09-27 20:11:15 +02:00
fix(tray): dynamically create/destroy tray icon on setting toggle
Previously, toggling the system tray in the settings updated the configuration but did not instantiate or destroy the tray immediately. This caused a desynchronization bug where the application could minimize to a non-existent tray, creating a ghost instance. The `set-feature` IPC handler now intercepts the `systemTray` key to apply the state at runtime before persisting the config.
This commit is contained in:
@@ -18,6 +18,7 @@ const { getThemes, reloadThemes } = require("./themeManager");
|
|||||||
const config = require("../config");
|
const config = require("../config");
|
||||||
const { validateDownloadPath, getDefaultDownloadPath } = require("./pathValidator");
|
const { validateDownloadPath, getDefaultDownloadPath } = require("./pathValidator");
|
||||||
const { userThemesPath } = require("../server/helpers/path.helpers");
|
const { userThemesPath } = require("../server/helpers/path.helpers");
|
||||||
|
const { createSystemTray, destroyTray } = require("./tray");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Security whitelist for feature flags that can be modified at runtime.
|
* Security whitelist for feature flags that can be modified at runtime.
|
||||||
@@ -214,6 +215,21 @@ function registerIpcHandlers(getMainWindow) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynamically intercepts and applies System Tray state changes at runtime.
|
||||||
|
* Instantiates or destroys the tray icon immediately to prevent window
|
||||||
|
* lifecycle desynchronization (e.g., minimizing a window to a non-existent tray).
|
||||||
|
*/
|
||||||
|
if (key === "systemTray") {
|
||||||
|
if (value === true) {
|
||||||
|
logger.info("System Tray enabled dynamically.");
|
||||||
|
createSystemTray(getMainWindow(), config.devMode);
|
||||||
|
} else {
|
||||||
|
logger.info("System Tray disabled dynamically.");
|
||||||
|
destroyTray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
configFeatures[key] = value;
|
configFeatures[key] = value;
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
|
|||||||
Reference in New Issue
Block a user