make UnknownDeviceDialog work again, other than the mess of vector-im/vector-web#3020

This commit is contained in:
Matthew Hodgson 2017-01-22 01:28:43 +01:00
parent d9c0513ee2
commit 7bc3fc8696
6 changed files with 33 additions and 30 deletions

View file

@ -60,7 +60,7 @@ const SETTINGS_LABELS = [
const CRYPTO_SETTINGS_LABELS = [ const CRYPTO_SETTINGS_LABELS = [
{ {
id: 'blacklistUnverifiedDevices', id: 'blacklistUnverifiedDevices',
label: 'Never send encrypted messages to unverified devices', label: 'Never send encrypted messages to unverified devices from this device',
}, },
// XXX: this is here for documentation; the actual setting is managed via RoomSettings // XXX: this is here for documentation; the actual setting is managed via RoomSettings
// { // {

View file

@ -36,14 +36,15 @@ module.exports = React.createClass({
}, },
render: function() { render: function() {
var DeviceVerifyButtons = sdk.getComponent('elements.DeviceVerifyButtons');
var client = MatrixClientPeg.get(); var client = MatrixClientPeg.get();
var blacklistUnverified = (client.getGlobalBlacklistUnverifiedDevices() || room.getBlacklistUnverifiedDevices()); var blacklistUnverified = client.getGlobalBlacklistUnverifiedDevices() || this.props.room.getBlacklistUnverifiedDevices();
var warning; var warning;
if (blacklistUnverified) { if (blacklistUnverified) {
warning = <h4>You are currently blacklisting unverified devices; to send messages to these devices you must verify them.<h4>; warning = <h4>You are currently blacklisting unverified devices; to send messages to these devices you must verify them.</h4>
} }
else { else {
warning = <h4>We strongly recommend you verify them before continuing.</h4>; warning = <h4>We strongly recommend you verify them before continuing.</h4>
} }
return ( return (
@ -54,19 +55,20 @@ module.exports = React.createClass({
<div className="mx_Dialog_content"> <div className="mx_Dialog_content">
<h4>This room contains unknown devices which have not been verified.</h4> <h4>This room contains unknown devices which have not been verified.</h4>
{ warning } { warning }
<p>Unknown devices: Unknown devices:
<ul>{ <ul>{
Object.keys(this.props.devices).map(userId=>{ Object.keys(this.props.devices).map(userId=>{
return <li key={ userId }> return <li key={ userId }>
<p>{ userId }:</p> <p>{ userId }:</p>
<ul> <ul className="mx_UnknownDeviceDialog_deviceList">
{ {
Object.keys(this.props.devices[userId]).map(deviceId=>{ Object.keys(this.props.devices[userId]).map(deviceId=>{
var DeviceVerifyButtons = sdk.getComponent('elements.DeviceVerifyButtons');
var device = this.props.devices[userId][deviceId]; var device = this.props.devices[userId][deviceId];
var buttons = <DeviceVerifyButtons device={ device } userId={ userId } /> var buttons = <DeviceVerifyButtons device={ device } userId={ userId } />
return <li key={ deviceId }> return <li key={ deviceId }>
{ deviceId } ( { device.getDisplayName() } ) { buttons } { buttons }
{ deviceId }<br/>
{ device.getDisplayName() }
</li> </li>
}) })
} }
@ -74,7 +76,6 @@ module.exports = React.createClass({
</li> </li>
}) })
}</ul> }</ul>
</p>
</div> </div>
<div className="mx_Dialog_buttons"> <div className="mx_Dialog_buttons">
<button className="mx_Dialog_primary" onClick={ this.props.onFinished } autoFocus={ true }> <button className="mx_Dialog_primary" onClick={ this.props.onFinished } autoFocus={ true }>

View file

@ -553,6 +553,7 @@ export default class MessageComposerInput extends React.Component {
sendMessagePromise = sendTextFn.call(this.client, this.props.room.roomId, contentText); sendMessagePromise = sendTextFn.call(this.client, this.props.room.roomId, contentText);
} }
var self = this;
sendMessagePromise.then((res) => { sendMessagePromise.then((res) => {
dis.dispatch({ dis.dispatch({
action: 'message_sent', action: 'message_sent',
@ -562,7 +563,7 @@ export default class MessageComposerInput extends React.Component {
var UnknownDeviceDialog = sdk.getComponent("dialogs.UnknownDeviceDialog"); var UnknownDeviceDialog = sdk.getComponent("dialogs.UnknownDeviceDialog");
Modal.createDialog(UnknownDeviceDialog, { Modal.createDialog(UnknownDeviceDialog, {
devices: err.devices, devices: err.devices,
room: this.props.room, room: self.props.room,
}); });
} }
dis.dispatch({ dis.dispatch({

View file

@ -337,6 +337,7 @@ module.exports = React.createClass({
MatrixClientPeg.get().sendTextMessage(this.props.room.roomId, contentText); MatrixClientPeg.get().sendTextMessage(this.props.room.roomId, contentText);
} }
var self = this;
sendMessagePromise.done(function(res) { sendMessagePromise.done(function(res) {
dis.dispatch({ dis.dispatch({
action: 'message_sent' action: 'message_sent'
@ -346,7 +347,7 @@ module.exports = React.createClass({
var UnknownDeviceDialog = sdk.getComponent("dialogs.UnknownDeviceDialog"); var UnknownDeviceDialog = sdk.getComponent("dialogs.UnknownDeviceDialog");
Modal.createDialog(UnknownDeviceDialog, { Modal.createDialog(UnknownDeviceDialog, {
devices: err.devices, devices: err.devices,
room: this.props.room, room: self.props.room,
}); });
} }

View file

@ -512,7 +512,7 @@ module.exports = React.createClass({
<input type="checkbox" ref="blacklistUnverified" <input type="checkbox" ref="blacklistUnverified"
defaultChecked={ isGlobalBlacklistUnverified || isRoomBlacklistUnverified } defaultChecked={ isGlobalBlacklistUnverified || isRoomBlacklistUnverified }
disabled={ isGlobalBlacklistUnverified || (this.refs.encrypt && !this.refs.encrypt.checked) }/> disabled={ isGlobalBlacklistUnverified || (this.refs.encrypt && !this.refs.encrypt.checked) }/>
Never send encrypted messages to unverified devices in this room. Never send encrypted messages to unverified devices in this room from this device.
</label>; </label>;
if (!isEncrypted && if (!isEncrypted &&