Merge pull request #3016 from dpalou/MOBILE-3803
MOBILE-3803 config: Move group WS constants to config file
This commit is contained in:
		
						commit
						1a910df6bc
					
				| @ -97,5 +97,7 @@ | |||||||
|     "appstores": { |     "appstores": { | ||||||
|         "android": "com.moodle.moodlemobile", |         "android": "com.moodle.moodlemobile", | ||||||
|         "ios": "id633359593" |         "ios": "id633359593" | ||||||
|     } |     }, | ||||||
|  |     "wsrequestqueuelimit": 10, | ||||||
|  |     "wsrequestqueuedelay": 50 | ||||||
| } | } | ||||||
|  | |||||||
| @ -66,8 +66,6 @@ const ALLOWED_LOGGEDOUT_WS = [ | |||||||
|  */ |  */ | ||||||
| export class CoreSite { | 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.
 |     static readonly REQUEST_QUEUE_FORCE_WS = false; // Use "tool_mobile_call_external_functions" even for calling a single function.
 | ||||||
| 
 | 
 | ||||||
|     // Constants for cache update frequency.
 |     // Constants for cache update frequency.
 | ||||||
| @ -756,10 +754,13 @@ export class CoreSite { | |||||||
|     protected enqueueRequest<T>(request: RequestQueueItem<T>): Promise<T> { |     protected enqueueRequest<T>(request: RequestQueueItem<T>): Promise<T> { | ||||||
|         this.requestQueue.push(request); |         this.requestQueue.push(request); | ||||||
| 
 | 
 | ||||||
|         if (this.requestQueue.length >= CoreSite.REQUEST_QUEUE_LIMIT) { |         if (this.requestQueue.length >= CoreConstants.CONFIG.wsrequestqueuelimit) { | ||||||
|             this.processRequestQueue(); |             this.processRequestQueue(); | ||||||
|         } else if (!this.requestQueueTimeout) { |         } 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; |         return request.deferred.promise; | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								src/types/config.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								src/types/config.d.ts
									
									
									
									
										vendored
									
									
								
							| @ -58,4 +58,6 @@ export interface EnvironmentConfig { | |||||||
|     feedbackFormUrl?: string | false; |     feedbackFormUrl?: string | false; | ||||||
|     a11yStatement?: string | false; |     a11yStatement?: string | false; | ||||||
|     iabToolbarColors?: 'auto' | { background: string; text?: string } | null; |     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.
 | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user