forked from cory/tildefriends
		
	Simplify stats sending.
This commit is contained in:
		| @@ -211,10 +211,6 @@ async function socket(request, response, client) { | ||||
| 				if (process && process.timeout > 0) { | ||||
| 					setTimeout(ping, process.timeout); | ||||
| 				} | ||||
| 			} else if (message.action == 'enableStats') { | ||||
| 				if (process) { | ||||
| 					core.enableStats(process, message.enabled); | ||||
| 				} | ||||
| 			} else if (message.action == 'resetPermission') { | ||||
| 				if (process) { | ||||
| 					process.resetPermission(message.permission); | ||||
|   | ||||
| @@ -1274,7 +1274,6 @@ function _receive_websocket_message(message) { | ||||
| 		document.getElementById('viewPane').style.display = message.edit_only | ||||
| 			? 'none' | ||||
| 			: 'flex'; | ||||
| 		send({action: 'enableStats', enabled: true}); | ||||
| 	} else if (message && message.action == 'ping') { | ||||
| 		send({action: 'pong'}); | ||||
| 	} else if (message && message.action == 'stats') { | ||||
|   | ||||
							
								
								
									
										21
									
								
								core/core.js
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								core/core.js
									
									
									
									
									
								
							| @@ -286,7 +286,6 @@ async function getProcessBlob(blobId, key, options) { | ||||
| 			process.lastActive = Date.now(); | ||||
| 			process.lastPing = null; | ||||
| 			process.timeout = options.timeout; | ||||
| 			process.stats = false; | ||||
| 			process.ready = new Promise(function (resolve, reject) { | ||||
| 				resolveReady = resolve; | ||||
| 				rejectReady = reject; | ||||
| @@ -778,6 +777,10 @@ async function getProcessBlob(blobId, key, options) { | ||||
| 			} | ||||
| 			await process.task.execute({name: appSourceName, source: appSource}); | ||||
| 			resolveReady(process); | ||||
| 			if (!gStatsTimer) { | ||||
| 				gStatsTimer = true; | ||||
| 				sendStats(); | ||||
| 			} | ||||
| 		} catch (error) { | ||||
| 			if (process.app) { | ||||
| 				if (process?.task?.onError) { | ||||
| @@ -1200,7 +1203,7 @@ async function loadSettings() { | ||||
|  */ | ||||
| function sendStats() { | ||||
| 	let apps = Object.values(gProcesses) | ||||
| 		.filter((process) => process.app && process.stats) | ||||
| 		.filter((process) => process.app) | ||||
| 		.map((process) => process.app); | ||||
| 	if (apps.length) { | ||||
| 		let stats = getStats(); | ||||
| @@ -1213,19 +1216,6 @@ function sendStats() { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * TODOC | ||||
|  * @param {*} process | ||||
|  * @param {*} enabled | ||||
|  */ | ||||
| function enableStats(process, enabled) { | ||||
| 	process.stats = enabled; | ||||
| 	if (!gStatsTimer) { | ||||
| 		gStatsTimer = true; | ||||
| 		sendStats(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * TODOC | ||||
|  */ | ||||
| @@ -1342,7 +1332,6 @@ function storePermission(user, packageOwner, packageName, permission, allow) { | ||||
| export { | ||||
| 	gGlobalSettings as globalSettings, | ||||
| 	setGlobalSettings, | ||||
| 	enableStats, | ||||
| 	invoke, | ||||
| 	getSessionProcessBlob, | ||||
| }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user