Skip to content

Commit

Permalink
Fix mutation of baseButtonMappings values that is being used in setti…
Browse files Browse the repository at this point in the history
…ngs page
  • Loading branch information
Pelsin committed Apr 7, 2024
1 parent 6308ccd commit f4f0b88
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions www/src/Services/WebApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,11 +438,13 @@ async function getAddonsOptions(setLoading) {
const data = response.data;
setLoading(false);

let mappings = { ...baseButtonMappings };
for (let prop of Object.keys(data.keyboardHostMap))
mappings[prop].key = parseInt(data.keyboardHostMap[prop]);
data.keyboardHostMap = mappings;
return data;
// Merge saved keyMappings with defaults
const keyboardHostMap = Object.entries(data.keyboardHostMap).reduce(
(acc, [key, value]) => ({ ...acc, [key]: { ...acc[key], key: value } }),
baseButtonMappings,
);

return { ...data, keyboardHostMap };
} catch (error) {
setLoading(false);
console.error(error);
Expand Down

0 comments on commit f4f0b88

Please sign in to comment.