Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for cancel broken on add route #3228

Merged
merged 5 commits into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Better fix for the prvious state bug with extensions
  • Loading branch information
nwmac committed Nov 22, 2018
commit 789b799a24e8f40598b77f00df48221572bfc7e2
8 changes: 1 addition & 7 deletions src/frontend/app/core/extension/dynamic-extension-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@ export class DynamicExtenstionRoutes implements CanActivate {
this.setChildRoutes(route.parent.routeConfig, newChildRoutes);
this.router.navigateByUrl(state.url);

// Dispatch action so that the previous state URL is stored correctly
this.store.dispatch({
type: ROUTER_NAVIGATION,
payload: {}
});

return false;
return false;
}

private getChildRoutes(r: any) {
Expand Down
9 changes: 9 additions & 0 deletions src/frontend/app/store/reducers/routing.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ export interface RouterRedirect {
export function routingReducer(state: RoutingHistory = defaultRoutingState, action: RouterNavigationAction) {
switch (action.type) {
case ROUTER_NAVIGATION:
// Check that the route actually changed - don't update the state if it did not
// This catches the case for the Dynamic Extensions where we have to redirect to the route
// Which would otherwise set the previous state to the same state as the current state
const destUrl = action.payload.event.url;
const currentUrl = state.currentState ? state.currentState.url : null;
if (destUrl === currentUrl) {
return { ... state };
}

return {
// history: state.history.concat([action.payload.event]),
previousState: state.currentState ? state.currentState : null,
Expand Down