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 1/4] 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

From b9ac1222ed08239e56c11e4f2597b300e41afccb Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 24 May 2017 15:55:37 +0100 Subject: [PATCH 2/4] remove listener on unmount Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/UserSettings.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 0407c9b43a..5ce0779322 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -201,9 +201,7 @@ module.exports = React.createClass({ if (PlatformPeg.get().isElectron()) { const {ipcRenderer} = require('electron'); - ipcRenderer.once('settings', (ev, settings) => { - this.setState({ electron_settings: settings }); - }); + ipcRenderer.on('settings', this._electronSettings); ipcRenderer.send('settings_get'); } @@ -226,6 +224,15 @@ module.exports = React.createClass({ if (cli) { cli.removeListener("RoomMember.membership", this._onInviteStateChange); } + + if (PlatformPeg.get().isElectron()) { + const {ipcRenderer} = require('electron'); + ipcRenderer.removeListener('settings', this._electronSettings); + } + }, + + _electronSettings: function(ev, settings) { + this.setState({ electron_settings: settings }); }, _refreshFromServer: function() { From 7e02977c27c79012ddd915085640a183d2c80454 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 29 May 2017 21:58:47 +0100 Subject: [PATCH 3/4] i18n Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/UserSettings.js | 2 +- src/i18n/strings/en_EN.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 714f7a6881..020c3e49b0 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -851,7 +851,7 @@ module.exports = React.createClass({ ipcRenderer.send('settings_set', 'auto-launch', e.target.checked); }} /> - +
; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 5abb27e2b7..38d9648d1a 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -673,5 +673,6 @@ "%(oneUser)schanged their avatar %(repeats)s times": "%(oneUser)schanged their avatar %(repeats)s times", "%(severalUsers)schanged their avatar": "%(severalUsers)schanged their avatar", "%(oneUser)schanged their avatar": "%(oneUser)schanged their avatar", - "Please select the destination room for this message": "Please select the destination room for this message" + "Please select the destination room for this message": "Please select the destination room for this message", + "Start automatically after system login": "Start automatically after system login" } From 0d930c0553562318fb9fb99cc6a7c4dfbb445f46 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 30 May 2017 23:46:51 +0100 Subject: [PATCH 4/4] change wording and i18n it Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/UserSettings.js | 2 +- src/i18n/strings/en_EN.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 020c3e49b0..39c2c0f145 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -841,7 +841,7 @@ module.exports = React.createClass({ const {ipcRenderer} = require('electron'); return
-

Electron Settings

+

{ _t('Desktop specific') }