This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 833
Initial Electron Settings - for Auto Launch #920
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1186207
Initial Electron Settings - for Auto Launch
t3chguy b9ac122
remove listener on unmount
t3chguy a2229ce
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy 7e02977
i18n
t3chguy 0d930c0
change wording and i18n it
t3chguy dcd99ac
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into…
t3chguy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -197,6 +197,14 @@ module.exports = React.createClass({ | |
this._syncedSettings = syncedSettings; | ||
|
||
this._localSettings = UserSettingsStore.getLocalSettings(); | ||
|
||
if (PlatformPeg.get().isElectron()) { | ||
const {ipcRenderer} = require('electron'); | ||
|
||
ipcRenderer.on('settings', this._electronSettings); | ||
|
||
ipcRenderer.send('settings_get'); | ||
} | ||
}, | ||
|
||
componentDidMount: function() { | ||
|
@@ -216,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() { | ||
|
@@ -787,6 +804,29 @@ module.exports = React.createClass({ | |
</div>; | ||
}, | ||
|
||
_renderElectronSettings: function() { | ||
const settings = this.state.electron_settings; | ||
if (!settings) return; | ||
|
||
const {ipcRenderer} = require('electron'); | ||
|
||
return <div> | ||
<h3>Electron Settings</h3> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Users don't know what electron is. "Desktop-specific settings" perhaps? |
||
<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">Start automatically after system login</label> | ||
</div> | ||
</div> | ||
</div>; | ||
}, | ||
|
||
_showSpoiler: function(event) { | ||
const target = event.target; | ||
target.innerHTML = target.getAttribute('data-spoiler'); | ||
|
@@ -988,6 +1028,8 @@ module.exports = React.createClass({ | |
{this._renderBulkOptions()} | ||
{this._renderBugReport()} | ||
|
||
{PlatformPeg.get().isElectron() && this._renderElectronSettings()} | ||
|
||
<h3>Advanced</h3> | ||
|
||
<div className="mx_UserSettings_section"> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels a bit weird to pollute BasePlatform with knowledge of electron - could we not just check the type of PlatformPeg to see if it's a VectorBasePlatform or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do you mean? I can't do
PlatformPeg.get() instanceof ElectronPlatform
from the react-sdk side of things. How about a genericgetFlags()
method on BasePlatform and descendants that would have a prop of isElectron = true on Electron Platform, no idea what else it'd be useful for but it seems like the most generic way of solving thisThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or since now they have getHumanReadableName could do it based off of that but that feels dirty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it could also just be a property and then accessed as
PlatformPeg.get().isElectron
that way no other classes have to implement it but is also weird, I guess its all weird with the current settings architecture
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i must be missing how
instanceof
works - why wouldn't it work from the react-sdk side?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how would I import ElectronPlatform from riot-web into react-sdk so I can refer to it in an instanceof? Am I missing something obvious :/?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only by violating the layering (which already happens in a bunch of places, sadly). for now, stick with the isElectron() method.