mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 14:23:32 +00:00
[PM-5111] Reduce calls to config endpoint (#7069)
* Removed second active account observable and added distinctUntilChanged. * Updated comment.
This commit is contained in:
@@ -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 { EnvironmentUrls } from "../../auth/models/domain/environment-urls";
|
||||||
import {
|
import {
|
||||||
@@ -52,6 +52,8 @@ export class EnvironmentService implements EnvironmentServiceAbstraction {
|
|||||||
constructor(private stateService: StateService) {
|
constructor(private stateService: StateService) {
|
||||||
this.stateService.activeAccount$
|
this.stateService.activeAccount$
|
||||||
.pipe(
|
.pipe(
|
||||||
|
// Use == here to not trigger on undefined -> null transition
|
||||||
|
distinctUntilChanged((oldUserId: string, newUserId: string) => oldUserId == newUserId),
|
||||||
concatMap(async () => {
|
concatMap(async () => {
|
||||||
if (!this.initialized) {
|
if (!this.initialized) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -224,7 +224,6 @@ export class StateService<
|
|||||||
email: account.profile.email,
|
email: account.profile.email,
|
||||||
});
|
});
|
||||||
await this.setActiveUser(account.profile.userId);
|
await this.setActiveUser(account.profile.userId);
|
||||||
this.activeAccountSubject.next(account.profile.userId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async setActiveUser(userId: string): Promise<void> {
|
async setActiveUser(userId: string): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user