mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 07:25:48 +01:00
Add option to manually edit the refresh interval
This commit is contained in:
@@ -7,14 +7,17 @@
|
|||||||
"rssFeedUrl": {
|
"rssFeedUrl": {
|
||||||
"label": "RSS feeds urls",
|
"label": "RSS feeds urls",
|
||||||
"description": "The urls of the RSS feeds you want to display from."
|
"description": "The urls of the RSS feeds you want to display from."
|
||||||
|
},
|
||||||
|
"refreshInterval": {
|
||||||
|
"label": "Refresh interval (in seconds)"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
"card": {
|
||||||
"card": {
|
"errors": {
|
||||||
"errors": {
|
"general": {
|
||||||
"general": {
|
"title": "Unable to retrieve RSS feed",
|
||||||
"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."
|
||||||
"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."
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ const WidgetOptionTypeSwitch: FC<{
|
|||||||
case 'slider':
|
case 'slider':
|
||||||
return (
|
return (
|
||||||
<Stack spacing="xs">
|
<Stack spacing="xs">
|
||||||
|
<Text>{t(`descriptor.settings.${key}.label`)}</Text>
|
||||||
<Slider
|
<Slider
|
||||||
color={primaryColor}
|
color={primaryColor}
|
||||||
label={value}
|
label={value}
|
||||||
|
|||||||
@@ -32,6 +32,13 @@ const definition = defineWidget({
|
|||||||
type: 'multiple-text',
|
type: 'multiple-text',
|
||||||
defaultValue: ['https://github.com/ajnart/homarr/tags.atom'],
|
defaultValue: ['https://github.com/ajnart/homarr/tags.atom'],
|
||||||
},
|
},
|
||||||
|
refreshInterval: {
|
||||||
|
type: 'slider',
|
||||||
|
defaultValue: 60,
|
||||||
|
min: 30,
|
||||||
|
max: 300,
|
||||||
|
step: 30,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
gridstack: {
|
gridstack: {
|
||||||
minWidth: 2,
|
minWidth: 2,
|
||||||
@@ -48,11 +55,12 @@ interface RssTileProps {
|
|||||||
widget: IRssWidget;
|
widget: IRssWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useGetRssFeeds = (feedUrls: string[], widgetId: string) =>
|
export const useGetRssFeeds = (feedUrls: string[], refreshInterval: number, widgetId: string) =>
|
||||||
useQuery({
|
useQuery({
|
||||||
queryKey: ['rss-feeds', feedUrls],
|
queryKey: ['rss-feeds', feedUrls],
|
||||||
// Cache the results for 24 hours
|
// Cache the results for 24 hours
|
||||||
cacheTime: 1000 * 60 * 60 * 24,
|
cacheTime: 1000 * 60 * 60 * 24,
|
||||||
|
staleTime: 1000 * refreshInterval,
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const responses = await Promise.all(
|
const responses = await Promise.all(
|
||||||
feedUrls.map((feedUrl) =>
|
feedUrls.map((feedUrl) =>
|
||||||
@@ -69,6 +77,7 @@ function RssTile({ widget }: RssTileProps) {
|
|||||||
const { t } = useTranslation('modules/rss');
|
const { t } = useTranslation('modules/rss');
|
||||||
const { data, isLoading, isFetching, isError, refetch } = useGetRssFeeds(
|
const { data, isLoading, isFetching, isError, refetch } = useGetRssFeeds(
|
||||||
widget.properties.rssFeedUrl,
|
widget.properties.rssFeedUrl,
|
||||||
|
widget.properties.refreshInterval,
|
||||||
widget.id
|
widget.id
|
||||||
);
|
);
|
||||||
const { classes } = useStyles();
|
const { classes } = useStyles();
|
||||||
|
|||||||
Reference in New Issue
Block a user