From 30ff1c55d33341b1481d93fc7d9f88d87755c31a Mon Sep 17 00:00:00 2001 From: Mononaut Date: Mon, 5 Aug 2024 13:57:01 +0000 Subject: [PATCH] clear miningstats cache on network change --- frontend/src/app/services/mining.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/services/mining.service.ts b/frontend/src/app/services/mining.service.ts index 64748e547..e84b6b972 100644 --- a/frontend/src/app/services/mining.service.ts +++ b/frontend/src/app/services/mining.service.ts @@ -31,6 +31,7 @@ export class MiningService { data: MiningStats; } } = {}; + network: string; poolsData: SinglePoolStats[] = []; constructor( @@ -44,7 +45,7 @@ export class MiningService { */ public getMiningStats(interval: string): Observable { // returned cached data fetched within the last 5 minutes - if (this.cache[interval] && this.cache[interval].lastUpdated > (Date.now() - (5 * 60000))) { + if (this.cache[interval] && this.cache[interval].lastUpdated > (Date.now() - (5 * 60000)) && this.network === this.stateService.network) { return of(this.cache[interval].data); } else { return this.apiService.listPools$(interval).pipe( @@ -54,6 +55,7 @@ export class MiningService { lastUpdated: Date.now(), data: stats, }; + this.network = this.stateService.network; }) ); }