Browse Source

fix(client): prevent race condition of nested subscriptions

pull/7076/head
KenTandrian 4 weeks ago
parent
commit
b761d82d50
  1. 18
      apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts

18
apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts

@ -43,6 +43,7 @@ import {
} from '@prisma/client';
import { isNumber } from 'lodash';
import { DeviceDetectorService } from 'ngx-device-detector';
import { filter, switchMap, tap } from 'rxjs';
import { AllocationsPageParams } from './interfaces/interfaces';
@ -161,17 +162,20 @@ export class GfAllocationsPageComponent implements OnInit {
});
this.userService.stateChanged
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((state) => {
if (state?.user) {
.pipe(
filter((state) => !!state?.user),
tap((state) => {
this.user = state.user;
this.isLoading = true;
this.initialize();
this.fetchPortfolioDetails()
.pipe(takeUntilDestroyed(this.destroyRef))
this.changeDetectorRef.markForCheck();
}),
switchMap(() => this.fetchPortfolioDetails()),
takeUntilDestroyed(this.destroyRef)
)
.subscribe((portfolioDetails) => {
this.initialize();
@ -184,10 +188,6 @@ export class GfAllocationsPageComponent implements OnInit {
this.changeDetectorRef.markForCheck();
});
this.changeDetectorRef.markForCheck();
}
});
this.initialize();
}

Loading…
Cancel
Save