From 1186207658951385965231e08b813bd0cd91343b Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 24 May 2017 15:40:50 +0100 Subject: [PATCH] Initial Electron Settings - for Auto Launch (opens path for Proxy Settings) Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/BasePlatform.js | 6 ++-- src/components/structures/UserSettings.js | 35 +++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/BasePlatform.js b/src/BasePlatform.js index 6eed22f436..0fa377c88e 100644 --- a/src/BasePlatform.js +++ b/src/BasePlatform.js @@ -70,7 +70,7 @@ export default class BasePlatform { * Returns a promise that resolves to a string representing * the current version of the application. */ - getAppVersion() { + getAppVersion(): Promise { throw new Error("getAppVersion not implemented!"); } @@ -79,10 +79,12 @@ export default class BasePlatform { * with getUserMedia, return a string explaining why not. * Otherwise, return null. */ - screenCaptureErrorString() { + screenCaptureErrorString(): string { return "Not implemented"; } + isElectron(): boolean { return false; } + /** * Restarts the application, without neccessarily reloading * any application code diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 2d76047d33..0407c9b43a 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -197,6 +197,16 @@ module.exports = React.createClass({ this._syncedSettings = syncedSettings; this._localSettings = UserSettingsStore.getLocalSettings(); + + if (PlatformPeg.get().isElectron()) { + const {ipcRenderer} = require('electron'); + + ipcRenderer.once('settings', (ev, settings) => { + this.setState({ electron_settings: settings }); + }); + + ipcRenderer.send('settings_get'); + } }, componentDidMount: function() { @@ -787,6 +797,29 @@ module.exports = React.createClass({ ; }, + _renderElectronSettings: function() { + const settings = this.state.electron_settings; + if (!settings) return; + + const {ipcRenderer} = require('electron'); + + return
+

Electron Settings

+
+
+ { + ipcRenderer.send('settings_set', 'auto-launch', e.target.checked); + }} + /> + +
+
+
; + }, + _showSpoiler: function(event) { const target = event.target; target.innerHTML = target.getAttribute('data-spoiler'); @@ -988,6 +1021,8 @@ module.exports = React.createClass({ {this._renderBulkOptions()} {this._renderBugReport()} + {PlatformPeg.get().isElectron() && this._renderElectronSettings()} +

Advanced