Skip to content

Commit

Permalink
api/focus: Don't bomb out when the firmware does not support keymap.l…
Browse files Browse the repository at this point in the history
…ayerNames

Signed-off-by: Gergely Nagy <[email protected]>
  • Loading branch information
algernon committed Jul 23, 2022
1 parent 25396a9 commit d45e9c4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/api/focus/layernames.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ export default class LayerNames {
}

async _pull(s) {
const data = (await s.request("keymap.layerNames"))
.split(/\n/)
.map((x) => x.split(/^(\d+) /).slice(1));
const data = await s.request("keymap.layerNames");
if (!data) return { storageSize: 0, names: [] };

const storageSize = data.pop()[1].split(/=/).pop();
const storageSize = data
.split(/\n/)
.map((x) => x.split(/^(\d+) /).slice(1))
.pop()[1]
.split(/=/)
.pop();
return {
storageSize: parseInt(storageSize),
names: data.map((x) => x[1]),
Expand Down

0 comments on commit d45e9c4

Please sign in to comment.