summaryrefslogtreecommitdiff
path: root/src/config/funcs.ts
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-04-02 22:12:06 +1100
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-04-02 22:12:06 +1100
commit579070733cf9605e96f045158ba56dcc5a9fdb80 (patch)
tree609af68ebfa294c5cb25822a9074dcbb3e93af0e /src/config/funcs.ts
parentnotifpopups: fix clicking opening sidebar (diff)
downloadcaelestia-shell-579070733cf9605e96f045158ba56dcc5a9fdb80.tar.gz
caelestia-shell-579070733cf9605e96f045158ba56dcc5a9fdb80.tar.bz2
caelestia-shell-579070733cf9605e96f045158ba56dcc5a9fdb80.zip
feat: define bar layout via config
Diffstat (limited to 'src/config/funcs.ts')
-rw-r--r--src/config/funcs.ts24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/config/funcs.ts b/src/config/funcs.ts
index 253164e..5b9efa4 100644
--- a/src/config/funcs.ts
+++ b/src/config/funcs.ts
@@ -25,16 +25,20 @@ const isCorrectType = (v: any, type: string | string[] | number[], path: string)
try {
// Recursively check type
const type = JSON.parse(arrType);
- const valid = v.filter((item, i) =>
- Object.entries(type).some(([k, t]) => {
- if (!item[k]) {
- console.warn(`Invalid shape for ${path}[${i}]: ${JSON.stringify(item)} != ${arrType}`);
- return false;
- }
- return !isCorrectType(item[k], t as any, `${path}[${i}].${k}`);
- })
- );
- v.splice(0, v.length, ...valid); // In-place filter
+ if (Array.isArray(type)) {
+ v.splice(0, v.length, ...v.filter((item, i) => isCorrectType(item, type, `${path}[${i}]`)));
+ } else {
+ const valid = v.filter((item, i) =>
+ Object.entries(type).some(([k, t]) => {
+ if (!item[k]) {
+ console.warn(`Invalid shape for ${path}[${i}]: ${JSON.stringify(item)} != ${arrType}`);
+ return false;
+ }
+ return !isCorrectType(item[k], t as any, `${path}[${i}].${k}`);
+ })
+ );
+ v.splice(0, v.length, ...valid); // In-place filter
+ }
} catch {
const valid = v.filter((item, i) => {
if (typeof item !== arrType) {