File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed
packages/toolkit/src/query Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -135,7 +135,8 @@ export const buildPollingHandler: InternalHandlerBuilder = ({
135
135
subscribers [ key ] . pollingInterval ! ,
136
136
lowestPollingInterval
137
137
)
138
- skipPollOnFocusLost = subscribers [ key ] . skipPollOnFocusLost
138
+ skipPollOnFocusLost =
139
+ subscribers [ key ] . skipPollOnFocusLost || skipPollOnFocusLost
139
140
}
140
141
}
141
142
Original file line number Diff line number Diff line change @@ -157,7 +157,7 @@ describe('polling tests', () => {
157
157
storeRef . store . dispatch ( api . util . resetApiState ( ) )
158
158
} )
159
159
160
- it ( 'respects skipPollOnFocusLost of the most recent mounted subscription' , async ( ) => {
160
+ it ( 'respects skipPollOnFocusLost if at least one subscription has it ' , async ( ) => {
161
161
storeRef . store . dispatch (
162
162
getPosts . initiate ( 3 , {
163
163
subscriptionOptions : {
@@ -169,7 +169,7 @@ describe('polling tests', () => {
169
169
)
170
170
171
171
await delay ( 50 )
172
- const callsWithSkip = mockBaseQuery . mock . calls . length
172
+ const callsWithoutSkip = mockBaseQuery . mock . calls . length
173
173
174
174
storeRef . store . dispatch (
175
175
getPosts . initiate ( 3 , {
@@ -178,13 +178,23 @@ describe('polling tests', () => {
178
178
} )
179
179
)
180
180
181
+ storeRef . store . dispatch (
182
+ getPosts . initiate ( 3 , {
183
+ subscriptionOptions : {
184
+ pollingInterval : 20 ,
185
+ skipPollOnFocusLost : false ,
186
+ } ,
187
+ subscribe : true ,
188
+ } )
189
+ )
190
+
181
191
storeRef . store . dispatch ( api . internalActions ?. onFocusLost ( ) )
182
192
183
193
await delay ( 50 )
184
- const callsWithoutSkip = mockBaseQuery . mock . calls . length
194
+ const callsWithSkip = mockBaseQuery . mock . calls . length
185
195
186
- expect ( callsWithSkip ) . toBeGreaterThan ( 2 )
187
- expect ( callsWithoutSkip ) . toBe ( callsWithSkip + 1 )
196
+ expect ( callsWithoutSkip ) . toBeGreaterThan ( 2 )
197
+ expect ( callsWithSkip ) . toBe ( callsWithoutSkip + 1 )
188
198
} )
189
199
190
200
it ( 'replaces skipPollOnFocusLost when the subscription options are updated' , async ( ) => {
You can’t perform that action at this time.
0 commit comments