From 0bc244b9f16372b4f59f7159de27d3f707d7c136 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Wed, 29 Mar 2023 15:10:59 +0900 Subject: [PATCH] Use window.location object instead of angular router for default graph window preference setting --- frontend/src/app/services/storage.service.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/services/storage.service.ts b/frontend/src/app/services/storage.service.ts index 73a013146..60d66b284 100644 --- a/frontend/src/app/services/storage.service.ts +++ b/frontend/src/app/services/storage.service.ts @@ -12,20 +12,22 @@ export class StorageService { setDefaultValueIfNeeded(key: string, defaultValue: string) { const graphWindowPreference: string = this.getValue(key); + const fragment = window.location.hash.replace('#', ''); + if (graphWindowPreference === null) { // First visit to mempool.space - if (this.router.url.includes('graphs') && key === 'graphWindowPreference' || - this.router.url.includes('pools') && key === 'miningWindowPreference' + if (window.location.pathname.includes('graphs') && key === 'graphWindowPreference' || + window.location.pathname.includes('pools') && key === 'miningWindowPreference' ) { - this.setValue(key, this.route.snapshot.fragment ? this.route.snapshot.fragment : defaultValue); + this.setValue(key, fragment ? fragment : defaultValue); } else { this.setValue(key, defaultValue); } - } else if (this.router.url.includes('graphs') && key === 'graphWindowPreference' || - this.router.url.includes('pools') && key === 'miningWindowPreference' + } else if (window.location.pathname.includes('graphs') && key === 'graphWindowPreference' || + window.location.pathname.includes('pools') && key === 'miningWindowPreference' ) { // 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); + if (fragment !== null && graphWindowPreference !== fragment) { + this.setValue(key, fragment); } } }