refetch only when window is active

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-07-24 22:45:48 +02:00
parent 1405acc4f6
commit 0e361c1c52
2 changed files with 24 additions and 15 deletions

View File

@@ -15,10 +15,12 @@ const RealtimeReloader = ({ projectId }: Props) => {
useWS<number>(
`/live/events/${projectId}`,
() => {
router.refresh();
client.refetchQueries({
type: 'active',
});
if (!document.hidden) {
router.refresh();
client.refetchQueries({
type: 'active',
});
}
},
{
debounce: {