diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-12-06 17:02:59 -0200 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-12-18 13:41:55 -0200 |
| commit | d647ecc4dff00be0832a40dc58ca1782a3e73626 (patch) | |
| tree | 5240a81976c4faed898ad31f9bf79072502e923b /gui | |
| parent | 3f75c93e81ede6b12685314bfe2bd8dd4e732fde (diff) | |
| download | mullvadvpn-d647ecc4dff00be0832a40dc58ca1782a3e73626.tar.xz mullvadvpn-d647ecc4dff00be0832a40dc58ca1782a3e73626.zip | |
Load GUI settings file when app starts
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/packages/desktop/src/main/index.js | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/gui/packages/desktop/src/main/index.js b/gui/packages/desktop/src/main/index.js index bf04f4d387..bbcfdac0ea 100644 --- a/gui/packages/desktop/src/main/index.js +++ b/gui/packages/desktop/src/main/index.js @@ -36,6 +36,10 @@ const DAEMON_RPC_PATH = type AppQuitStage = 'unready' | 'initiated' | 'ready'; +type GuiSettings = { + startMinimized: boolean, +}; + export type CurrentAppVersionInfo = { gui: string, daemon: string, @@ -81,6 +85,9 @@ const ApplicationMain = { proxy: null, }, }: Settings), + _guiSettings: ({ + startMinimized: false, + }: GuiSettings), _location: (null: ?Location), _lastDisconnectedLocation: (null: ?Location), @@ -124,6 +131,10 @@ const ApplicationMain = { app.setAppUserModelId('net.mullvad.vpn'); } + if (process.platform === 'linux') { + this._loadGuiSettings(); + } + app.on('activate', () => this._onActivate()); app.on('ready', () => this._onReady()); app.on('window-all-closed', () => app.quit()); @@ -205,6 +216,18 @@ const ApplicationMain = { } }, + _loadGuiSettings() { + try { + const settingsFile = path.join(app.getPath('userData'), 'gui_settings.json'); + const contents = fs.readFileSync(settingsFile, 'utf8'); + const settings = JSON.parse(contents); + + this._guiSettings.startMinimized = settings.startMinimized || false; + } catch (error) { + log.error(`Failed to read GUI settings file: ${error}`); + } + }, + // Returns platform specific logs folder for application // See open issue and PR on Github: // 1. https://github.com/electron/electron/issues/10118 @@ -1009,16 +1032,7 @@ const ApplicationMain = { case 'darwin': return false; case 'linux': - try { - const settingsFile = path.join(app.getPath('userData'), 'gui_settings.json'); - const contents = fs.readFileSync(settingsFile, 'utf8'); - const settings = JSON.parse(contents); - - return !settings.startMinimized; - } catch (error) { - log.error(`Failed to read if window should start minimized or not: ${error}`); - return true; - } + return !this._guiSettings.startMinimized; default: return true; } |
