Skip to content

Commit

Permalink
[PM-5111] Reduce calls to config endpoint (#7069)
Browse files Browse the repository at this point in the history
* Removed second active account observable and added distinctUntilChanged.

* Updated comment.
  • Loading branch information
trmartin4 authored Dec 6, 2023
1 parent 0aca876 commit 299a880
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 3 additions & 1 deletion libs/common/src/platform/services/environment.service.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion libs/common/src/platform/services/state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit 299a880

Please sign in to comment.