diff --git a/src/components/macro/header/macro-header.component.ts b/src/components/macro/header/macro-header.component.ts index bfe540a0..ff5b7bf7 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.id)); + this.store.dispatch(MacroActions.removeMacro(this.macro)); } duplicateMacro() { diff --git a/src/store/actions/macro.ts b/src/store/actions/macro.ts index 8f94c1c7..43e9fc79 100644 --- a/src/store/actions/macro.ts +++ b/src/store/actions/macro.ts @@ -22,10 +22,10 @@ export namespace MacroActions { }; } - export function removeMacro(id: number): Action { + export function removeMacro(macro: Macro): Action { return { type: MacroActions.REMOVE, - payload: id + payload: macro }; } diff --git a/src/store/reducers/keymap.ts b/src/store/reducers/keymap.ts index 8c559da0..690cfab8 100644 --- a/src/store/reducers/keymap.ts +++ b/src/store/reducers/keymap.ts @@ -147,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, '_macroId', action.payload); + changedKeymap.layers = checkExistence(changedKeymap.layers, 'macro', action.payload); return changedKeymap; }); @@ -211,7 +211,7 @@ function generateName(keymaps: Keymap[], name: string) { return name; } -function checkExistence(layers: Layer[], property: string, value: string | number) { +function checkExistence(layers: Layer[], property: string, value: any) { let newLayers = layers.map((layer) => { let newLayer = new Layer(layer); diff --git a/src/store/reducers/macro.ts b/src/store/reducers/macro.ts index 19405ce7..0c642895 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.id !== action.payload); + newState = state.entities.filter((macro: Macro) => macro !== action.payload); return { entities: newState