Browse Source

Refactoring

pull/2959/head
Thomas Kaul 2 years ago
parent
commit
b010aef239
  1. 4
      apps/client/src/app/components/header/header.component.ts
  2. 4
      apps/client/src/app/components/home-overview/home-overview.component.ts
  3. 16
      apps/client/src/app/core/layout.service.ts

4
apps/client/src/app/components/header/header.component.ts

@ -195,8 +195,8 @@ export class HeaderComponent implements OnChanges {
}
public onLogoClick() {
if (this.currentRoute === 'home') {
this.layoutService.triggerReload();
if (this.currentRoute === 'home' || this.currentRoute === 'zen') {
this.layoutService.getShouldReloadSubject().next();
}
}

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

@ -13,7 +13,7 @@ import {
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
import { DateRange } from '@ghostfolio/common/types';
import { DeviceDetectorService } from 'ngx-device-detector';
import { Subject, Subscription } from 'rxjs';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
@Component({
@ -81,7 +81,7 @@ export class HomeOverviewComponent implements OnDestroy, OnInit {
this.unit = this.showDetails ? this.user.settings.baseCurrency : '%';
this.layoutService.shouldReload$
this.layoutService.shouldReloadContent$
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(() => {
this.update();

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

@ -1,19 +1,19 @@
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
import { Observable, Subject } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class LayoutService {
private shouldReloadSubject = new Subject<void>();
public shouldReloadContent$: Observable<void>;
// Observable stream
public shouldReload$ = this.shouldReloadSubject.asObservable();
private shouldReloadSubject = new Subject<void>();
public constructor() {}
public constructor() {
this.shouldReloadContent$ = this.shouldReloadSubject.asObservable();
}
// Method to trigger the reload
public triggerReload() {
this.shouldReloadSubject.next();
public getShouldReloadSubject() {
return this.shouldReloadSubject;
}
}

Loading…
Cancel
Save