Minor cleanup
This commit is contained in:
parent
3436f1824f
commit
ffcb8c6563
@ -4,7 +4,8 @@ import Container from "components/services/widget/container";
|
|||||||
import Block from "components/services/widget/block";
|
import Block from "components/services/widget/block";
|
||||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
|
|
||||||
export const rommDefaultFields = ["platforms", "totalRoms", "saves", "states"];
|
const ROMM_DEFAULT_FIELDS = ["platforms", "totalRoms", "saves", "states"];
|
||||||
|
const MAX_ALLOWED_FIELDS = 4;
|
||||||
|
|
||||||
export default function Component({ service }) {
|
export default function Component({ service }) {
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
@ -15,12 +16,9 @@ export default function Component({ service }) {
|
|||||||
return <Container service={service} error={responseError} />;
|
return <Container service={service} error={responseError} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default fields
|
|
||||||
if (!widget.fields?.length > 0) {
|
if (!widget.fields?.length > 0) {
|
||||||
widget.fields = rommDefaultFields;
|
widget.fields = ROMM_DEFAULT_FIELDS;
|
||||||
}
|
} else if (widget.fields.length > MAX_ALLOWED_FIELDS) {
|
||||||
const MAX_ALLOWED_FIELDS = 4;
|
|
||||||
if (widget.fields?.length > MAX_ALLOWED_FIELDS) {
|
|
||||||
widget.fields = widget.fields.slice(0, MAX_ALLOWED_FIELDS);
|
widget.fields = widget.fields.slice(0, MAX_ALLOWED_FIELDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user