Minor cleanup

This commit is contained in:
shamoon
2024-08-23 19:27:27 -07:00
parent 3436f1824f
commit ffcb8c6563

View File

@@ -4,7 +4,8 @@ import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
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 }) {
const { widget } = service;
@@ -15,12 +16,9 @@ export default function Component({ service }) {
return <Container service={service} error={responseError} />;
}
// Default fields
if (!widget.fields?.length > 0) {
widget.fields = rommDefaultFields;
}
const MAX_ALLOWED_FIELDS = 4;
if (widget.fields?.length > MAX_ALLOWED_FIELDS) {
widget.fields = ROMM_DEFAULT_FIELDS;
} else if (widget.fields.length > MAX_ALLOWED_FIELDS) {
widget.fields = widget.fields.slice(0, MAX_ALLOWED_FIELDS);
}