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() {
|
||||
this._suppressReadReceiptAnimation = false;
|
||||
this.dispatcherRef = dispatcher.register(this.onAction);
|
||||
MatrixClientPeg.get().on("deviceVerified", this.onDeviceVerified);
|
||||
},
|
||||
|
||||
componentWillReceiveProps: function (nextProps) {
|
||||
|
@ -161,16 +161,15 @@ module.exports = React.createClass({
|
|||
},
|
||||
|
||||
componentWillUnmount: function() {
|
||||
dispatcher.unregister(this.dispatcherRef);
|
||||
var client = MatrixClientPeg.get();
|
||||
if (client) {
|
||||
client.removeListener("deviceVerified", this.onDeviceVerified);
|
||||
}
|
||||
},
|
||||
|
||||
onAction: function(payload) {
|
||||
switch (payload.action) {
|
||||
case 'device_verified':
|
||||
if (payload.params.userId == this.props.mxEvent.getSender()) {
|
||||
this._verifyEvent(this.props.mxEvent);
|
||||
}
|
||||
break;
|
||||
onDeviceVerified: function(userId, device) {
|
||||
if (userId == this.props.mxEvent.getSender()) {
|
||||
this._verifyEvent(this.props.mxEvent);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@ limitations under the License.
|
|||
var React = require('react');
|
||||
var MatrixClientPeg = require("../../../MatrixClientPeg");
|
||||
|
||||
var dis = require("../../../dispatcher");
|
||||
|
||||
module.exports = React.createClass({
|
||||
displayName: 'MemberDeviceInfo',
|
||||
propTypes: {
|
||||
|
@ -29,14 +27,6 @@ module.exports = React.createClass({
|
|||
onVerifyClick: function() {
|
||||
MatrixClientPeg.get().setDeviceVerified(this.props.userId,
|
||||
this.props.device.id);
|
||||
|
||||
dis.dispatch({
|
||||
action: 'device_verified',
|
||||
params: {
|
||||
userId: this.props.userId,
|
||||
deviceId: this.props.device.id,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
|
|
|
@ -67,7 +67,7 @@ module.exports = React.createClass({
|
|||
|
||||
componentDidMount: function() {
|
||||
this._updateStateForNewMember(this.props.member);
|
||||
this.dispatcherRef = dis.register(this.onAction);
|
||||
MatrixClientPeg.get().on("deviceVerified", this.onDeviceVerified);
|
||||
},
|
||||
|
||||
componentWillReceiveProps: function(newProps) {
|
||||
|
@ -77,30 +77,24 @@ module.exports = React.createClass({
|
|||
},
|
||||
|
||||
componentWillUnmount: function() {
|
||||
dis.unregister(this.dispatcherRef);
|
||||
var client = MatrixClientPeg.get();
|
||||
if (client) {
|
||||
client.removeListener("deviceVerified", this.onDeviceVerified);
|
||||
}
|
||||
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(userId, device) {
|
||||
if (userId == this.props.member.userId) {
|
||||
// no need to re-download the whole thing; just update our copy of
|
||||
// the list.
|
||||
var devices = MatrixClientPeg.get().listDeviceKeys(userId);
|
||||
this.setState({devices: devices});
|
||||
}
|
||||
},
|
||||
|
||||
_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;
|
||||
|
|
Loading…
Reference in New Issue