From 235266151366b34e42b12da1ebec75d15f4b0495 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 8 Jun 2016 22:54:48 +0100 Subject: [PATCH] MemberInfo: remove spinner if device query fails If the request to /keys/query fails (for example, because we are a guest), we need to remove the spinner. --- src/components/views/rooms/MemberInfo.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/components/views/rooms/MemberInfo.js b/src/components/views/rooms/MemberInfo.js index c50b6e919e..bd9fd06be2 100644 --- a/src/components/views/rooms/MemberInfo.js +++ b/src/components/views/rooms/MemberInfo.js @@ -56,7 +56,8 @@ module.exports = React.createClass({ muted: false, isTargetMod: false, 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) { var newState = this._calculateOpsPermissions(member); + newState.devicesLoading = true; newState.devices = null; this.setState(newState); @@ -114,14 +116,18 @@ module.exports = React.createClass({ var client = MatrixClientPeg.get(); var self = this; - client.downloadKeys([member.userId], true).done(function() { + client.downloadKeys([member.userId], true).finally(function() { + self._cancelDeviceList = null; + }).done(function() { if (cancelled) { // we got cancelled - presumably a different user now return; } - self._cancelDeviceList = null; 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 devComponents; - if (devices === null) { + if (this.state.devicesLoading) { // still loading devComponents = ; + } else if (devices === null) { + devComponents = "Unable to load device list"; + } else if (devices.length === 0) { + devComponents = "No registered devices"; } else { devComponents = []; for (var i = 0; i < devices.length; i++) {