1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 07:43:35 +00:00

Use account service for account enumeration. (#9023)

This commit is contained in:
Matt Gibson
2024-05-03 14:24:30 -04:00
committed by GitHub
parent 0b02d2ee1c
commit a4d5717283
7 changed files with 33 additions and 68 deletions

View File

@@ -1,4 +1,4 @@
import { BehaviorSubject, firstValueFrom, map } from "rxjs";
import { firstValueFrom, map } from "rxjs";
import { Jsonify, JsonValue } from "type-fest";
import { AccountService } from "../../auth/abstractions/account.service";
@@ -52,9 +52,6 @@ export class StateService<
TAccount extends Account = Account,
> implements StateServiceAbstraction<TAccount>
{
protected accountsSubject = new BehaviorSubject<{ [userId: string]: TAccount }>({});
accounts$ = this.accountsSubject.asObservable();
private hasBeenInited = false;
protected isRecoveredSession = false;
@@ -115,8 +112,6 @@ export class StateService<
state = await this.syncAccountFromDisk(authenticatedAccounts[i]);
}
await this.pushAccounts();
return state;
});
}
@@ -153,7 +148,6 @@ export class StateService<
await this.removeAccountFromDisk(options?.userId);
await this.removeAccountFromMemory(options?.userId);
await this.pushAccounts();
}
/**
@@ -856,7 +850,6 @@ export class StateService<
});
});
}
await this.pushAccounts();
}
protected async scaffoldNewAccountStorage(account: TAccount): Promise<void> {
@@ -934,17 +927,6 @@ export class StateService<
);
}
protected async pushAccounts(): Promise<void> {
await this.state().then((state) => {
if (state.accounts == null || Object.keys(state.accounts).length < 1) {
this.accountsSubject.next({});
return;
}
this.accountsSubject.next(state.accounts);
});
}
protected reconcileOptions(
requestedOptions: StorageOptions,
defaultOptions: StorageOptions,
@@ -1096,8 +1078,6 @@ export class StateService<
return state;
});
await this.pushAccounts();
}
protected createAccount(init: Partial<TAccount> = null): TAccount {