Fix reintroduced macro deleting bug

Fixes #140
This commit is contained in:
Farkas József
2016-12-15 22:59:25 +01:00
parent c48e959ed8
commit 6cab3b982a
4 changed files with 6 additions and 6 deletions

View File

@@ -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() {

View File

@@ -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
};
}

View File

@@ -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);

View File

@@ -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