diff --git a/apps/api/src/app/info/info.service.ts b/apps/api/src/app/info/info.service.ts index 2752795672..cb7d24bcba 100644 --- a/apps/api/src/app/info/info.service.ts +++ b/apps/api/src/app/info/info.service.ts @@ -1,7 +1,6 @@ import { RedisCacheService } from '@ghostfolio/api/app/redis-cache/redis-cache.service'; import { SubscriptionService } from '@ghostfolio/api/app/subscription/subscription.service'; import { UserService } from '@ghostfolio/api/app/user/user.service'; -import { encodeDataSource } from '@ghostfolio/api/helper/data-source.helper'; import { BenchmarkService } from '@ghostfolio/api/services/benchmark/benchmark.service'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service'; @@ -25,6 +24,7 @@ import { permissions } from '@ghostfolio/common/permissions'; import { Injectable } from '@nestjs/common'; import { JwtService } from '@nestjs/jwt'; +import { MarketData } from '@prisma/client'; import { subDays } from 'date-fns'; import { isNil } from 'lodash'; @@ -48,6 +48,7 @@ export class InfoService { public async get(): Promise { const info: Partial = {}; let isReadOnlyMode: boolean; + let latestFearAndGreedStocksMarketDataPromise: Promise; const globalPermissions: string[] = []; @@ -64,23 +65,12 @@ export class InfoService { } if (this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX')) { - const fearAndGreedIndexDataSource = - this.dataProviderService.getDataSourceForFearAndGreedIndexStocks(); - - if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) { - info.fearAndGreedDataSource = encodeDataSource( - fearAndGreedIndexDataSource - ); - } else { - info.fearAndGreedDataSource = fearAndGreedIndexDataSource; - } - - const latestMarketData = await this.marketDataService.getLatest({ - dataSource: fearAndGreedIndexDataSource, - symbol: ghostfolioFearAndGreedIndexSymbolStocks - }); - - info.fearAndGreedMarketPrice = latestMarketData?.marketPrice; + latestFearAndGreedStocksMarketDataPromise = + this.marketDataService.getLatest({ + dataSource: + this.dataProviderService.getDataSourceForFearAndGreedIndexStocks(), + symbol: ghostfolioFearAndGreedIndexSymbolStocks + }); globalPermissions.push(permissions.enableFearAndGreedIndex); } @@ -112,12 +102,14 @@ export class InfoService { benchmarks, demoAuthToken, isUserSignupEnabled, + latestFearAndGreedStocksMarketData, statistics, subscriptionOffer ] = await Promise.all([ this.benchmarkService.getBenchmarkAssetProfiles(), this.getDemoAuthToken(), this.propertyService.isUserSignupEnabled(), + latestFearAndGreedStocksMarketDataPromise, this.getStatistics(), this.subscriptionService.getSubscriptionOffer({ key: 'default' }) ]); @@ -135,7 +127,9 @@ export class InfoService { statistics, subscriptionOffer, baseCurrency: DEFAULT_CURRENCY, - currencies: this.exchangeRateDataService.getCurrencies() + currencies: this.exchangeRateDataService.getCurrencies(), + fearAndGreedStocksMarketPrice: + latestFearAndGreedStocksMarketData?.marketPrice }; } diff --git a/apps/client/src/app/components/home-market/home-market.component.ts b/apps/client/src/app/components/home-market/home-market.component.ts index d22f3b9749..0eec3f2d9e 100644 --- a/apps/client/src/app/components/home-market/home-market.component.ts +++ b/apps/client/src/app/components/home-market/home-market.component.ts @@ -29,10 +29,12 @@ import { DeviceDetectorService } from 'ngx-device-detector'; }) export class GfHomeMarketComponent implements OnInit { protected readonly benchmarks = signal([]); + protected readonly deviceType = computed( () => this.deviceDetectorService.deviceInfo().deviceType ); - protected readonly fearAndGreedIndex = signal(undefined); + + protected fearAndGreedIndex: number | undefined; protected hasPermissionToAccessFearAndGreedIndex: boolean; protected user: User; @@ -65,7 +67,7 @@ export class GfHomeMarketComponent implements OnInit { ); if (this.hasPermissionToAccessFearAndGreedIndex) { - this.fearAndGreedIndex.set(this.info.fearAndGreedMarketPrice); + this.fearAndGreedIndex = this.info.fearAndGreedStocksMarketPrice; } this.dataService diff --git a/apps/client/src/app/components/home-market/home-market.html b/apps/client/src/app/components/home-market/home-market.html index 6d344d74f1..b1e21df955 100644 --- a/apps/client/src/app/components/home-market/home-market.html +++ b/apps/client/src/app/components/home-market/home-market.html @@ -5,7 +5,7 @@
diff --git a/apps/client/src/app/components/home-market/home-market.scss b/apps/client/src/app/components/home-market/home-market.scss index 5b523160d5..5d4e87f30f 100644 --- a/apps/client/src/app/components/home-market/home-market.scss +++ b/apps/client/src/app/components/home-market/home-market.scss @@ -1,7 +1,3 @@ :host { display: block; - - gf-line-chart { - aspect-ratio: 16 / 9; - } } diff --git a/libs/common/src/lib/interfaces/info-item.interface.ts b/libs/common/src/lib/interfaces/info-item.interface.ts index 08c1d13872..96db7f9b06 100644 --- a/libs/common/src/lib/interfaces/info-item.interface.ts +++ b/libs/common/src/lib/interfaces/info-item.interface.ts @@ -9,8 +9,7 @@ export interface InfoItem { countriesOfSubscribers?: string[]; currencies: string[]; demoAuthToken: string; - fearAndGreedDataSource?: string; - fearAndGreedMarketPrice?: number; + fearAndGreedStocksMarketPrice?: number; globalPermissions: string[]; isDataGatheringEnabled?: string; isReadOnlyMode?: boolean;