No macro text and route update
This commit is contained in:
committed by
József Farkas
parent
f887dc8a96
commit
03ca90d558
@@ -25,7 +25,7 @@ export class MacroEffects {
|
||||
const macro: Macro[] = state.macros.entities;
|
||||
|
||||
if (state.macros.entities.length === 0) {
|
||||
this.router.navigate(['/macro/add']);
|
||||
this.router.navigate(['/macro']);
|
||||
} else {
|
||||
this.router.navigate(['/macro', macro[0].id]);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import '@ngrx/core/add/operator/select';
|
||||
import { Action } from '@ngrx/store';
|
||||
|
||||
import 'rxjs/add/observable/of';
|
||||
import 'rxjs/add/operator/map';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
@@ -13,7 +14,7 @@ const initialState: MacroState = {
|
||||
entities: []
|
||||
};
|
||||
|
||||
export default function(state = initialState, action: Action): MacroState {
|
||||
export default function (state = initialState, action: Action): MacroState {
|
||||
let newMacro: Macro;
|
||||
let newState: Macro[];
|
||||
|
||||
@@ -149,15 +150,7 @@ export function getMacroEntities(): (state$: Observable<AppState>) => Observable
|
||||
|
||||
export function getMacro(id: number) {
|
||||
if (isNaN(id)) {
|
||||
return (state$: Observable<AppState>) => state$
|
||||
.select(appState => appState.macros.entities)
|
||||
.map((macros: Macro[]) => {
|
||||
if (macros.length > 0) {
|
||||
return macros[0];
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
return () => Observable.of<Macro>(undefined);
|
||||
} else {
|
||||
return (state$: Observable<AppState>) => state$
|
||||
.select(appState => appState.macros.entities)
|
||||
|
||||
Reference in New Issue
Block a user