|
|
@ -17,12 +17,11 @@ import { |
|
|
ChangeDetectorRef, |
|
|
ChangeDetectorRef, |
|
|
Component, |
|
|
Component, |
|
|
CUSTOM_ELEMENTS_SCHEMA, |
|
|
CUSTOM_ELEMENTS_SCHEMA, |
|
|
OnDestroy, |
|
|
DestroyRef, |
|
|
OnInit |
|
|
OnInit |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
|
|
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { Subject } from 'rxjs'; |
|
|
|
|
|
import { takeUntil } from 'rxjs/operators'; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
imports: [ |
|
|
imports: [ |
|
|
@ -35,7 +34,7 @@ import { takeUntil } from 'rxjs/operators'; |
|
|
styleUrls: ['./home-market.scss'], |
|
|
styleUrls: ['./home-market.scss'], |
|
|
templateUrl: './home-market.html' |
|
|
templateUrl: './home-market.html' |
|
|
}) |
|
|
}) |
|
|
export class GfHomeMarketComponent implements OnDestroy, OnInit { |
|
|
export class GfHomeMarketComponent implements OnInit { |
|
|
public benchmarks: Benchmark[]; |
|
|
public benchmarks: Benchmark[]; |
|
|
public deviceType: string; |
|
|
public deviceType: string; |
|
|
public fearAndGreedIndex: number; |
|
|
public fearAndGreedIndex: number; |
|
|
@ -47,11 +46,10 @@ export class GfHomeMarketComponent implements OnDestroy, OnInit { |
|
|
public readonly numberOfDays = 365; |
|
|
public readonly numberOfDays = 365; |
|
|
public user: User; |
|
|
public user: User; |
|
|
|
|
|
|
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
|
|
|
|
|
|
|
|
|
public constructor( |
|
|
public constructor( |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private dataService: DataService, |
|
|
private dataService: DataService, |
|
|
|
|
|
private destroyRef: DestroyRef, |
|
|
private deviceService: DeviceDetectorService, |
|
|
private deviceService: DeviceDetectorService, |
|
|
private userService: UserService |
|
|
private userService: UserService |
|
|
) { |
|
|
) { |
|
|
@ -59,7 +57,7 @@ export class GfHomeMarketComponent implements OnDestroy, OnInit { |
|
|
this.info = this.dataService.fetchInfo(); |
|
|
this.info = this.dataService.fetchInfo(); |
|
|
|
|
|
|
|
|
this.userService.stateChanged |
|
|
this.userService.stateChanged |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((state) => { |
|
|
.subscribe((state) => { |
|
|
if (state?.user) { |
|
|
if (state?.user) { |
|
|
this.user = state.user; |
|
|
this.user = state.user; |
|
|
@ -82,7 +80,7 @@ export class GfHomeMarketComponent implements OnDestroy, OnInit { |
|
|
includeHistoricalData: this.numberOfDays, |
|
|
includeHistoricalData: this.numberOfDays, |
|
|
symbol: ghostfolioFearAndGreedIndexSymbol |
|
|
symbol: ghostfolioFearAndGreedIndexSymbol |
|
|
}) |
|
|
}) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(({ historicalData, marketPrice }) => { |
|
|
.subscribe(({ historicalData, marketPrice }) => { |
|
|
this.fearAndGreedIndex = marketPrice; |
|
|
this.fearAndGreedIndex = marketPrice; |
|
|
this.historicalDataItems = [ |
|
|
this.historicalDataItems = [ |
|
|
@ -99,16 +97,11 @@ export class GfHomeMarketComponent implements OnDestroy, OnInit { |
|
|
|
|
|
|
|
|
this.dataService |
|
|
this.dataService |
|
|
.fetchBenchmarks() |
|
|
.fetchBenchmarks() |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(({ benchmarks }) => { |
|
|
.subscribe(({ benchmarks }) => { |
|
|
this.benchmarks = benchmarks; |
|
|
this.benchmarks = benchmarks; |
|
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
this.changeDetectorRef.markForCheck(); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public ngOnDestroy() { |
|
|
|
|
|
this.unsubscribeSubject.next(); |
|
|
|
|
|
this.unsubscribeSubject.complete(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|