Browse Source

Addresses feedback from dtslvr in PR #2959 for better code consistency and maintainability.

pull/2959/head
Martin 2 years ago
committed by Thomas Kaul
parent
commit
3fd4715f2e
  1. 3
      .vscode/settings.json
  2. 14
      apps/client/src/app/components/home-overview/home-overview.component.ts
  3. 2
      apps/client/src/app/core/layout.service.ts

3
.vscode/settings.json

@ -1,5 +1,4 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"angular.enable-strict-mode-prompt": false
"editor.formatOnSave": true
}

14
apps/client/src/app/components/home-overview/home-overview.component.ts

@ -36,7 +36,6 @@ export class HomeOverviewComponent implements OnDestroy, OnInit {
public showDetails = false;
public unit: string;
public user: User;
private subscription: Subscription;
private unsubscribeSubject = new Subject<void>();
@ -44,8 +43,8 @@ export class HomeOverviewComponent implements OnDestroy, OnInit {
private changeDetectorRef: ChangeDetectorRef,
private dataService: DataService,
private deviceService: DeviceDetectorService,
private layoutService: LayoutService,
private impersonationStorageService: ImpersonationStorageService,
private layoutService: LayoutService,
private userService: UserService
) {
this.userService.stateChanged
@ -82,9 +81,11 @@ export class HomeOverviewComponent implements OnDestroy, OnInit {
this.unit = this.showDetails ? this.user.settings.baseCurrency : '%';
this.subscription = this.layoutService.shouldReload$.subscribe(() => {
this.update();
});
this.layoutService.shouldReload$
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(() => {
this.update();
});
}
public onChangeDateRange(dateRange: DateRange) {
@ -108,9 +109,6 @@ export class HomeOverviewComponent implements OnDestroy, OnInit {
public ngOnDestroy() {
this.unsubscribeSubject.next();
this.unsubscribeSubject.complete();
if (this.subscription) {
this.subscription.unsubscribe();
}
}
private update() {

2
apps/client/src/app/core/layout.service.ts

@ -10,7 +10,7 @@ export class LayoutService {
// Observable stream
public shouldReload$ = this.shouldReloadSubject.asObservable();
constructor() {}
public constructor() {}
// Method to trigger the reload
public triggerReload() {

Loading…
Cancel
Save