fix: SwitchKeymapAction not allow to refer to itself (#694)

This commit is contained in:
Róbert Kiss
2018-06-24 20:32:32 +02:00
committed by László Monda
parent 0aa9c73b4b
commit 94cfd9d2e9

View File

@@ -13,6 +13,7 @@ import {
Module,
NoneAction,
PlayMacroAction,
SwitchKeymapAction,
SwitchLayerAction,
UserConfiguration
} from 'uhk-common';
@@ -143,8 +144,14 @@ export function reducer(state = initialState, action: Action & { payload?: any }
const newKeyAction = keyActionRemap.action;
const newKeymap: Keymap = action.payload.keymap;
const isSwitchLayerAction = newKeyAction instanceof SwitchLayerAction;
const isSwitchKeymapAction = newKeyAction instanceof SwitchKeymapAction;
changedUserConfiguration.keymaps = state.keymaps.map(keymap => {
// SwitchKeymapAction not allow to refer to itself
if (isSwitchKeymapAction && keymap.abbreviation === newKeyAction.keymapAbbreviation) {
return keymap;
}
if (keyActionRemap.remapOnAllKeymap || keymap.abbreviation === newKeymap.abbreviation) {
keymap = new Keymap(keymap);