Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #920 from matrix-org/t3chguy/electron_settings
Browse files Browse the repository at this point in the history
Initial Electron Settings - for Auto Launch
  • Loading branch information
ara4n authored May 30, 2017
2 parents 055386d + dcd99ac commit 3942dbc
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/BasePlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class BasePlatform {
* Returns a promise that resolves to a string representing
* the current version of the application.
*/
getAppVersion() {
getAppVersion(): Promise<string> {
throw new Error("getAppVersion not implemented!");
}

Expand All @@ -84,10 +84,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
Expand Down
41 changes: 41 additions & 0 deletions src/components/structures/UserSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ module.exports = React.createClass({

this._localSettings = UserSettingsStore.getLocalSettings();

if (PlatformPeg.get().isElectron()) {
const {ipcRenderer} = require('electron');

ipcRenderer.on('settings', this._electronSettings);
ipcRenderer.send('settings_get');
}

this.setState({
language: languageHandler.getCurrentLanguage(),
});
Expand All @@ -239,6 +246,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() {
Expand Down Expand Up @@ -843,6 +859,29 @@ module.exports = React.createClass({
</div>;
},

_renderElectronSettings: function() {
const settings = this.state.electron_settings;
if (!settings) return;

const {ipcRenderer} = require('electron');

return <div>
<h3>{ _t('Desktop specific') }</h3>
<div className="mx_UserSettings_section">
<div className="mx_UserSettings_toggle">
<input type="checkbox"
name="auto-launch"
defaultChecked={settings['auto-launch']}
onChange={(e) => {
ipcRenderer.send('settings_set', 'auto-launch', e.target.checked);
}}
/>
<label htmlFor="auto-launch">{_t('Start automatically after system login')}</label>
</div>
</div>
</div>;
},

_showSpoiler: function(event) {
const target = event.target;
target.innerHTML = target.getAttribute('data-spoiler');
Expand Down Expand Up @@ -1045,6 +1084,8 @@ module.exports = React.createClass({
{this._renderBulkOptions()}
{this._renderBugReport()}

{PlatformPeg.get().isElectron() && this._renderElectronSettings()}

{this._renderAnalyticsControl()}

<h3>{ _t("Advanced") }</h3>
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,9 @@
"%(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",
"Start automatically after system login": "Start automatically after system login",
"Desktop specific": "Desktop specific",
"Analytics": "Analytics",
"Opt out of analytics": "Opt out of analytics",
"Riot collects anonymous analytics to allow us to improve the application.": "Riot collects anonymous analytics to allow us to improve the application.",
Expand Down

0 comments on commit 3942dbc

Please sign in to comment.