diff --git a/moodle.config.json b/moodle.config.json index 99348b609..7896c81ce 100644 --- a/moodle.config.json +++ b/moodle.config.json @@ -97,5 +97,7 @@ "appstores": { "android": "com.moodle.moodlemobile", "ios": "id633359593" - } + }, + "wsrequestqueuelimit": 10, + "wsrequestqueuedelay": 50 } diff --git a/src/core/classes/site.ts b/src/core/classes/site.ts index 5dac39fee..7b03c32bf 100644 --- a/src/core/classes/site.ts +++ b/src/core/classes/site.ts @@ -66,8 +66,6 @@ const ALLOWED_LOGGEDOUT_WS = [ */ export class CoreSite { - static readonly REQUEST_QUEUE_DELAY = 50; // Maximum number of miliseconds to wait before processing the queue. - static readonly REQUEST_QUEUE_LIMIT = 10; // Maximum number of requests allowed in the queue. static readonly REQUEST_QUEUE_FORCE_WS = false; // Use "tool_mobile_call_external_functions" even for calling a single function. // Constants for cache update frequency. @@ -756,10 +754,13 @@ export class CoreSite { protected enqueueRequest(request: RequestQueueItem): Promise { this.requestQueue.push(request); - if (this.requestQueue.length >= CoreSite.REQUEST_QUEUE_LIMIT) { + if (this.requestQueue.length >= CoreConstants.CONFIG.wsrequestqueuelimit) { this.processRequestQueue(); } else if (!this.requestQueueTimeout) { - this.requestQueueTimeout = window.setTimeout(this.processRequestQueue.bind(this), CoreSite.REQUEST_QUEUE_DELAY); + this.requestQueueTimeout = window.setTimeout( + this.processRequestQueue.bind(this), + CoreConstants.CONFIG.wsrequestqueuedelay, + ); } return request.deferred.promise; diff --git a/src/types/config.d.ts b/src/types/config.d.ts index 14b0b5a51..c5df37dcd 100644 --- a/src/types/config.d.ts +++ b/src/types/config.d.ts @@ -58,4 +58,6 @@ export interface EnvironmentConfig { feedbackFormUrl?: string | false; a11yStatement?: string | false; iabToolbarColors?: 'auto' | { background: string; text?: string } | null; + wsrequestqueuelimit: number; // Maximum number of requests allowed in the queue. + wsrequestqueuedelay: number; // Maximum number of miliseconds to wait before processing the queue. }