From 9d2f1ab8c8449224ab7264c108f4b7e7fcbe4e54 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Thu, 1 Dec 2022 06:36:51 -0800 Subject: [PATCH] Add default interval setting for coinmarketcap --- src/utils/config/service-helpers.js | 2 ++ src/widgets/coinmarketcap/component.jsx | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/config/service-helpers.js b/src/utils/config/service-helpers.js index 15740d22b..e0a9f23f1 100644 --- a/src/utils/config/service-helpers.js +++ b/src/utils/config/service-helpers.js @@ -118,6 +118,7 @@ export function cleanServiceGroups(groups) { container, currency, // coinmarketcap widget symbols, + defaultinterval } = cleanedService.widget; cleanedService.widget = { @@ -129,6 +130,7 @@ export function cleanServiceGroups(groups) { if (currency) cleanedService.widget.currency = currency; if (symbols) cleanedService.widget.symbols = symbols; + if (defaultinterval) cleanedService.widget.defaultinterval = defaultinterval; if (type === "docker") { if (server) cleanedService.widget.server = server; diff --git a/src/widgets/coinmarketcap/component.jsx b/src/widgets/coinmarketcap/component.jsx index 90b91a5ea..180ffe220 100644 --- a/src/widgets/coinmarketcap/component.jsx +++ b/src/widgets/coinmarketcap/component.jsx @@ -17,11 +17,12 @@ export default function Component({ service }) { { label: t("coinmarketcap.30days"), value: "30d" }, ]; - const [dateRange, setDateRange] = useState(dateRangeOptions[0].value); - const { widget } = service; const { symbols } = widget; const currencyCode = widget.currency ?? "USD"; + const interval = widget.defaultinterval ?? dateRangeOptions[0].value; + + const [dateRange, setDateRange] = useState(interval); const { data: statsData, error: statsError } = useWidgetAPI(widget, "v1/cryptocurrency/quotes/latest", { symbol: `${symbols.join(",")}`,