From de38e9c06e3b93a50b162ec92ce892ffde469af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Farkas=20J=C3=B3zsef?= Date: Thu, 29 Dec 2016 16:57:04 +0100 Subject: [PATCH] Fixes Keymap and Macro removing Fixes #235 --- src/components/macro/header/macro-header.component.ts | 2 +- src/store/actions/macro.ts | 4 ++-- src/store/reducers/keymap.ts | 5 ++--- src/store/reducers/macro.ts | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/macro/header/macro-header.component.ts b/src/components/macro/header/macro-header.component.ts index ff5b7bf7..bfe540a0 100644 --- a/src/components/macro/header/macro-header.component.ts +++ b/src/components/macro/header/macro-header.component.ts @@ -36,7 +36,7 @@ export class MacroHeaderComponent implements AfterViewInit, OnChanges { } removeMacro() { - this.store.dispatch(MacroActions.removeMacro(this.macro)); + this.store.dispatch(MacroActions.removeMacro(this.macro.id)); } duplicateMacro() { diff --git a/src/store/actions/macro.ts b/src/store/actions/macro.ts index 43e9fc79..5b0fc5f6 100644 --- a/src/store/actions/macro.ts +++ b/src/store/actions/macro.ts @@ -22,10 +22,10 @@ export namespace MacroActions { }; } - export function removeMacro(macro: Macro): Action { + export function removeMacro(macroId: number): Action { return { type: MacroActions.REMOVE, - payload: macro + payload: macroId }; } diff --git a/src/store/reducers/keymap.ts b/src/store/reducers/keymap.ts index 7c825f12..89115fdf 100644 --- a/src/store/reducers/keymap.ts +++ b/src/store/reducers/keymap.ts @@ -97,12 +97,11 @@ export default function (state = initialState, action: Action): KeymapState { filtered[0].isDefault = true; } - const deletedKeymap = state.entities.find(keymap => keymap.abbreviation === action.payload); // Check for the deleted keymap in other keymaps newState = filtered.map((keymap: Keymap) => { changedKeymap = new Keymap(); Object.assign(changedKeymap, keymap); - changedKeymap.layers = checkExistence(changedKeymap.layers, 'keymap', deletedKeymap); + changedKeymap.layers = checkExistence(changedKeymap.layers, 'keymapAbbreviation', action.payload); return changedKeymap; }); @@ -148,7 +147,7 @@ export default function (state = initialState, action: Action): KeymapState { newState = state.entities.map((keymap: Keymap) => { changedKeymap = new Keymap(); Object.assign(changedKeymap, keymap); - changedKeymap.layers = checkExistence(changedKeymap.layers, 'macro', action.payload); + changedKeymap.layers = checkExistence(changedKeymap.layers, '_macroId', action.payload); return changedKeymap; }); diff --git a/src/store/reducers/macro.ts b/src/store/reducers/macro.ts index 0c642895..19405ce7 100644 --- a/src/store/reducers/macro.ts +++ b/src/store/reducers/macro.ts @@ -57,7 +57,7 @@ export default function (state = initialState, action: Action): MacroState { }; case MacroActions.REMOVE: - newState = state.entities.filter((macro: Macro) => macro !== action.payload); + newState = state.entities.filter((macro: Macro) => macro.id !== action.payload); return { entities: newState