From 646cb64a8acb096544a6e0d71f6feb0825bc8628 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Thu, 17 Nov 2016 09:08:13 +0100 Subject: [PATCH] Redirect to specific URL of favourite keymap --- src/store/effects/keymap.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/store/effects/keymap.ts b/src/store/effects/keymap.ts index ec9aa5d9..f562b48c 100644 --- a/src/store/effects/keymap.ts +++ b/src/store/effects/keymap.ts @@ -28,12 +28,13 @@ export class KeymapEffects { .ofType(KeymapActions.REMOVE) .withLatestFrom(this.store) .do((latest) => { - let state: AppState = latest[1]; + const state: AppState = latest[1]; if (state.keymaps.entities.length === 0) { this.router.navigate(['/keymap/add']); } else { - this.router.navigate(['/keymap']); + let favourite: Keymap = state.keymaps.entities.find(keymap => keymap.isDefault); + this.router.navigate(['/keymap', favourite.abbreviation]); } }); @@ -41,7 +42,7 @@ export class KeymapEffects { .ofType(KeymapActions.EDIT_ABBR) .withLatestFrom(this.store) .do((latest) => { - let state: AppState = latest[1]; + const state: AppState = latest[1]; this.router.navigate(['/keymap', state.keymaps.newAbbr]); });