Skip to content

Commit

Permalink
set configSett.osKeyboardLayout = 'keymap_us' if undefined or invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
precondition committed Aug 23, 2022
1 parent af9118a commit 82cb033
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/store/modules/keycodes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,19 @@ const state = {

function getOSKeyboardLayout() {
const fallbackOSKeyboardLayout = 'keymap_us';
return (
store.state.app.configuratorSettings.osKeyboardLayout ||
fallbackOSKeyboardLayout
);
const osKeyboardLayout =
store.state.app.configuratorSettings.osKeyboardLayout;
if (
isUndefined(osKeyboardLayout) ||
!Object.keys(keymapExtras).includes(osKeyboardLayout)
) {
console.log(
`The stored OS keyboard layout value (${osKeyboardLayout}) is not a valid value! Falling back to '${fallbackOSKeyboardLayout}'.`
);
store.state.app.configuratorSettings.osKeyboardLayout =
fallbackOSKeyboardLayout;
}
return store.state.app.configuratorSettings.osKeyboardLayout;
}

function isANSI() {
Expand Down Expand Up @@ -70,12 +79,6 @@ function generateKeycodes(osKeyboardLayout, isSteno) {
...keycodePickerTabLayout.special,
...(isSteno ? steno : [])
];
if (!Object.keys(keymapExtras).includes(getOSKeyboardLayout())) {
console.log(
`${getOSKeyboardLayout()} is not a valid OS keyboard layout value!`
);
return keycodes;
}
const { keycodeLUT } = keymapExtras[getOSKeyboardLayout()];
return keycodes.map((keycodeObject) =>
toLocaleKeycode(keycodeLUT, keycodeObject)
Expand Down

0 comments on commit 82cb033

Please sign in to comment.