This repository was archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 822
UI for blacklisting unverified devices per-room & globally #636
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3071fc0
UI for blacklisting unverified devices per-room & globally
ara4n c618880
oops
ara4n 071e364
improve the verify warning if blacklisting is unabled
ara4n 532f4e5
literally blindly add verification buttons
ara4n 39c122f
fix local storage idiocy
ara4n d9c0513
make it work
ara4n 7bc3fc8
make UnknownDeviceDialog work again, other than the mess of vector-im…
ara4n 67bd2cf
Merge branch 'matthew/warn-unknown-devices' into matthew/blacklist-un…
richvdh 0a3d9fc
Fix lint
richvdh be41462
merge
ara4n 5de84f8
tweak verbiage
ara4n 28d28b5
correctly reflect verify/blacklist state in UI
ara4n e018eef
UnknownDeviceDialog.js: tweak warning
richvdh 3ea746d
Fix RoomSettings
richvdh 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -149,6 +149,23 @@ module.exports = { | |
return MatrixClientPeg.get().setAccountData("im.vector.web.settings", settings); | ||
}, | ||
|
||
getLocalSettings: function() { | ||
var localSettingsString = localStorage.getItem('mx_local_settings') || '{}'; | ||
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. ought to handle localStorage === undefined here |
||
return JSON.parse(localSettingsString); | ||
}, | ||
|
||
getLocalSetting: function(type, defaultValue = null) { | ||
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. type? why type? 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. comments on what the behaviour is if the setting is absent would be nice. |
||
var settings = this.getLocalSettings(); | ||
return settings.hasOwnProperty(type) ? settings[type] : null; | ||
}, | ||
|
||
setLocalSetting: function(type, value) { | ||
var settings = this.getLocalSettings(); | ||
settings[type] = value; | ||
// FIXME: handle errors | ||
localStorage.setItem('mx_local_settings', JSON.stringify(settings)); | ||
}, | ||
|
||
isFeatureEnabled: function(feature: string): boolean { | ||
// Disable labs for guests. | ||
if (MatrixClientPeg.get().isGuest()) return false; | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -59,6 +59,18 @@ const SETTINGS_LABELS = [ | |
*/ | ||
]; | ||
|
||
const CRYPTO_SETTINGS_LABELS = [ | ||
{ | ||
id: 'blacklistUnverifiedDevices', | ||
label: 'Never send encrypted messages to unverified devices from this device', | ||
}, | ||
// XXX: this is here for documentation; the actual setting is managed via RoomSettings | ||
// { | ||
// id: 'blacklistUnverifiedDevicesPerRoom' | ||
// label: 'Never send encrypted messages to unverified devices in this room', | ||
// } | ||
]; | ||
|
||
// Enumerate the available themes, with a nice human text label. | ||
// 'id' gives the key name in the im.vector.web.settings account data event | ||
// 'value' is the value for that key in the event | ||
|
@@ -151,6 +163,8 @@ module.exports = React.createClass({ | |
syncedSettings.theme = 'light'; | ||
} | ||
this._syncedSettings = syncedSettings; | ||
|
||
this._localSettings = UserSettingsStore.getLocalSettings(); | ||
}, | ||
|
||
componentDidMount: function() { | ||
|
@@ -566,10 +580,34 @@ module.exports = React.createClass({ | |
{exportButton} | ||
{importButton} | ||
</div> | ||
<div className="mx_UserSettings_section"> | ||
{ CRYPTO_SETTINGS_LABELS.map( this._renderLocalSetting ) } | ||
</div> | ||
</div> | ||
); | ||
}, | ||
|
||
_renderLocalSetting: function(setting) { | ||
const client = MatrixClientPeg.get(); | ||
return <div className="mx_UserSettings_toggle" key={ setting.id }> | ||
<input id={ setting.id } | ||
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. this is crying out to be made a separate react component. |
||
type="checkbox" | ||
defaultChecked={ this._localSettings[setting.id] } | ||
onChange={ | ||
e => { | ||
UserSettingsStore.setLocalSetting(setting.id, e.target.checked) | ||
if (setting.id === 'blacklistUnverifiedDevices') { // XXX: this is a bit ugly | ||
client.setGlobalBlacklistUnverifiedDevices(e.target.checked); | ||
} | ||
} | ||
} | ||
/> | ||
<label htmlFor={ setting.id }> | ||
{ setting.label } | ||
</label> | ||
</div>; | ||
}, | ||
|
||
_renderDevicesPanel: function() { | ||
var DevicesPanel = sdk.getComponent('settings.DevicesPanel'); | ||
return ( | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
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.
it would be good to explain wtf a 'local setting' is. Turns out, it's a setting which is persisted in localstorage.