mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-07 09:35:54 -08:00
make it work with less than 4 fields
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user