From 762fa6f8bf14d935ca088cbea191105b87f45603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ro=CC=81bert=20Kiss?= Date: Mon, 18 Jun 2018 19:50:34 +0200 Subject: [PATCH] fix: remap SwitchLayerAction --- .../uhk-web/src/app/store/reducers/user-configuration.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/uhk-web/src/app/store/reducers/user-configuration.ts b/packages/uhk-web/src/app/store/reducers/user-configuration.ts index 1f29d066..264d95fa 100644 --- a/packages/uhk-web/src/app/store/reducers/user-configuration.ts +++ b/packages/uhk-web/src/app/store/reducers/user-configuration.ts @@ -142,21 +142,21 @@ export function reducer(state = initialState, action: Action & { payload?: any } const keyActionRemap = action.payload.keyAction; const newKeyAction = keyActionRemap.action; const newKeymap: Keymap = action.payload.keymap; + const isSwitchLayerAction = newKeyAction instanceof SwitchLayerAction; changedUserConfiguration.keymaps = state.keymaps.map(keymap => { if (keyActionRemap.remapOnAllKeymap || keymap.abbreviation === newKeymap.abbreviation) { keymap = new Keymap(keymap); keymap.layers = keymap.layers.map((layer, index) => { - if (keyActionRemap.remapOnAllLayer || index === layerIndex) { + if (keyActionRemap.remapOnAllLayer || index === layerIndex || isSwitchLayerAction) { layer = new Layer(layer); const clonedAction = KeyActionHelper.createKeyAction(newKeyAction); - const isSwitchLayerAction = newKeyAction instanceof SwitchLayerAction; // If the key action is a SwitchLayerAction then set the same SwitchLayerAction // on the target layer and remove SwitchLayerAction from other layers if (isSwitchLayerAction) { - if (index - 1 === (newKeyAction as SwitchLayerAction).layer) { + if (index === 0 || index - 1 === (newKeyAction as SwitchLayerAction).layer) { setKeyActionToLayer(layer, moduleIndex, keyIndex, clonedAction); } else { const actionOnLayer = layer.modules[moduleIndex].keyActions[keyIndex];