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.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true, "editor.formatOnSave": true
"angular.enable-strict-mode-prompt": false
} }

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

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

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

Loading…
Cancel
Save