From 4abdac1ef695913ed4edf4010b0ec6373ea47e85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Kiss?= Date: Thu, 18 Apr 2019 01:58:16 +0200 Subject: [PATCH] fix: delete LayerSwitcher on the dest layer when LayerSwitcher remove/changing (#939) --- packages/uhk-web/src/app/store/reducers/user-configuration.ts | 4 ++++ 1 file changed, 4 insertions(+) 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 8f692b0c..512fabf8 100644 --- a/packages/uhk-web/src/app/store/reducers/user-configuration.ts +++ b/packages/uhk-web/src/app/store/reducers/user-configuration.ts @@ -195,6 +195,8 @@ export function reducer( const newKeymap: Keymap = payload.keymap; const isSwitchLayerAction = newKeyAction instanceof SwitchLayerAction; const isSwitchKeymapAction = newKeyAction instanceof SwitchKeymapAction; + const oldKeyAction = newKeymap.layers[layerIndex].modules[moduleIndex].keyActions[keyIndex]; + const oldKeyIsSwitchLayerAction = oldKeyAction instanceof SwitchLayerAction; const userConfiguration: UserConfiguration = Object.assign(new UserConfiguration(), state.userConfiguration); userConfiguration.keymaps = state.userConfiguration.keymaps.map(keymap => { @@ -222,6 +224,8 @@ export function reducer( } else { setKeyActionToLayer(layer, moduleIndex, keyIndex, clonedAction); } + } else if (oldKeyIsSwitchLayerAction && index - 1 === (oldKeyAction as SwitchLayerAction).layer) { + setKeyActionToLayer(layer, moduleIndex, keyIndex, null); } return layer;