Add option to manually edit the refresh interval

This commit is contained in:
ajnart
2023-04-05 14:53:18 +09:00
parent 9d51e2ce52
commit 31a80f5588
3 changed files with 21 additions and 8 deletions

View File

@@ -32,6 +32,13 @@ const definition = defineWidget({
type: 'multiple-text',
defaultValue: ['https://github.com/ajnart/homarr/tags.atom'],
},
refreshInterval: {
type: 'slider',
defaultValue: 60,
min: 30,
max: 300,
step: 30,
},
},
gridstack: {
minWidth: 2,
@@ -48,11 +55,12 @@ interface RssTileProps {
widget: IRssWidget;
}
export const useGetRssFeeds = (feedUrls: string[], widgetId: string) =>
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();