@@ -53,38 +53,36 @@ export const buildPollingHandler: InternalHandlerBuilder = ({
53
53
{ queryCacheKey } : QuerySubstateIdentifier ,
54
54
api : SubMiddlewareApi
55
55
) {
56
- const state = api . getState ( ) [ reducerPath ] ;
57
- const querySubState = state . queries [ queryCacheKey ] ;
58
- const subscriptions = internalState . currentSubscriptions [ queryCacheKey ] ;
56
+ const state = api . getState ( ) [ reducerPath ]
57
+ const querySubState = state . queries [ queryCacheKey ]
58
+ const subscriptions = internalState . currentSubscriptions [ queryCacheKey ]
59
59
60
60
if ( ! querySubState || querySubState . status === QueryStatus . uninitialized )
61
- return ;
61
+ return
62
62
63
- const { lowestPollingInterval, skipPollOnFocusLost } = findLowestPollingInterval ( subscriptions ) ;
64
- if ( ! Number . isFinite ( lowestPollingInterval ) ) return ;
63
+ const { lowestPollingInterval, skipPollOnFocusLost } =
64
+ findLowestPollingInterval ( subscriptions )
65
+ if ( ! Number . isFinite ( lowestPollingInterval ) ) return
65
66
66
- const currentPoll = currentPolls [ queryCacheKey ] ;
67
+ const currentPoll = currentPolls [ queryCacheKey ]
67
68
68
69
if ( currentPoll ?. timeout ) {
69
- clearTimeout ( currentPoll . timeout ) ;
70
- currentPoll . timeout = undefined ;
70
+ clearTimeout ( currentPoll . timeout )
71
+ currentPoll . timeout = undefined
71
72
}
72
73
73
- const nextPollTimestamp = Date . now ( ) + lowestPollingInterval ;
74
+ const nextPollTimestamp = Date . now ( ) + lowestPollingInterval
74
75
75
- // Always update the polling interval
76
76
currentPolls [ queryCacheKey ] = {
77
77
nextPollTimestamp,
78
78
pollingInterval : lowestPollingInterval ,
79
79
timeout : setTimeout ( ( ) => {
80
- // Conditionally dispatch the query
81
80
if ( document . hasFocus ( ) || ! skipPollOnFocusLost ) {
82
- api . dispatch ( refetchQuery ( querySubState , queryCacheKey ) ) ;
81
+ api . dispatch ( refetchQuery ( querySubState , queryCacheKey ) )
83
82
}
84
- // Regardless of dispatch, set up the next poll
85
- startNextPoll ( { queryCacheKey } , api ) ;
83
+ startNextPoll ( { queryCacheKey } , api )
86
84
} , lowestPollingInterval ) ,
87
- } ;
85
+ }
88
86
}
89
87
90
88
function updatePollingInterval (
0 commit comments