Fix xxxWindowPreference management

This commit is contained in:
nymkappa
2022-01-19 13:03:43 +09:00
parent 16ab9b38a0
commit 92de2bbc03
4 changed files with 20 additions and 42 deletions

View File

@@ -78,6 +78,7 @@ export class PoolRankingComponent implements OnInit, OnDestroy {
}
onChangeWindowPreference(e) {
this.storageService.setValue('poolsWindowPreference', e.target.value);
this.poolsWindowPreference = e.target.value;
this.isLoading = true;
this.refreshMiningStats();

View File

@@ -13,12 +13,17 @@ export class StorageService {
setDefaultValueIfNeeded(key: string, defaultValue: string) {
let graphWindowPreference: string = this.getValue(key);
if (graphWindowPreference === null) { // First visit to mempool.space
if (this.router.url.includes("graphs") || this.router.url.includes("pools")) {
if (this.router.url.includes('graphs') && key === 'graphWindowPreference' ||
this.router.url.includes('pools') && key === 'poolsWindowPreference'
) {
this.setValue(key, this.route.snapshot.fragment ? this.route.snapshot.fragment : defaultValue);
} else {
this.setValue(key, defaultValue);
}
} else if (this.router.url.includes("graphs") || this.router.url.includes("pools")) { // Visit a different graphs#fragment from last visit
} else if (this.router.url.includes('graphs') && key === 'graphWindowPreference' ||
this.router.url.includes('pools') && key === 'poolsWindowPreference'
) {
// Visit a different graphs#fragment from last visit
if (this.route.snapshot.fragment !== null && graphWindowPreference !== this.route.snapshot.fragment) {
this.setValue(key, this.route.snapshot.fragment);
}