make it work with less than 4 fields
This commit is contained in:
parent
2893667a08
commit
15d44acf93
@ -10,7 +10,7 @@ export default function Component({ service }) {
|
|||||||
/** @type {{widget: { fields: string[] }}} */
|
/** @type {{widget: { fields: string[] }}} */
|
||||||
const { widget } = service;
|
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);
|
const { data: suwayomiData, error: suwayomiError } = useWidgetAPI(widget);
|
||||||
|
|
||||||
if (suwayomiError) {
|
if (suwayomiError) {
|
||||||
@ -18,7 +18,9 @@ export default function Component({ service }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!suwayomiData) {
|
if (!suwayomiData) {
|
||||||
widget.fields.length = 4;
|
if (widget.fields.length > 4) {
|
||||||
|
widget.fields.length = 4;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
{widget.fields.map((Field) => {
|
{widget.fields.map((Field) => {
|
||||||
|
|||||||
@ -181,7 +181,9 @@ function makeFields(Fields) {
|
|||||||
if (fields.length === 0) {
|
if (fields.length === 0) {
|
||||||
fields = ["download", "nondownload", "read", "unread"];
|
fields = ["download", "nondownload", "read", "unread"];
|
||||||
}
|
}
|
||||||
fields.length = 4;
|
if (fields.length > 4) {
|
||||||
|
fields.length = 4;
|
||||||
|
}
|
||||||
fields = fields.map((f) => f.toLowerCase());
|
fields = fields.map((f) => f.toLowerCase());
|
||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user