1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-29 04:17:41 +02:00

[PM-5111] Reduce calls to config endpoint (#7069)

* Removed second active account observable and added distinctUntilChanged.

* Updated comment.
This commit is contained in:
Todd Martin 2023-12-06 11:21:29 -05:00 committed by GitHub
parent 0aca876b75
commit 299a880cba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import { concatMap, Observable, ReplaySubject } from "rxjs";
import { concatMap, distinctUntilChanged, Observable, ReplaySubject } from "rxjs";
import { EnvironmentUrls } from "../../auth/models/domain/environment-urls";
import {
@ -52,6 +52,8 @@ export class EnvironmentService implements EnvironmentServiceAbstraction {
constructor(private stateService: StateService) {
this.stateService.activeAccount$
.pipe(
// Use == here to not trigger on undefined -> null transition
distinctUntilChanged((oldUserId: string, newUserId: string) => oldUserId == newUserId),
concatMap(async () => {
if (!this.initialized) {
return;

View File

@ -224,7 +224,6 @@ export class StateService<
email: account.profile.email,
});
await this.setActiveUser(account.profile.userId);
this.activeAccountSubject.next(account.profile.userId);
}
async setActiveUser(userId: string): Promise<void> {