React-sdk changes to support sandboxed electron
This commit is contained in:
parent
2ca7477406
commit
37b3644fd9
3 changed files with 25 additions and 60 deletions
|
@ -188,9 +188,11 @@ module.exports = React.createClass({
|
|||
phase: "UserSettings.LOADING", // LOADING, DISPLAY
|
||||
email_add_pending: false,
|
||||
vectorVersion: undefined,
|
||||
canSelfUpdate: null,
|
||||
rejectingInvites: false,
|
||||
mediaDevices: null,
|
||||
ignoredUsers: [],
|
||||
autoLaunchEnabled: null,
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -209,6 +211,13 @@ module.exports = React.createClass({
|
|||
}, (e) => {
|
||||
console.log("Failed to fetch app version", e);
|
||||
});
|
||||
|
||||
PlatformPeg.get().canSelfUpdate().then((canUpdate) => {
|
||||
if (this._unmounted) return;
|
||||
this.setState({
|
||||
canSelfUpdate: canUpdate,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
this._refreshMediaDevices();
|
||||
|
@ -227,11 +236,12 @@ module.exports = React.createClass({
|
|||
});
|
||||
this._refreshFromServer();
|
||||
|
||||
if (PlatformPeg.get().isElectron()) {
|
||||
const {ipcRenderer} = require('electron');
|
||||
|
||||
ipcRenderer.on('settings', this._electronSettings);
|
||||
ipcRenderer.send('settings_get');
|
||||
if (PlatformPeg.get().supportsAutoLaunch()) {
|
||||
PlatformPeg.get().getAutoLaunchEnabled().then(enabled => {
|
||||
this.setState({
|
||||
autoLaunchEnabled: enabled,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
this.setState({
|
||||
|
@ -262,11 +272,6 @@ 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);
|
||||
}
|
||||
},
|
||||
|
||||
// `UserSettings` assumes that the client peg will not be null, so give it some
|
||||
|
@ -285,10 +290,6 @@ module.exports = React.createClass({
|
|||
});
|
||||
},
|
||||
|
||||
_electronSettings: function(ev, settings) {
|
||||
this.setState({ electron_settings: settings });
|
||||
},
|
||||
|
||||
_refreshMediaDevices: function(stream) {
|
||||
if (stream) {
|
||||
// kill stream so that we don't leave it lingering around with webcam enabled etc
|
||||
|
@ -967,7 +968,7 @@ module.exports = React.createClass({
|
|||
|
||||
_renderCheckUpdate: function() {
|
||||
const platform = PlatformPeg.get();
|
||||
if ('canSelfUpdate' in platform && platform.canSelfUpdate() && 'startUpdateCheck' in platform) {
|
||||
if (this.state.canSelfUpdate) {
|
||||
return <div>
|
||||
<h3>{ _t('Updates') }</h3>
|
||||
<div className="mx_UserSettings_section">
|
||||
|
@ -1012,8 +1013,7 @@ module.exports = React.createClass({
|
|||
},
|
||||
|
||||
_renderElectronSettings: function() {
|
||||
const settings = this.state.electron_settings;
|
||||
if (!settings) return;
|
||||
if (!PlatformPeg.get().supportsAutoLaunch()) return;
|
||||
|
||||
// TODO: This should probably be a granular setting, but it only applies to electron
|
||||
// and ends up being get/set outside of matrix anyways (local system setting).
|
||||
|
@ -1023,7 +1023,7 @@ module.exports = React.createClass({
|
|||
<div className="mx_UserSettings_toggle">
|
||||
<input type="checkbox"
|
||||
name="auto-launch"
|
||||
defaultChecked={settings['auto-launch']}
|
||||
defaultChecked={this.state.autoLaunchEnabled}
|
||||
onChange={this._onAutoLaunchChanged}
|
||||
/>
|
||||
<label htmlFor="auto-launch">{ _t('Start automatically after system login') }</label>
|
||||
|
@ -1033,8 +1033,11 @@ module.exports = React.createClass({
|
|||
},
|
||||
|
||||
_onAutoLaunchChanged: function(e) {
|
||||
const {ipcRenderer} = require('electron');
|
||||
ipcRenderer.send('settings_set', 'auto-launch', e.target.checked);
|
||||
PlatformPeg.get().setAutoLaunchEnabled(e.target.checked).then(() => {
|
||||
this.setState({
|
||||
autoLaunchEnabled: e.target.checked,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
_mapWebRtcDevicesToSpans: function(devices) {
|
||||
|
@ -1393,7 +1396,7 @@ module.exports = React.createClass({
|
|||
{ this._renderBulkOptions() }
|
||||
{ this._renderBugReport() }
|
||||
|
||||
{ PlatformPeg.get().isElectron() && this._renderElectronSettings() }
|
||||
{ this._renderElectronSettings() }
|
||||
|
||||
{ this._renderAnalyticsControl() }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue