From bdd4c30fc0ac34d606f434c46dedf76354b8b4b7 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Thu, 27 Aug 2020 17:01:47 +0300 Subject: [PATCH] Fixed clear state params for change dashboardId --- .../pages/dashboard/states/state-controller.component.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/dashboard/states/state-controller.component.ts b/ui-ngx/src/app/modules/home/pages/dashboard/states/state-controller.component.ts index ae3600409d..bd552f409f 100644 --- a/ui-ngx/src/app/modules/home/pages/dashboard/states/state-controller.component.ts +++ b/ui-ngx/src/app/modules/home/pages/dashboard/states/state-controller.component.ts @@ -100,7 +100,7 @@ export abstract class StateControllerComponent implements IStateControllerCompon this.rxSubscriptions.push(this.route.queryParamMap.subscribe((paramMap) => { const dashboardId = this.route.snapshot.params.dashboardId; if (this.dashboardId === dashboardId) { - const newState = decodeURIComponent(paramMap.get('state')); + const newState = this.decodeStateParam(paramMap.get('state')); if (this.currentState !== newState) { this.currentState = newState; if (this.inited) { @@ -147,10 +147,15 @@ export abstract class StateControllerComponent implements IStateControllerCompon } public reInit() { - this.currentState = decodeURIComponent(this.route.snapshot.queryParamMap.get('state')); + this.preservedState = null; + this.currentState = this.decodeStateParam(this.route.snapshot.queryParamMap.get('state')); this.init(); } + private decodeStateParam(stateURI: string): string{ + return stateURI !== null ? decodeURIComponent(stateURI) : null; + } + protected abstract init(); protected abstract onMobileChanged();