You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-17 17:42:41 +03:00
Prepare for asynchronous e2e APIs
the js-sdk is making some of its APIs asynchronous, and adding an `initCrypto` method which you have to call. Particular methods we need to worry about are: * `getStoredDevice` * `getStoredDevicesForUser` * `getEventSenderDeviceInfo` * `isEventSenderVerified`
This commit is contained in:
@@ -193,13 +193,12 @@ module.exports = withMatrixClient(React.createClass({
|
||||
}
|
||||
},
|
||||
|
||||
_verifyEvent: function(mxEvent) {
|
||||
var verified = null;
|
||||
|
||||
if (mxEvent.isEncrypted()) {
|
||||
verified = this.props.matrixClient.isEventSenderVerified(mxEvent);
|
||||
_verifyEvent: async function(mxEvent) {
|
||||
if (!mxEvent.isEncrypted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const verified = await this.props.matrixClient.isEventSenderVerified(mxEvent);
|
||||
this.setState({
|
||||
verified: verified
|
||||
});
|
||||
|
||||
@@ -136,8 +136,12 @@ module.exports = withMatrixClient(React.createClass({
|
||||
if (userId == this.props.member.userId) {
|
||||
// no need to re-download the whole thing; just update our copy of
|
||||
// the list.
|
||||
var devices = this.props.matrixClient.getStoredDevicesForUser(userId);
|
||||
this.setState({devices: devices});
|
||||
|
||||
// Promise.resolve to handle transition from static result to promise; can be removed
|
||||
// in future
|
||||
Promise.resolve(this.props.matrixClient.getStoredDevicesForUser(userId)).then((devices) => {
|
||||
this.setState({devices: devices});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -204,14 +208,15 @@ module.exports = withMatrixClient(React.createClass({
|
||||
|
||||
var client = this.props.matrixClient;
|
||||
var self = this;
|
||||
client.downloadKeys([member.userId], true).finally(function() {
|
||||
client.downloadKeys([member.userId], true).then(() => {
|
||||
return client.getStoredDevicesForUser(member.userId);
|
||||
}).finally(function() {
|
||||
self._cancelDeviceList = null;
|
||||
}).done(function() {
|
||||
}).done(function(devices) {
|
||||
if (cancelled) {
|
||||
// we got cancelled - presumably a different user now
|
||||
return;
|
||||
}
|
||||
var devices = client.getStoredDevicesForUser(member.userId);
|
||||
self._disambiguateDevices(devices);
|
||||
self.setState({devicesLoading: false, devices: devices});
|
||||
}, function(err) {
|
||||
|
||||
Reference in New Issue
Block a user