MOBILE-3803 config: Move group WS constants to config file

main
Dani Palou 2021-12-03 14:18:22 +01:00
parent ad6c7367ff
commit 9837e6d3b3
3 changed files with 10 additions and 5 deletions

View File

@ -97,5 +97,7 @@
"appstores": {
"android": "com.moodle.moodlemobile",
"ios": "id633359593"
}
},
"wsrequestqueuelimit": 10,
"wsrequestqueuedelay": 50
}

View File

@ -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<T>(request: RequestQueueItem<T>): Promise<T> {
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;

View File

@ -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.
}