From: Alexander Ebert Date: Thu, 9 Jul 2015 16:51:36 +0000 (+0200) Subject: Moved background queue invocation into `BootstrapFrontend` X-Git-Tag: 3.0.0_Beta_1~2198 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a784f34c5216b523caaad7196a3d2aee4b60fe4e;p=GitHub%2FWoltLab%2FWCF.git Moved background queue invocation into `BootstrapFrontend` --- diff --git a/com.woltlab.wcf/templates/headIncludeJavaScript.tpl b/com.woltlab.wcf/templates/headIncludeJavaScript.tpl index 31d878d4c5..7c73cbe892 100644 --- a/com.woltlab.wcf/templates/headIncludeJavaScript.tpl +++ b/com.woltlab.wcf/templates/headIncludeJavaScript.tpl @@ -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} diff --git a/wcfsetup/install/files/js/WoltLab/WCF/BootstrapFrontend.js b/wcfsetup/install/files/js/WoltLab/WCF/BootstrapFrontend.js index b223f21115..c1784db8da 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/BootstrapFrontend.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/BootstrapFrontend.js @@ -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 + }); + } } };