Skip to content

Commit

Permalink
frontend: Fix router event handling in base class
Browse files Browse the repository at this point in the history
Fix router event handling in DataJobsBaseGridComponent.
Distinguish between Browser popped state and changed Team.

Signed-off-by: Goran Kokinovski <[email protected]>
  • Loading branch information
gorankokin committed Jul 7, 2023
1 parent 1f18b58 commit c64871d
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ export abstract class DataJobsBaseGridComponent
*/
onModelInit(): void {
let initializationFinished = false;
let previousState: RouteState;

this.subscriptions.push(
this.routerService
Expand All @@ -332,21 +333,28 @@ export abstract class DataJobsBaseGridComponent
)
.subscribe((routerState) => {
if (initializationFinished) {
if (!this._areQueryParamsPristine(routerState.state)) {
// check if route state comes from Browser popped state (Browser stack)
if (
(!previousState || previousState.absoluteRoutePath === routerState.state.absoluteRoutePath) &&
!this._areQueryParamsPristine(routerState.state)
) {
this._extractQueryParams(routerState.state);
this._updateUrlStateManager();

// set query params mutation to false, because it's popped state from Browser stack
// set query params mutation to false, because it's Browser popped state
// no need to update the Browser URL, just URLStateManager need to be updated
this.urlStateManager.isQueryParamsStateMutated = false;
} else {
this._updateUrlStateManager(routerState.state);
}

previousState = routerState.state;

return;
}

initializationFinished = true;
previousState = routerState.state;

this._initUrlStateManager(routerState.state);
this._extractQueryParams(routerState.state);
Expand Down

0 comments on commit c64871d

Please sign in to comment.