From a7b0362f0f153131196a9e62c5deb8293e552448 Mon Sep 17 00:00:00 2001 From: Quentin DECAUNES Date: Tue, 30 Jul 2019 16:53:22 +0200 Subject: [PATCH] Fixes RYZEN-CONTROLLER-12 - Better detection of wrong path for askingForRyzenAdjExecutablePath(). --- js/methods.js | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/js/methods.js b/js/methods.js index 986d7e5..0847fa9 100644 --- a/js/methods.js +++ b/js/methods.js @@ -215,25 +215,29 @@ function askingForRyzenAdjExecutablePath() { var remote = require('electron').remote; var dialog = remote.require('electron').dialog; - var path = dialog.showOpenDialog({ + dialog.showOpenDialog({ properties: ['openFile'] }, function (filePaths) { - if (typeof filePaths[0] !== 'undefined') { - const settings = require('electron-settings'); - - settings.set("settings", - Object.assign( - {}, - settings.get('settings'), - { ryzen_adj_path: filePaths[0] } - ) - ); - - notification('primary', 'Path to ryzenAdj executable has been saved.'); - appendLog(`askingForRyzenAdjExecutablePath(): ${filePaths[0]}`); - } else { + const settings = require('electron-settings'); + if (typeof filePaths === 'undefined') { notification('warning', 'No path given, nothing changed.'); + return; } + if (typeof filePaths[0] === 'undefined') { + notification('warning', 'No path given, nothing changed.'); + return; + } + + settings.set("settings", + Object.assign( + {}, + settings.get('settings'), + { ryzen_adj_path: filePaths[0] } + ) + ); + + notification('primary', 'Path to ryzenAdj executable has been saved.'); + appendLog(`askingForRyzenAdjExecutablePath(): ${filePaths[0]}`); preFillSettings(); }); }