Fix: Config not working propely

This commit is contained in:
MasterAcnolo
2026-01-21 11:08:42 +01:00
parent cd8eb05020
commit 967144bd55
2 changed files with 39 additions and 14 deletions

View File

@@ -8,8 +8,6 @@
"verboseLogs": false,
"autoDownloadPlaylist": true,
"customCodec": "h264",
"logSystem": true,
"outputTitleCheck": true,
"downloadSystem": true,

33
main.js
View File

@@ -205,22 +205,49 @@ app.whenReady().then(async () => {
return configFeatures;
});
const featureWhitelist = new Set([
"autoUpdate",
"discordRPC",
"customTopBar",
"autoCheckInfo",
"addThumbnail",
"addMetadata",
"verboseLogs",
"autoDownloadPlaylist",
"customCodec"
]);
ipcMain.handle("set-feature", (event, { key, value }) => {
try {
// update mémoire
if (!featureWhitelist.has(key)) {
logger.warn(`Rejected feature (not whitelisted): ${key}`);
return false;
}
// optionnel mais propre
if (configFeatures[key] === value) {
return true;
}
configFeatures[key] = value;
// écriture directe sur le JSON
fs.writeFileSync(configFolderPath, JSON.stringify(configFeatures, null, 2), "utf-8");
fs.writeFileSync(
configFolderPath,
JSON.stringify(configFeatures, null, 2),
"utf-8"
);
logger.info(`Feature updated: ${key} = ${value}`);
return true;
} catch (err) {
logger.error(`set-feature failed (${key}): ${err.message}`);
return false;
}
});
configFeatures.discordRPC ? startRPC() : "";
await createMainWindow();