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
very barebones support for warning users when rooms contain unknown devices #635
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2e15e8f
very barebones support for warning users when rooms contain unknown d…
ara4n 21f3aea
Revert accidental change
richvdh a2dd1fa
Merge branch 'develop' into matthew/warn-unknown-devices
richvdh 5538ce7
Merge branch 'develop' into matthew/warn-unknown-devices
richvdh 5da6ca8
Refactor UnknownDeviceDialog
richvdh 70190be
Factor out common onSendMessageFailed
richvdh ebf6ba8
explicitly set device known-ness
ara4n 60d7575
Merge branch 'matthew/warn-unknown-devices' of github.com:matrix-org/…
richvdh 2c7b3d9
UnknownDeviceDialog: Reword the warning
richvdh c09d173
Merge branch 'develop' into matthew/warn-unknown-devices
ara4n 5e5b7f8
support scrollable content for UnknownDeviceDialog
ara4n 5d5125d
fix copyright & always show gemini
ara4n 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
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 |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
Copyright 2017 Vector Creations Ltd | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import sdk from '../../../index'; | ||
import MatrixClientPeg from '../../../MatrixClientPeg'; | ||
import GeminiScrollbar from 'react-gemini-scrollbar'; | ||
|
||
function UserUnknownDeviceList(props) { | ||
const {userDevices} = props; | ||
|
||
const deviceListEntries = Object.keys(userDevices).map((deviceId) => | ||
<li key={ deviceId }> | ||
{ deviceId } ( { userDevices[deviceId].getDisplayName() } ) | ||
</li>, | ||
); | ||
|
||
return <ul>{deviceListEntries}</ul>; | ||
} | ||
|
||
UserUnknownDeviceList.propTypes = { | ||
// map from deviceid -> deviceinfo | ||
userDevices: React.PropTypes.object.isRequired, | ||
}; | ||
|
||
|
||
function UnknownDeviceList(props) { | ||
const {devices} = props; | ||
|
||
const userListEntries = Object.keys(devices).map((userId) => | ||
<li key={ userId }> | ||
<p>{ userId }:</p> | ||
<UserUnknownDeviceList userDevices={devices[userId]} /> | ||
</li>, | ||
); | ||
|
||
return <ul>{userListEntries}</ul>; | ||
} | ||
|
||
UnknownDeviceList.propTypes = { | ||
// map from userid -> deviceid -> deviceinfo | ||
devices: React.PropTypes.object.isRequired, | ||
}; | ||
|
||
|
||
export default React.createClass({ | ||
displayName: 'UnknownEventDialog', | ||
|
||
propTypes: { | ||
// map from userid -> deviceid -> deviceinfo | ||
devices: React.PropTypes.object.isRequired, | ||
onFinished: React.PropTypes.func.isRequired, | ||
}, | ||
|
||
componentDidMount: function() { | ||
// Given we've now shown the user the unknown device, it is no longer | ||
// unknown to them. Therefore mark it as 'known'. | ||
Object.keys(this.props.devices).forEach((userId) => { | ||
Object.keys(this.props.devices[userId]).map((deviceId) => { | ||
MatrixClientPeg.get().setDeviceKnown(userId, deviceId, true); | ||
}); | ||
}); | ||
}, | ||
|
||
render: function() { | ||
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); | ||
return ( | ||
<BaseDialog className='mx_UnknownDeviceDialog' | ||
onFinished={this.props.onFinished} | ||
title='Room contains unknown devices' | ||
> | ||
<GeminiScrollbar autoshow={false} className="mx_Dialog_content"> | ||
<h4>This room contains devices which have not been | ||
verified.</h4> | ||
<p> | ||
This means there is no guarantee that the devices belong | ||
to a rightful user of the room. | ||
</p><p> | ||
We recommend you go through the verification process | ||
for each device before continuing, but you can resend | ||
the message without verifying if you prefer. | ||
</p> | ||
<p>Unknown devices:</p> | ||
<UnknownDeviceList devices={this.props.devices} /> | ||
</GeminiScrollbar> | ||
<div className="mx_Dialog_buttons"> | ||
<button className="mx_Dialog_primary" autoFocus={ true } | ||
onClick={ this.props.onFinished } > | ||
OK | ||
</button> | ||
</div> | ||
</BaseDialog> | ||
); | ||
}, | ||
}); |
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
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.
don't we have https://github.com/JedWatson/classnames for this? fine, anyway
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.
we do. but it's arguably slightly overkill for something trivial like this. plus this was just fixing someone else's bug.