@@ -36,7 +36,7 @@ export class MacroHeaderComponent implements AfterViewInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeMacro() {
|
removeMacro() {
|
||||||
this.store.dispatch(MacroActions.removeMacro(this.macro.id));
|
this.store.dispatch(MacroActions.removeMacro(this.macro));
|
||||||
}
|
}
|
||||||
|
|
||||||
duplicateMacro() {
|
duplicateMacro() {
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ export namespace MacroActions {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeMacro(id: number): Action {
|
export function removeMacro(macro: Macro): Action {
|
||||||
return {
|
return {
|
||||||
type: MacroActions.REMOVE,
|
type: MacroActions.REMOVE,
|
||||||
payload: id
|
payload: macro
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ export default function (state = initialState, action: Action): KeymapState {
|
|||||||
newState = state.entities.map((keymap: Keymap) => {
|
newState = state.entities.map((keymap: Keymap) => {
|
||||||
changedKeymap = new Keymap();
|
changedKeymap = new Keymap();
|
||||||
Object.assign(changedKeymap, keymap);
|
Object.assign(changedKeymap, keymap);
|
||||||
changedKeymap.layers = checkExistence(changedKeymap.layers, '_macroId', action.payload);
|
changedKeymap.layers = checkExistence(changedKeymap.layers, 'macro', action.payload);
|
||||||
|
|
||||||
return changedKeymap;
|
return changedKeymap;
|
||||||
});
|
});
|
||||||
@@ -211,7 +211,7 @@ function generateName(keymaps: Keymap[], name: string) {
|
|||||||
return name;
|
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 newLayers = layers.map((layer) => {
|
||||||
let newLayer = new Layer(layer);
|
let newLayer = new Layer(layer);
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export default function (state = initialState, action: Action): MacroState {
|
|||||||
};
|
};
|
||||||
|
|
||||||
case MacroActions.REMOVE:
|
case MacroActions.REMOVE:
|
||||||
newState = state.entities.filter((macro: Macro) => macro.id !== action.payload);
|
newState = state.entities.filter((macro: Macro) => macro !== action.payload);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
entities: newState
|
entities: newState
|
||||||
|
|||||||
Reference in New Issue
Block a user