fix: SwitchKeymapAction not allow to refer to itself (#694)
This commit is contained in:
committed by
László Monda
parent
0aa9c73b4b
commit
94cfd9d2e9
@@ -13,6 +13,7 @@ import {
|
|||||||
Module,
|
Module,
|
||||||
NoneAction,
|
NoneAction,
|
||||||
PlayMacroAction,
|
PlayMacroAction,
|
||||||
|
SwitchKeymapAction,
|
||||||
SwitchLayerAction,
|
SwitchLayerAction,
|
||||||
UserConfiguration
|
UserConfiguration
|
||||||
} from 'uhk-common';
|
} from 'uhk-common';
|
||||||
@@ -143,8 +144,14 @@ export function reducer(state = initialState, action: Action & { payload?: any }
|
|||||||
const newKeyAction = keyActionRemap.action;
|
const newKeyAction = keyActionRemap.action;
|
||||||
const newKeymap: Keymap = action.payload.keymap;
|
const newKeymap: Keymap = action.payload.keymap;
|
||||||
const isSwitchLayerAction = newKeyAction instanceof SwitchLayerAction;
|
const isSwitchLayerAction = newKeyAction instanceof SwitchLayerAction;
|
||||||
|
const isSwitchKeymapAction = newKeyAction instanceof SwitchKeymapAction;
|
||||||
|
|
||||||
changedUserConfiguration.keymaps = state.keymaps.map(keymap => {
|
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) {
|
if (keyActionRemap.remapOnAllKeymap || keymap.abbreviation === newKeymap.abbreviation) {
|
||||||
keymap = new Keymap(keymap);
|
keymap = new Keymap(keymap);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user