From ac86a08a53af299821ac5d45dff2cf7decb086b9 Mon Sep 17 00:00:00 2001 From: InsertDisc <31751462+InsertDisc@users.noreply.github.com> Date: Fri, 23 Aug 2024 20:59:42 -0400 Subject: [PATCH 1/4] Update component.jsx Add field limiting logic. Cleaned up response error that is returned. Refactor size returned to use 'common.bytes' to avoid predefined calculations. --- src/widgets/romm/component.jsx | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/widgets/romm/component.jsx b/src/widgets/romm/component.jsx index 94be30d1d..9f095cbec 100644 --- a/src/widgets/romm/component.jsx +++ b/src/widgets/romm/component.jsx @@ -4,20 +4,26 @@ 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", "roms", "saves", "states"]; + export default function Component({ service }) { const { widget } = service; const { t } = useTranslation(); - const { data: response, error: responseError } = useWidgetAPI(widget, "statistics"); if (responseError) { - return ( - - - - ); + return ; } + // Default fields + if (!widget.fields?.length > 0) { + widget.fields = rommDefaultFields; + } + const MAX_ALLOWED_FIELDS = 4; + if (widget.fields?.length > MAX_ALLOWED_FIELDS) { + widget.fields = widget.fields.slice(0, MAX_ALLOWED_FIELDS); + } + if (!response) { return ( @@ -32,8 +38,6 @@ export default function Component({ service }) { } if (response) { - const totalFilesizeGB = (response.FILESIZE / 1024 ** 3).toFixed(2); - return ( @@ -41,7 +45,7 @@ export default function Component({ service }) { - + ); } From 48af44856091d959bdc0bb19634512ef6687fcc4 Mon Sep 17 00:00:00 2001 From: InsertDisc <31751462+InsertDisc@users.noreply.github.com> Date: Fri, 23 Aug 2024 21:02:57 -0400 Subject: [PATCH 2/4] Update romm.md Updated documentation to clarify how fields are handled. --- docs/widgets/services/romm.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/widgets/services/romm.md b/docs/widgets/services/romm.md index 6d8bc8b30..b4799171b 100644 --- a/docs/widgets/services/romm.md +++ b/docs/widgets/services/romm.md @@ -4,12 +4,12 @@ description: Romm Widget Configuration --- Allowed fields: `["platforms", "roms", "saves", "states", "screenshots", "totalfilesize"]`. - +If more than (4) fields are provided, only the first (4) will be used. ```yaml widget: type: romm url: http://romm.host.or.ip username: username # optional password: password # optional - fields: ["platforms", "roms", "saves", "screenshots"] + fields: ["platforms", "roms", "saves", "states"] # optional - default fields shown ``` From fb026eef936784f26d6131f727ec96d09b7bc35a Mon Sep 17 00:00:00 2001 From: InsertDisc <31751462+InsertDisc@users.noreply.github.com> Date: Fri, 23 Aug 2024 21:50:30 -0400 Subject: [PATCH 3/4] Update romm.md Add additional empty line according to lint --- docs/widgets/services/romm.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/widgets/services/romm.md b/docs/widgets/services/romm.md index b4799171b..cf10d09b8 100644 --- a/docs/widgets/services/romm.md +++ b/docs/widgets/services/romm.md @@ -5,6 +5,7 @@ description: Romm Widget Configuration Allowed fields: `["platforms", "roms", "saves", "states", "screenshots", "totalfilesize"]`. If more than (4) fields are provided, only the first (4) will be used. + ```yaml widget: type: romm From 72b7312a0923709a1dd0731a8219e5748c585545 Mon Sep 17 00:00:00 2001 From: InsertDisc <31751462+InsertDisc@users.noreply.github.com> Date: Fri, 23 Aug 2024 21:53:17 -0400 Subject: [PATCH 4/4] Update component.jsx Remove empty whitespace according to lint --- src/widgets/romm/component.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/romm/component.jsx b/src/widgets/romm/component.jsx index 9f095cbec..a9df14230 100644 --- a/src/widgets/romm/component.jsx +++ b/src/widgets/romm/component.jsx @@ -23,7 +23,7 @@ export default function Component({ service }) { if (widget.fields?.length > MAX_ALLOWED_FIELDS) { widget.fields = widget.fields.slice(0, MAX_ALLOWED_FIELDS); } - + if (!response) { return (