Fixes Keymap and Macro removing

Fixes #235
This commit is contained in:
Farkas József
2016-12-29 16:57:04 +01:00
committed by József Farkas
parent 9b2aa188e6
commit de38e9c06e
4 changed files with 6 additions and 7 deletions

View File

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

View File

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

View File

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

View File

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