diff --git a/public/locales/en/modules/rss.json b/public/locales/en/modules/rss.json index 47d6e405d..56a751750 100644 --- a/public/locales/en/modules/rss.json +++ b/public/locales/en/modules/rss.json @@ -7,14 +7,17 @@ "rssFeedUrl": { "label": "RSS feeds urls", "description": "The urls of the RSS feeds you want to display from." + }, + "refreshInterval": { + "label": "Refresh interval (in seconds)" } - } - }, - "card": { - "errors": { - "general": { - "title": "Unable to retrieve RSS feed", - "text": "There was a problem reaching out the RSS feed. Make sure that you have correctly configured the RSS feed using a valid URL. URLs should match the official specification. After updating the feed, you may need to refresh the dashboard." + }, + "card": { + "errors": { + "general": { + "title": "Unable to retrieve RSS feed", + "text": "There was a problem reaching out the RSS feed. Make sure that you have correctly configured the RSS feed using a valid URL. URLs should match the official specification. After updating the feed, you may need to refresh the dashboard." + } } } } diff --git a/src/components/Dashboard/Tiles/Widgets/WidgetsEditModal.tsx b/src/components/Dashboard/Tiles/Widgets/WidgetsEditModal.tsx index 643a8b64b..805b7f805 100644 --- a/src/components/Dashboard/Tiles/Widgets/WidgetsEditModal.tsx +++ b/src/components/Dashboard/Tiles/Widgets/WidgetsEditModal.tsx @@ -184,6 +184,7 @@ const WidgetOptionTypeSwitch: FC<{ case 'slider': return ( + {t(`descriptor.settings.${key}.label`)} +export const useGetRssFeeds = (feedUrls: string[], refreshInterval: number, widgetId: string) => useQuery({ queryKey: ['rss-feeds', feedUrls], // Cache the results for 24 hours cacheTime: 1000 * 60 * 60 * 24, + staleTime: 1000 * refreshInterval, queryFn: async () => { const responses = await Promise.all( feedUrls.map((feedUrl) => @@ -69,6 +77,7 @@ function RssTile({ widget }: RssTileProps) { const { t } = useTranslation('modules/rss'); const { data, isLoading, isFetching, isError, refetch } = useGetRssFeeds( widget.properties.rssFeedUrl, + widget.properties.refreshInterval, widget.id ); const { classes } = useStyles();