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 = ({
135135 subscribers [ key ] . pollingInterval ! ,
136136 lowestPollingInterval
137137 )
138- skipPollOnFocusLost = subscribers [ key ] . skipPollOnFocusLost
138+ skipPollOnFocusLost =
139+ subscribers [ key ] . skipPollOnFocusLost || skipPollOnFocusLost
139140 }
140141 }
141142
Original file line number Diff line number Diff line change @@ -157,7 +157,7 @@ describe('polling tests', () => {
157157 storeRef . store . dispatch ( api . util . resetApiState ( ) )
158158 } )
159159
160- it ( 'respects skipPollOnFocusLost of the most recent mounted subscription' , async ( ) => {
160+ it ( 'respects skipPollOnFocusLost if at least one subscription has it ' , async ( ) => {
161161 storeRef . store . dispatch (
162162 getPosts . initiate ( 3 , {
163163 subscriptionOptions : {
@@ -169,7 +169,7 @@ describe('polling tests', () => {
169169 )
170170
171171 await delay ( 50 )
172- const callsWithSkip = mockBaseQuery . mock . calls . length
172+ const callsWithoutSkip = mockBaseQuery . mock . calls . length
173173
174174 storeRef . store . dispatch (
175175 getPosts . initiate ( 3 , {
@@ -178,13 +178,23 @@ describe('polling tests', () => {
178178 } )
179179 )
180180
181+ storeRef . store . dispatch (
182+ getPosts . initiate ( 3 , {
183+ subscriptionOptions : {
184+ pollingInterval : 20 ,
185+ skipPollOnFocusLost : false ,
186+ } ,
187+ subscribe : true ,
188+ } )
189+ )
190+
181191 storeRef . store . dispatch ( api . internalActions ?. onFocusLost ( ) )
182192
183193 await delay ( 50 )
184- const callsWithoutSkip = mockBaseQuery . mock . calls . length
194+ const callsWithSkip = mockBaseQuery . mock . calls . length
185195
186- expect ( callsWithSkip ) . toBeGreaterThan ( 2 )
187- expect ( callsWithoutSkip ) . toBe ( callsWithSkip + 1 )
196+ expect ( callsWithoutSkip ) . toBeGreaterThan ( 2 )
197+ expect ( callsWithSkip ) . toBe ( callsWithoutSkip + 1 )
188198 } )
189199
190200 it ( 'replaces skipPollOnFocusLost when the subscription options are updated' , async ( ) => {
You can’t perform that action at this time.
0 commit comments