Moved background queue invocation into `BootstrapFrontend`
authorAlexander Ebert <ebert@woltlab.com>
Thu, 9 Jul 2015 16:51:36 +0000 (18:51 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 9 Jul 2015 16:51:36 +0000 (18:51 +0200)
com.woltlab.wcf/templates/headIncludeJavaScript.tpl
wcfsetup/install/files/js/WoltLab/WCF/BootstrapFrontend.js

index 31d878d4c5b0b2a9c477a54074a12e226528f562..7c73cbe892a86acbc4806343191067eda956a8cf 100644 (file)
@@ -102,6 +102,7 @@ requirejs.config({
                });
                
                BootstrapFrontend.setup({
+                       backgroundQueueUrl: '{link controller="BackgroundQueuePerform"}{/link}',
                        styleChanger: {if $__wcf->getStyleHandler()->countStyles() > 1}true{else}false{/if}
                });
        });
@@ -193,18 +194,6 @@ requirejs.config({
                        });
                {/if}
                
-               {* invoke background queue roughly every 10th request *}
-               if (Math.random() < 0.1) {
-                       require(['Ajax'], function(Ajax) {
-                               // fire and forget background queue perform task
-                               Ajax.apiOnce({
-                                       url: '{link controller="BackgroundQueuePerform"}{/link}',
-                                       ignoreError: true,
-                                       silent: true
-                               });
-                       });
-               }
-               
                {if $__sessionKeepAlive|isset}
                        new WCF.System.KeepAlive({@$__sessionKeepAlive});
                {/if}
index b223f21115a21b051dde3f1b0a0a3d7c01ff50e5..c1784db8da3aac058b2541c32589806fb33f28d0 100644 (file)
@@ -37,6 +37,7 @@ define(
                        }
                        
                        this._initUserPopover();
+                       this._invokeBackgroundQueue(options.backgroundQueueUrl);
                },
                
                /**
@@ -59,6 +60,22 @@ define(
                                        }, callback, callback);
                                }
                        });
+               },
+               
+               /**
+                * Invokes the background queue roughly every 10th request.
+                * 
+                * @param       {string}        url     background queue url
+                */
+               _invokeBackgroundQueue: function(url) {
+                       if (Math.random() < 0.1) {
+                               // 'fire and forget' background queue perform task
+                               Ajax.apiOnce({
+                                       url: url,
+                                       ignoreError: true,
+                                       silent: true
+                               });
+                       }
                }
        };