Wire up events to update UI on device verification

Use the dispatcher to update event tiles and memberdeviceinfo when a device is
marked as verified.
This commit is contained in:
Richard van der Hoff 2016-06-08 18:35:43 +01:00
parent 1616431d27
commit 7ce49c752f
3 changed files with 45 additions and 3 deletions

View file

@ -67,6 +67,7 @@ module.exports = React.createClass({
componentDidMount: function() {
this._updateStateForNewMember(this.props.member);
this.dispatcherRef = dis.register(this.onAction);
},
componentWillReceiveProps: function(newProps) {
@ -76,11 +77,30 @@ module.exports = React.createClass({
},
componentWillUnmount: function() {
dis.unregister(this.dispatcherRef);
if (this._cancelDeviceList) {
this._cancelDeviceList();
}
},
onAction: function(payload) {
switch (payload.action) {
case 'device_verified':
if (payload.params.userId == this.props.member.userId) {
this._onDeviceVerified();
}
break;
}
},
_onDeviceVerified: function() {
// no need to re-download the whole thing; just update our copy of the
// list.
var devices = MatrixClientPeg.get().listDeviceKeys(
this.props.member.userId);
this.setState({devices: devices});
},
_updateStateForNewMember: function(member) {
var newState = this._calculateOpsPermissions(member);
newState.devices = null;