Use unified function to check cross-signing is ready

Fixes mismatches where the Cross signing panel would say cross
signing was not ready but no toasts would appear.

Fixes https://github.com/vector-im/riot-web/issues/12796
Fixes https://github.com/vector-im/riot-web/issues/12798
Requires https://github.com/matrix-org/matrix-js-sdk/pull/1279
This commit is contained in:
David Baker 2020-03-23 18:36:37 +00:00
parent b8ef736038
commit 281bc09c9a
2 changed files with 12 additions and 3 deletions

View File

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

View File

@ -74,12 +74,14 @@ export default class CrossSigningPanel extends React.PureComponent {
const secretStorageKeyInAccount = await secretStorage.hasKey(); const secretStorageKeyInAccount = await secretStorage.hasKey();
const homeserverSupportsCrossSigning = const homeserverSupportsCrossSigning =
await cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing"); await cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing");
const crossSigningReady = await cli.crossSigningReady();
this.setState({ this.setState({
crossSigningPublicKeysOnDevice, crossSigningPublicKeysOnDevice,
crossSigningPrivateKeysInStorage, crossSigningPrivateKeysInStorage,
secretStorageKeyInAccount, secretStorageKeyInAccount,
homeserverSupportsCrossSigning, homeserverSupportsCrossSigning,
crossSigningReady,
}); });
} }
@ -124,6 +126,7 @@ export default class CrossSigningPanel extends React.PureComponent {
crossSigningPrivateKeysInStorage, crossSigningPrivateKeysInStorage,
secretStorageKeyInAccount, secretStorageKeyInAccount,
homeserverSupportsCrossSigning, homeserverSupportsCrossSigning,
crossSigningReady,
} = this.state; } = this.state;
let errorSection; let errorSection;
@ -139,11 +142,14 @@ export default class CrossSigningPanel extends React.PureComponent {
); );
let summarisedStatus; let summarisedStatus;
if (!homeserverSupportsCrossSigning) { if (homeserverSupportsCrossSigning === undefined) {
const InlineSpinner = sdk.getComponent('views.elements.InlineSpinner');
summarisedStatus = <p><InlineSpinner /></p>;
} else if (!homeserverSupportsCrossSigning) {
summarisedStatus = <p>{_t( summarisedStatus = <p>{_t(
"Your homeserver does not support cross-signing.", "Your homeserver does not support cross-signing.",
)}</p>; )}</p>;
} else if (enabledForAccount && crossSigningPublicKeysOnDevice) { } else if (crossSigningReady) {
summarisedStatus = <p> {_t( summarisedStatus = <p> {_t(
"Cross-signing and secret storage are enabled.", "Cross-signing and secret storage are enabled.",
)}</p>; )}</p>;