Skip to content

Commit

Permalink
Apply review recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewFerr committed Aug 4, 2023
1 parent 7449440 commit cc221fb
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/e2ee/RustEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class RustEngine {
if (keysClaim) {
await this.processKeysClaimRequest(keysClaim);
// Back up keys asynchronously
this.backupRoomKeysIfEnabled();
void this.backupRoomKeysIfEnabled();
}
});

Expand All @@ -140,6 +140,7 @@ export class RustEngine {
public enableKeyBackup(info: IKeyBackupInfoRetrieved): Promise<void> {
this.keyBackupWaiter = this.keyBackupWaiter.then(async () => {
if (this.isBackupEnabled) {
// Finish any pending backups before changing the backup version/pubkey
await this.actuallyDisableKeyBackup();
}
// TODO Error with message if the key backup uses an unsupported auth_data type
Expand All @@ -151,15 +152,17 @@ export class RustEngine {
}

public disableKeyBackup(): Promise<void> {
this.keyBackupWaiter = this.keyBackupWaiter.then(this.actuallyDisableKeyBackup);
this.keyBackupWaiter = this.keyBackupWaiter.then(async () => {
await this.actuallyDisableKeyBackup();
});
return this.keyBackupWaiter;
}

private readonly actuallyDisableKeyBackup = async () => {
private async actuallyDisableKeyBackup(): Promise<void> {
await this.machine.disableBackup();
this.keyBackupVersion = undefined;
this.isBackupEnabled = false;
};
}

public backupRoomKeys(): Promise<void> {
this.keyBackupWaiter = this.keyBackupWaiter.then(async () => {
Expand All @@ -180,12 +183,12 @@ export class RustEngine {
return this.keyBackupWaiter;
}

private readonly actuallyBackupRoomKeys = async () => {
private async actuallyBackupRoomKeys(): Promise<void> {
const request = await this.machine.backupRoomKeys();
if (request) {
await this.processKeysBackupRequest(request);
}
};
}

private async processKeysClaimRequest(request: KeysClaimRequest) {
const resp = await this.client.doRequest("POST", "/_matrix/client/v3/keys/claim", null, JSON.parse(request.body));
Expand Down

0 comments on commit cc221fb

Please sign in to comment.