Merge pull request #4263 from matrix-org/dbkr/unify_cross_signing_checks

Use unified function to check cross-signing is ready
This commit is contained in:
David Baker 2020-03-24 13:34:27 +00:00 committed by GitHub
commit b5ea91f44c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View file

@ -116,7 +116,10 @@ export default class DeviceListener {
) return;
if (!cli.isCryptoEnabled()) return;
if (!cli.getCrossSigningId()) {
const crossSigningReady = await cli.isCrossSigningReady();
if (!crossSigningReady) {
if (this._dismissedThisDeviceToast) {
ToastStore.sharedInstance().dismissToast(THIS_DEVICE_TOAST_KEY);
return;

View file

@ -70,7 +70,6 @@ export default class CrossSigningPanel extends React.PureComponent {
};
async _getUpdatedStatus() {
// XXX: Add public accessors if we keep this around in production
const cli = MatrixClientPeg.get();
const crossSigning = cli._crypto._crossSigningInfo;
const secretStorage = cli._crypto._secretStorage;
@ -79,6 +78,7 @@ export default class CrossSigningPanel extends React.PureComponent {
const secretStorageKeyInAccount = await secretStorage.hasKey();
const homeserverSupportsCrossSigning =
await cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing");
const crossSigningReady = await cli.isCrossSigningReady();
const secretStorageKeyNeedsUpgrade = await cli.secretStorageKeyNeedsUpgrade();
this.setState({
@ -86,6 +86,7 @@ export default class CrossSigningPanel extends React.PureComponent {
crossSigningPrivateKeysInStorage,
secretStorageKeyInAccount,
homeserverSupportsCrossSigning,
crossSigningReady,
secretStorageKeyNeedsUpgrade,
});
}
@ -131,6 +132,7 @@ export default class CrossSigningPanel extends React.PureComponent {
crossSigningPrivateKeysInStorage,
secretStorageKeyInAccount,
homeserverSupportsCrossSigning,
crossSigningReady,
secretStorageKeyNeedsUpgrade,
} = this.state;
@ -147,11 +149,14 @@ export default class CrossSigningPanel extends React.PureComponent {
);
let summarisedStatus;
if (!homeserverSupportsCrossSigning) {
if (homeserverSupportsCrossSigning === undefined) {
const InlineSpinner = sdk.getComponent('views.elements.InlineSpinner');
summarisedStatus = <p><InlineSpinner /></p>;
} else if (!homeserverSupportsCrossSigning) {
summarisedStatus = <p>{_t(
"Your homeserver does not support cross-signing.",
)}</p>;
} else if (enabledForAccount && crossSigningPublicKeysOnDevice) {
} else if (crossSigningReady) {
summarisedStatus = <p> {_t(
"Cross-signing and secret storage are enabled.",
)}</p>;