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, "verboseLogs": false,
"autoDownloadPlaylist": true, "autoDownloadPlaylist": true,
"customCodec": "h264", "customCodec": "h264",
"logSystem": true, "logSystem": true,
"outputTitleCheck": true, "outputTitleCheck": true,
"downloadSystem": true, "downloadSystem": true,

51
main.js
View File

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