mirror of
https://gitlab.com/ryzen-controller-team/ryzen-controller.git
synced 2024-12-22 10:03:28 +07:00
fix: #43 Stop trying to apply settings when ryzenadj has not been set.
This commit is contained in:
parent
9d01b070d3
commit
ef35ffe128
@ -6,6 +6,7 @@ ready(function(){
|
|||||||
fixPath();
|
fixPath();
|
||||||
displayOptions();
|
displayOptions();
|
||||||
preFillSettings();
|
preFillSettings();
|
||||||
|
isRyzenAdjPathValid();
|
||||||
loadLatestUsedSettings();
|
loadLatestUsedSettings();
|
||||||
registerRepeaterForAllInput();
|
registerRepeaterForAllInput();
|
||||||
registerEventListenerForSettingsInput();
|
registerEventListenerForSettingsInput();
|
||||||
@ -40,6 +41,10 @@ function applyRyzenSettings() {
|
|||||||
const child = require('child_process').execFile;
|
const child = require('child_process').execFile;
|
||||||
const executablePath = getRyzenAdjExecutablePath();
|
const executablePath = getRyzenAdjExecutablePath();
|
||||||
|
|
||||||
|
if (!isRyzenAdjPathValid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const options_data = require('./js/options_data.json');
|
const options_data = require('./js/options_data.json');
|
||||||
const ryzenAdjConvert = {
|
const ryzenAdjConvert = {
|
||||||
"toHex": function (value) { return '0x' + decimalToHexString(value * 1000); },
|
"toHex": function (value) { return '0x' + decimalToHexString(value * 1000); },
|
||||||
|
@ -246,13 +246,10 @@ function getRyzenAdjExecutablePath() {
|
|||||||
* Will fill settings page on render with saved data.
|
* Will fill settings page on render with saved data.
|
||||||
*/
|
*/
|
||||||
function preFillSettings() {
|
function preFillSettings() {
|
||||||
var ryzen_adj_path = document.getElementById('ryzen_adj_path');
|
const ryzen_adj_path = document.getElementById('ryzen_adj_path');
|
||||||
var fs = require('fs');
|
|
||||||
ryzen_adj_path.value = getRyzenAdjExecutablePath();
|
|
||||||
if (!fs.existsSync(ryzen_adj_path.value)) {
|
|
||||||
notification('danger', "Path to ryzenadj.exe is wrong, please fix it in settings tab.");
|
|
||||||
}
|
|
||||||
const settings = require('electron-settings');
|
const settings = require('electron-settings');
|
||||||
|
|
||||||
|
ryzen_adj_path.value = getRyzenAdjExecutablePath();
|
||||||
document.getElementById('start_at_boot').checked = !!settings.get('settings.start_at_boot');
|
document.getElementById('start_at_boot').checked = !!settings.get('settings.start_at_boot');
|
||||||
document.getElementById('apply_last_settings_on_launch').checked = !!settings.get('settings.apply_last_settings_on_launch');
|
document.getElementById('apply_last_settings_on_launch').checked = !!settings.get('settings.apply_last_settings_on_launch');
|
||||||
document.getElementById('minimize_to_tray').checked = !!settings.get('settings.minimize_to_tray');
|
document.getElementById('minimize_to_tray').checked = !!settings.get('settings.minimize_to_tray');
|
||||||
@ -264,6 +261,22 @@ function preFillSettings() {
|
|||||||
document.getElementById('reapply_periodically_range').value = seconds;
|
document.getElementById('reapply_periodically_range').value = seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if ryzenadj executable has been registered and is valid.
|
||||||
|
* Will display a notification if not.
|
||||||
|
*
|
||||||
|
* @return {Boolean} True if ryzenadj executable exists.
|
||||||
|
*/
|
||||||
|
function isRyzenAdjPathValid() {
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
if (!fs.existsSync(getRyzenAdjExecutablePath())) {
|
||||||
|
notification('danger', "Path to ryzenadj.exe is wrong, please fix it in settings tab.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will open a dialog to let user choose where is ryzenadj.exe.
|
* Will open a dialog to let user choose where is ryzenadj.exe.
|
||||||
*/
|
*/
|
||||||
@ -438,7 +451,7 @@ function registerEventListenerForSettingsInput() {
|
|||||||
});
|
});
|
||||||
var start_at_boot = document.getElementById('start_at_boot');
|
var start_at_boot = document.getElementById('start_at_boot');
|
||||||
start_at_boot.addEventListener('change', function() {
|
start_at_boot.addEventListener('change', function() {
|
||||||
|
|
||||||
settings.set(
|
settings.set(
|
||||||
"settings",
|
"settings",
|
||||||
Object.assign(
|
Object.assign(
|
||||||
@ -570,7 +583,7 @@ function checkForNewRelease() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
request.send();
|
request.send();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('Unable to check if new release is available.', error);
|
console.log('Unable to check if new release is available.', error);
|
||||||
|
Loading…
Reference in New Issue
Block a user