@@ -261,6 +261,32 @@ export class Component {
261261 }
262262 }
263263
264+ /**
265+ * Check to see if the poll is disabled.
266+ */
267+ isPollEnabled ( ) {
268+ if ( ! this . poll . disable ) {
269+ if ( hasValue ( this . poll . disableData ) ) {
270+ if ( this . poll . disableData . startsWith ( "!" ) ) {
271+ // Manually negate this and re-negate it after the check
272+ this . poll . disableData = this . poll . disableData . slice ( 1 ) ;
273+
274+ if ( this . data [ this . poll . disableData ] ) {
275+ return true ;
276+ }
277+
278+ this . poll . disableData = `!${ this . poll . disableData } ` ;
279+ } else if ( ! this . data [ this . poll . disableData ] ) {
280+ return true ;
281+ }
282+ } else {
283+ return true ;
284+ }
285+ }
286+
287+ return false ;
288+ }
289+
264290 /**
265291 * Sets up polling if it is defined on the component's root.
266292 */
@@ -287,12 +313,15 @@ export class Component {
287313
288314 this . poll . partial = rootElement . partial ;
289315
290- // Call the method once before the timer starts
291- this . callMethod (
292- this . poll . method ,
293- this . poll . partial ,
294- this . handlePollError
295- ) ;
316+ if ( this . isPollEnabled ( ) ) {
317+ // Call the method once before the timer starts
318+ this . callMethod (
319+ this . poll . method ,
320+ this . poll . partial ,
321+ this . handlePollError
322+ ) ;
323+ }
324+
296325 this . startPolling ( ) ;
297326 }
298327 }
@@ -302,35 +331,12 @@ export class Component {
302331 */
303332 startPolling ( ) {
304333 this . poll . timer = setInterval ( ( ) => {
305- if ( ! this . poll . disable ) {
306- if ( hasValue ( this . poll . disableData ) ) {
307- if ( this . poll . disableData . startsWith ( "!" ) ) {
308- // Manually negate this and re-negate it after the check
309- this . poll . disableData = this . poll . disableData . slice ( 1 ) ;
310-
311- if ( this . data [ this . poll . disableData ] ) {
312- this . callMethod (
313- this . poll . method ,
314- this . poll . partial ,
315- this . handlePollError
316- ) ;
317- }
318-
319- this . poll . disableData = `!${ this . poll . disableData } ` ;
320- } else if ( ! this . data [ this . poll . disableData ] ) {
321- this . callMethod (
322- this . poll . method ,
323- this . poll . partial ,
324- this . handlePollError
325- ) ;
326- }
327- } else {
328- this . callMethod (
329- this . poll . method ,
330- this . poll . partial ,
331- this . handlePollError
332- ) ;
333- }
334+ if ( this . isPollEnabled ( ) ) {
335+ this . callMethod (
336+ this . poll . method ,
337+ this . poll . partial ,
338+ this . handlePollError
339+ ) ;
334340 }
335341 } , this . poll . timing ) ;
336342 }
0 commit comments