From 6295a2e0f57235366615d4a1afde14cb505c1ea1 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sat, 23 Jul 2022 09:11:25 +0200 Subject: [PATCH] api/focus: Fix the layer name parsing, again The previous change made Chrysalis not error out when there were no layer names present, but it also broke the name parsing when there were. With this change, we handle both cases appropriately. Signed-off-by: Gergely Nagy --- src/api/focus/layernames.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/api/focus/layernames.js b/src/api/focus/layernames.js index 864746dbe..991c71f52 100644 --- a/src/api/focus/layernames.js +++ b/src/api/focus/layernames.js @@ -29,15 +29,11 @@ export default class LayerNames { const data = await s.request("keymap.layerNames"); if (!data) return { storageSize: 0, names: [] }; - const storageSize = data - .split(/\n/) - .map((x) => x.split(/^(\d+) /).slice(1)) - .pop()[1] - .split(/=/) - .pop(); + const names = data.split(/\n/).map((x) => x.split(/^(\d+) /).slice(1)); + const storageSize = names.pop()[1].split(/=/).pop(); return { storageSize: parseInt(storageSize), - names: data.map((x) => x[1]), + names: names.map((x) => x[1]), }; }