Factor out this device check & reorder conditionals

pull/21833/head
David Baker 2019-04-09 13:47:25 +01:00
parent 7c1943ef4e
commit 0f1ebf8095
1 changed files with 3 additions and 2 deletions

View File

@ -221,18 +221,19 @@ export default class KeyBackupPanel extends React.PureComponent {
{sub}
</span>;
const device = sub => <span className="mx_KeyBackupPanel_deviceName">{deviceName}</span>;
const fromThisDevice = sig.device.getFingerprint() === MatrixClientPeg.get().getDeviceEd25519Key();
let sigStatus;
if (!sig.device) {
sigStatus = _t(
"Backup has a signature from <verify>unknown</verify> device with ID %(deviceId)s.",
{ deviceId: sig.deviceId }, { verify },
);
} else if (sig.device.getFingerprint() === MatrixClientPeg.get().getDeviceEd25519Key() && sig.valid) {
} else if (sig.valid && fromThisDevice) {
sigStatus = _t(
"Backup has a <validity>valid</validity> signature from this device",
{}, { validity },
);
} else if (sig.device.getFingerprint() === MatrixClientPeg.get().getDeviceEd25519Key() && !sig.valid) {
} else if (!sig.valid && fromThisDevice) {
// it can happen...
sigStatus = _t(
"Backup has an <validity>invalid</validity> signature from this device",