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

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

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

Loading…
Cancel
Save