added refetch when nudges are not fetched
This commit is contained in:
parent
fcd0bed85f
commit
9c3ba58dff
1 changed files with 5 additions and 0 deletions
|
|
@ -76,6 +76,11 @@ export const useGetNudgesQuery = (
|
||||||
{
|
{
|
||||||
queryKey: ["nudges", chatId, filters, limit, scoreThreshold],
|
queryKey: ["nudges", chatId, filters, limit, scoreThreshold],
|
||||||
queryFn: getNudges,
|
queryFn: getNudges,
|
||||||
|
refetchInterval: (query) => {
|
||||||
|
// If data is empty, refetch every 5 seconds
|
||||||
|
const data = query.state.data;
|
||||||
|
return Array.isArray(data) && data.length === 0 ? 5000 : false;
|
||||||
|
},
|
||||||
...options,
|
...options,
|
||||||
},
|
},
|
||||||
queryClient,
|
queryClient,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue