Switch to using checkDeviceTrust

In the UserInfo panel. This means we now use cross-signing
verifications in the UserInfoPanel so we can see our cross-signing
verifications working!

Lots more to do here: the remaining device.isVerified() calls in
UserInfoPanel are where it needs to be switched to verifying users
rather than devices, and of course we need to replace all the calls
to device.isVerified() with checkDeviceTrust everywhere else.
This commit is contained in:
David Baker 2019-12-20 11:31:11 +00:00
parent 24d0d0d596
commit b998e6ffe8

View file

@ -129,17 +129,20 @@ function verifyDevice(userId, device) {
} }
function DeviceItem({userId, device}) { function DeviceItem({userId, device}) {
const cli = useContext(MatrixClientContext);
const deviceTrust = cli.checkDeviceTrust(userId, device.deviceId);
const classes = classNames("mx_UserInfo_device", { const classes = classNames("mx_UserInfo_device", {
mx_UserInfo_device_verified: device.isVerified(), mx_UserInfo_device_verified: deviceTrust.isVerified(),
mx_UserInfo_device_unverified: !device.isVerified(), mx_UserInfo_device_unverified: !deviceTrust.isVerified(),
}); });
const iconClasses = classNames("mx_E2EIcon", { const iconClasses = classNames("mx_E2EIcon", {
mx_E2EIcon_verified: device.isVerified(), mx_E2EIcon_verified: deviceTrust.isVerified(),
mx_E2EIcon_warning: !device.isVerified(), mx_E2EIcon_warning: !deviceTrust.isVerified(),
}); });
const onDeviceClick = () => { const onDeviceClick = () => {
if (!device.isVerified()) { if (!deviceTrust.isVerified()) {
verifyDevice(userId, device); verifyDevice(userId, device);
} }
}; };
@ -147,7 +150,7 @@ function DeviceItem({userId, device}) {
const deviceName = device.ambiguous ? const deviceName = device.ambiguous ?
(device.getDisplayName() ? device.getDisplayName() : "") + " (" + device.deviceId + ")" : (device.getDisplayName() ? device.getDisplayName() : "") + " (" + device.deviceId + ")" :
device.getDisplayName(); device.getDisplayName();
const trustedLabel = device.isVerified() ? _t("Trusted") : _t("Not trusted"); const trustedLabel = deviceTrust.isVerified() ? _t("Trusted") : _t("Not trusted");
return (<AccessibleButton className={classes} onClick={onDeviceClick}> return (<AccessibleButton className={classes} onClick={onDeviceClick}>
<div className={iconClasses} /> <div className={iconClasses} />
<div className="mx_UserInfo_device_name">{deviceName}</div> <div className="mx_UserInfo_device_name">{deviceName}</div>
@ -157,6 +160,7 @@ function DeviceItem({userId, device}) {
function DevicesSection({devices, userId, loading}) { function DevicesSection({devices, userId, loading}) {
const Spinner = sdk.getComponent("elements.Spinner"); const Spinner = sdk.getComponent("elements.Spinner");
const cli = useContext(MatrixClientContext);
const [isExpanded, setExpanded] = useState(false); const [isExpanded, setExpanded] = useState(false);
@ -167,9 +171,21 @@ function DevicesSection({devices, userId, loading}) {
if (devices === null) { if (devices === null) {
return _t("Unable to load device list"); return _t("Unable to load device list");
} }
const deviceTrusts = devices.map(d => cli.checkDeviceTrust(userId, d.deviceId));
const unverifiedDevices = devices.filter(d => !d.isVerified()); const unverifiedDevices = [];
const verifiedDevices = devices.filter(d => d.isVerified()); const verifiedDevices = [];
for (let i = 0; i < devices.length; ++i) {
const device = devices[i];
const deviceTrust = deviceTrusts[i];
if (deviceTrust.isVerified()) {
verifiedDevices.push(device);
} else {
unverifiedDevices.push(device);
}
}
let expandButton; let expandButton;
if (verifiedDevices.length) { if (verifiedDevices.length) {