Replace Matrix.getKeyBackupEnabled by MatrixClient.CryptoApi.getActiveSessionBackupVersion (#28225)

* Migrating deprecated sync `MatrixClient.getKeyBackupEnabled` to async `MatrixClient.CryptoApi.getActiveSessionBackupVersion` in `NewRecoveryMethodDialog`.
Rewrite `NewRecoveryMethodDialog` into a functional component to make it easier to handle the new async method.

* Migrating deprecated sync `MatrixClient.getKeyBackupEnabled` to async `MatrixClient.CryptoApi.getActiveSessionBackupVersion` in `MatrixChat`.
This commit is contained in:
Florian Duros 2024-10-18 11:45:45 +02:00 committed by GitHub
parent 85d2bf3a04
commit 1bb482f6f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 312 additions and 72 deletions

View file

@ -1631,8 +1631,12 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
cli.on(CryptoEvent.KeyBackupFailed, async (errcode): Promise<void> => {
let haveNewVersion: boolean | undefined;
let newVersionInfo: KeyBackupInfo | null = null;
const keyBackupEnabled = Boolean(
cli.getCrypto() && (await cli.getCrypto()?.getActiveSessionBackupVersion()) !== null,
);
// if key backup is still enabled, there must be a new backup in place
if (cli.getKeyBackupEnabled()) {
if (keyBackupEnabled) {
haveNewVersion = true;
} else {
// otherwise check the server to see if there's a new one
@ -1650,7 +1654,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
import(
"../../async-components/views/dialogs/security/NewRecoveryMethodDialog"
) as unknown as Promise<typeof NewRecoveryMethodDialog>,
{ newVersionInfo: newVersionInfo! },
);
} else {
Modal.createDialogAsync(