disambiguate devices by ID in memberinfo
This commit is contained in:
parent
6e57faecb0
commit
5fa5489bbd
2 changed files with 22 additions and 3 deletions
src/components/views/rooms
|
@ -145,16 +145,17 @@ export default class MemberDeviceInfo extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var deviceName = this.props.device.getDisplayName() || this.props.device.deviceId;
|
var deviceName = this.props.device.ambiguous ?
|
||||||
|
(this.props.device.getDisplayName() ? this.props.device.getDisplayName() : "") + " (" + this.props.device.deviceId + ")" :
|
||||||
|
this.props.device.getDisplayName();
|
||||||
|
|
||||||
var info = (
|
var info = (
|
||||||
<div className="mx_MemberDeviceInfo_deviceInfo" title={ "device id: " + this.props.device.deviceId }>
|
<div className="mx_MemberDeviceInfo_deviceInfo">
|
||||||
<div className="mx_MemberDeviceInfo_deviceId">{deviceName}{indicator}</div>
|
<div className="mx_MemberDeviceInfo_deviceId">{deviceName}{indicator}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the deviceId as a titletext to help with debugging
|
|
||||||
return (
|
return (
|
||||||
<div className="mx_MemberDeviceInfo">
|
<div className="mx_MemberDeviceInfo">
|
||||||
{ info }
|
{ info }
|
||||||
|
|
|
@ -115,6 +115,23 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_disambiguateDevices: function(devices) {
|
||||||
|
var names = Object.create(null);
|
||||||
|
for (var i = 0; i < devices.length; i++) {
|
||||||
|
var name = devices[i].getDisplayName();
|
||||||
|
var indexList = names[name] || [];
|
||||||
|
indexList.push(i);
|
||||||
|
names[name] = indexList;
|
||||||
|
}
|
||||||
|
for (name in names) {
|
||||||
|
if (names[name].length > 1) {
|
||||||
|
names[name].forEach((j)=>{
|
||||||
|
devices[j].ambiguous = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onDeviceVerificationChanged: function(userId, device) {
|
onDeviceVerificationChanged: function(userId, device) {
|
||||||
if (!this._enableDevices) {
|
if (!this._enableDevices) {
|
||||||
return;
|
return;
|
||||||
|
@ -199,6 +216,7 @@ module.exports = React.createClass({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var devices = client.getStoredDevicesForUser(member.userId);
|
var devices = client.getStoredDevicesForUser(member.userId);
|
||||||
|
self._disambiguateDevices(devices);
|
||||||
self.setState({devicesLoading: false, devices: devices});
|
self.setState({devicesLoading: false, devices: devices});
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
console.log("Error downloading devices", err);
|
console.log("Error downloading devices", err);
|
||||||
|
|
Loading…
Reference in a new issue