From 15d44acf9362d2ab0f7d2b9cf2ba754de766b42f Mon Sep 17 00:00:00 2001 From: Robonau <30987265+Robonau@users.noreply.github> Date: Mon, 11 Nov 2024 20:42:38 +0000 Subject: [PATCH] make it work with less than 4 fields --- src/widgets/suwayomi/component.jsx | 6 ++++-- src/widgets/suwayomi/proxy.js | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/widgets/suwayomi/component.jsx b/src/widgets/suwayomi/component.jsx index cda447578..e9965b924 100644 --- a/src/widgets/suwayomi/component.jsx +++ b/src/widgets/suwayomi/component.jsx @@ -10,7 +10,7 @@ export default function Component({ service }) { /** @type {{widget: { fields: string[] }}} */ const { widget } = service; - /** @type { { data: { label: string, count: number }[], error: unknown }} */ + /** @type { { data: { label: string, count: number }[], error: unk }} */ const { data: suwayomiData, error: suwayomiError } = useWidgetAPI(widget); if (suwayomiError) { @@ -18,7 +18,9 @@ export default function Component({ service }) { } if (!suwayomiData) { - widget.fields.length = 4; + if (widget.fields.length > 4) { + widget.fields.length = 4; + } return ( {widget.fields.map((Field) => { diff --git a/src/widgets/suwayomi/proxy.js b/src/widgets/suwayomi/proxy.js index 274735227..2d25438d8 100644 --- a/src/widgets/suwayomi/proxy.js +++ b/src/widgets/suwayomi/proxy.js @@ -181,7 +181,9 @@ function makeFields(Fields) { if (fields.length === 0) { fields = ["download", "nondownload", "read", "unread"]; } - fields.length = 4; + if (fields.length > 4) { + fields.length = 4; + } fields = fields.map((f) => f.toLowerCase()); return fields;