mirror of https://github.com/vector-im/riot-web
device verification: use a js-sdk event
We'll probably want to be able to bubble up device verifications from the js-sdk at some point, so let's use a js-sdk event for this.pull/21833/head
parent
7ce49c752f
commit
85770feb31
|
@ -139,7 +139,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
this._suppressReadReceiptAnimation = false;
|
this._suppressReadReceiptAnimation = false;
|
||||||
this.dispatcherRef = dispatcher.register(this.onAction);
|
MatrixClientPeg.get().on("deviceVerified", this.onDeviceVerified);
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillReceiveProps: function (nextProps) {
|
componentWillReceiveProps: function (nextProps) {
|
||||||
|
@ -161,16 +161,15 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
dispatcher.unregister(this.dispatcherRef);
|
var client = MatrixClientPeg.get();
|
||||||
|
if (client) {
|
||||||
|
client.removeListener("deviceVerified", this.onDeviceVerified);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onAction: function(payload) {
|
onDeviceVerified: function(userId, device) {
|
||||||
switch (payload.action) {
|
if (userId == this.props.mxEvent.getSender()) {
|
||||||
case 'device_verified':
|
this._verifyEvent(this.props.mxEvent);
|
||||||
if (payload.params.userId == this.props.mxEvent.getSender()) {
|
|
||||||
this._verifyEvent(this.props.mxEvent);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,6 @@ limitations under the License.
|
||||||
var React = require('react');
|
var React = require('react');
|
||||||
var MatrixClientPeg = require("../../../MatrixClientPeg");
|
var MatrixClientPeg = require("../../../MatrixClientPeg");
|
||||||
|
|
||||||
var dis = require("../../../dispatcher");
|
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'MemberDeviceInfo',
|
displayName: 'MemberDeviceInfo',
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
@ -29,14 +27,6 @@ module.exports = React.createClass({
|
||||||
onVerifyClick: function() {
|
onVerifyClick: function() {
|
||||||
MatrixClientPeg.get().setDeviceVerified(this.props.userId,
|
MatrixClientPeg.get().setDeviceVerified(this.props.userId,
|
||||||
this.props.device.id);
|
this.props.device.id);
|
||||||
|
|
||||||
dis.dispatch({
|
|
||||||
action: 'device_verified',
|
|
||||||
params: {
|
|
||||||
userId: this.props.userId,
|
|
||||||
deviceId: this.props.device.id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
|
@ -67,7 +67,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
this._updateStateForNewMember(this.props.member);
|
this._updateStateForNewMember(this.props.member);
|
||||||
this.dispatcherRef = dis.register(this.onAction);
|
MatrixClientPeg.get().on("deviceVerified", this.onDeviceVerified);
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillReceiveProps: function(newProps) {
|
componentWillReceiveProps: function(newProps) {
|
||||||
|
@ -77,30 +77,24 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
dis.unregister(this.dispatcherRef);
|
var client = MatrixClientPeg.get();
|
||||||
|
if (client) {
|
||||||
|
client.removeListener("deviceVerified", this.onDeviceVerified);
|
||||||
|
}
|
||||||
if (this._cancelDeviceList) {
|
if (this._cancelDeviceList) {
|
||||||
this._cancelDeviceList();
|
this._cancelDeviceList();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onAction: function(payload) {
|
onDeviceVerified: function(userId, device) {
|
||||||
switch (payload.action) {
|
if (userId == this.props.member.userId) {
|
||||||
case 'device_verified':
|
// no need to re-download the whole thing; just update our copy of
|
||||||
if (payload.params.userId == this.props.member.userId) {
|
// the list.
|
||||||
this._onDeviceVerified();
|
var devices = MatrixClientPeg.get().listDeviceKeys(userId);
|
||||||
}
|
this.setState({devices: devices});
|
||||||
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) {
|
_updateStateForNewMember: function(member) {
|
||||||
var newState = this._calculateOpsPermissions(member);
|
var newState = this._calculateOpsPermissions(member);
|
||||||
newState.devices = null;
|
newState.devices = null;
|
||||||
|
|
Loading…
Reference in New Issue