|
|
|
@ -1,8 +1,9 @@ |
|
|
|
import { Injectable } from '@angular/core'; |
|
|
|
import { State, Action, StateContext, Selector, createSelector } from '@ngxs/store'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
import { Action, createSelector, Selector, State, StateContext } from '@ngxs/store'; |
|
|
|
import snq from 'snq'; |
|
|
|
import { AddReplaceableComponent } from '../actions/replaceable-components.actions'; |
|
|
|
import { ReplaceableComponents } from '../models/replaceable-components'; |
|
|
|
import snq from 'snq'; |
|
|
|
|
|
|
|
@State<ReplaceableComponents.State>({ |
|
|
|
name: 'ReplaceableComponentsState', |
|
|
|
@ -28,10 +29,12 @@ export class ReplaceableComponentsState { |
|
|
|
return selector; |
|
|
|
} |
|
|
|
|
|
|
|
constructor(private router: Router) {} |
|
|
|
|
|
|
|
@Action(AddReplaceableComponent) |
|
|
|
replaceableComponentsAction( |
|
|
|
async replaceableComponentsAction( |
|
|
|
{ getState, patchState }: StateContext<ReplaceableComponents.State>, |
|
|
|
{ payload }: AddReplaceableComponent, |
|
|
|
{ payload, reload }: AddReplaceableComponent, |
|
|
|
) { |
|
|
|
let { replaceableComponents } = getState(); |
|
|
|
|
|
|
|
@ -48,5 +51,15 @@ export class ReplaceableComponentsState { |
|
|
|
patchState({ |
|
|
|
replaceableComponents, |
|
|
|
}); |
|
|
|
|
|
|
|
if (reload) { |
|
|
|
// TODO: Create a shared service for route reload and more
|
|
|
|
const { shouldReuseRoute } = this.router.routeReuseStrategy; |
|
|
|
this.router.routeReuseStrategy.shouldReuseRoute = () => false; |
|
|
|
this.router.navigated = false; |
|
|
|
|
|
|
|
await this.router.navigateByUrl(this.router.url).catch(); |
|
|
|
this.router.routeReuseStrategy.shouldReuseRoute = shouldReuseRoute; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|