make it work with less than 4 fields

This commit is contained in:
Robonau
2024-11-11 20:42:38 +00:00
committed by shamoon
parent 2893667a08
commit 15d44acf93
2 changed files with 7 additions and 3 deletions

View File

@@ -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 (
<Container service={service}>
{widget.fields.map((Field) => {

View File

@@ -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;