mirror of
https://gitlab.com/ryzen-controller-team/ryzen-controller.git
synced 2024-12-22 10:03:28 +07:00
fix: Ensure preset exist when applying.
This fix an issue where you could apply a preset on ac status change after deleting it.
This commit is contained in:
parent
1a7fd0098a
commit
2152f32b8f
23
js/preset.js
23
js/preset.js
@ -130,15 +130,32 @@ function preset_updateList() {
|
||||
presetTab.innerHTML = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will check if the preset exists.
|
||||
*
|
||||
* @param {String} name The preset name to look for.
|
||||
*/
|
||||
function preset_isExist(name) {
|
||||
const preset = require('electron-settings').get(`presets`)[name];
|
||||
return !!preset;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will apply the preset you asked for.
|
||||
* @param {string} presetName The preset name to be applied.
|
||||
*/
|
||||
function preset_apply(presetName) {
|
||||
const presets = require('electron-settings').get(`presets`)[presetName];
|
||||
appendLog(`preset_apply(): preset ${presetName}: ${JSON.stringify(presets)}`);
|
||||
var ret = require('electron-settings').set("latest_controller_tabs_settings", presets);
|
||||
if (!preset_isExist(presetName)) {
|
||||
notification('danger', `Unable to apply unexisting preset "${presetName}".`);
|
||||
return;
|
||||
}
|
||||
|
||||
const preset = require('electron-settings').get(`presets`)[presetName];
|
||||
appendLog(`preset_apply(): preset ${presetName}: ${JSON.stringify(preset)}`);
|
||||
|
||||
var ret = require('electron-settings').set("latest_controller_tabs_settings", preset);
|
||||
appendLog(`preset_apply(): saved preset: ${JSON.stringify(ret)}`);
|
||||
|
||||
loadLatestUsedSettings();
|
||||
applyRyzenSettings();
|
||||
toggleOptionDisplayBasedOnApplyCheckbox();
|
||||
|
Loading…
Reference in New Issue
Block a user