mirror of https://github.com/vector-im/riot-web
Merge pull request #302 from matrix-org/rav/guest_device_spinner
Fix spinner-of-doom in member info for guestspull/21833/head
commit
888c0611e8
|
@ -56,7 +56,8 @@ module.exports = React.createClass({
|
||||||
muted: false,
|
muted: false,
|
||||||
isTargetMod: false,
|
isTargetMod: false,
|
||||||
updating: 0,
|
updating: 0,
|
||||||
devices: null, // null means device list is loading
|
devicesLoading: true,
|
||||||
|
devices: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -97,6 +98,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
_updateStateForNewMember: function(member) {
|
_updateStateForNewMember: function(member) {
|
||||||
var newState = this._calculateOpsPermissions(member);
|
var newState = this._calculateOpsPermissions(member);
|
||||||
|
newState.devicesLoading = true;
|
||||||
newState.devices = null;
|
newState.devices = null;
|
||||||
this.setState(newState);
|
this.setState(newState);
|
||||||
|
|
||||||
|
@ -114,14 +116,18 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
var client = MatrixClientPeg.get();
|
var client = MatrixClientPeg.get();
|
||||||
var self = this;
|
var self = this;
|
||||||
client.downloadKeys([member.userId], true).done(function() {
|
client.downloadKeys([member.userId], true).finally(function() {
|
||||||
|
self._cancelDeviceList = null;
|
||||||
|
}).done(function() {
|
||||||
if (cancelled) {
|
if (cancelled) {
|
||||||
// we got cancelled - presumably a different user now
|
// we got cancelled - presumably a different user now
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self._cancelDeviceList = null;
|
|
||||||
var devices = client.listDeviceKeys(member.userId);
|
var devices = client.listDeviceKeys(member.userId);
|
||||||
self.setState({devices: devices});
|
self.setState({devicesLoading: false, devices: devices});
|
||||||
|
}, function(err) {
|
||||||
|
console.log("Error downloading devices", err);
|
||||||
|
self.setState({devicesLoading: false});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -540,9 +546,13 @@ module.exports = React.createClass({
|
||||||
var Spinner = sdk.getComponent("elements.Spinner");
|
var Spinner = sdk.getComponent("elements.Spinner");
|
||||||
|
|
||||||
var devComponents;
|
var devComponents;
|
||||||
if (devices === null) {
|
if (this.state.devicesLoading) {
|
||||||
// still loading
|
// still loading
|
||||||
devComponents = <Spinner />;
|
devComponents = <Spinner />;
|
||||||
|
} else if (devices === null) {
|
||||||
|
devComponents = "Unable to load device list";
|
||||||
|
} else if (devices.length === 0) {
|
||||||
|
devComponents = "No registered devices";
|
||||||
} else {
|
} else {
|
||||||
devComponents = [];
|
devComponents = [];
|
||||||
for (var i = 0; i < devices.length; i++) {
|
for (var i = 0; i < devices.length; i++) {
|
||||||
|
|
Loading…
Reference in New Issue