From e41a62be13bf3317235c355a2646247975f749b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Farkas=20J=C3=B3zsef?= Date: Tue, 7 Feb 2017 21:42:47 +0100 Subject: [PATCH] Remove newAbbr from KeymapState --- shared/src/store/effects/keymap.ts | 13 ++++++------- shared/src/store/index.ts | 1 - shared/src/store/reducers/keymap.ts | 3 +-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/shared/src/store/effects/keymap.ts b/shared/src/store/effects/keymap.ts index 9c5d70fa..21006380 100644 --- a/shared/src/store/effects/keymap.ts +++ b/shared/src/store/effects/keymap.ts @@ -16,7 +16,7 @@ import { Keymap } from '../../config-serializer/config-items/Keymap'; @Injectable() export class KeymapEffects { - @Effect({ dispatch: false })add$: any = this.actions$ + @Effect({ dispatch: false }) add$: any = this.actions$ .ofType(KeymapActions.ADD) .withLatestFrom(this.store) .do((latest) => { @@ -34,7 +34,7 @@ export class KeymapEffects { this.router.navigate(['/keymap', entities[entities.length - 1].abbreviation]); }); - @Effect({ dispatch: false })remove$: any = this.actions$ + @Effect({ dispatch: false }) remove$: any = this.actions$ .ofType(KeymapActions.REMOVE) .withLatestFrom(this.store) .do((latest) => { @@ -50,11 +50,10 @@ export class KeymapEffects { @Effect({ dispatch: false }) editAbbr$: any = this.actions$ .ofType(KeymapActions.EDIT_ABBR) - .withLatestFrom(this.store) - .do((latest) => { - const state: AppState = latest[1]; - this.router.navigate(['/keymap', state.keymaps.newAbbr]); + .map(action => action.payload.newAbbr) + .do(newAbbr => { + this.router.navigate(['/keymap', newAbbr]); }); - constructor(private actions$: Actions, private router: Router, private store: Store) {} + constructor(private actions$: Actions, private router: Router, private store: Store) { } } diff --git a/shared/src/store/index.ts b/shared/src/store/index.ts index 37cf8f41..0e06626f 100644 --- a/shared/src/store/index.ts +++ b/shared/src/store/index.ts @@ -3,7 +3,6 @@ import { Macro } from '../config-serializer/config-items/Macro'; export interface KeymapState { entities: Keymap[]; - newAbbr?: string; } export interface MacroState { diff --git a/shared/src/store/reducers/keymap.ts b/shared/src/store/reducers/keymap.ts index 3b814b32..cc5b9f80 100644 --- a/shared/src/store/reducers/keymap.ts +++ b/shared/src/store/reducers/keymap.ts @@ -63,8 +63,7 @@ export default function (state = initialState, action: Action): KeymapState { }); return { - entities: newState, - newAbbr: abbr + entities: newState }; case KeymapActions.SET_DEFAULT: