From 221f276c4b92bb85b0246214bfe1d0d90afb2742 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 24 Jul 2024 12:15:05 -0400 Subject: [PATCH] Simplify stats sending. --- core/app.js | 4 ---- core/client.js | 1 - core/core.js | 21 +++++---------------- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/core/app.js b/core/app.js index 839e9137..e4b35758 100644 --- a/core/app.js +++ b/core/app.js @@ -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); diff --git a/core/client.js b/core/client.js index f237258c..39348308 100644 --- a/core/client.js +++ b/core/client.js @@ -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') { diff --git a/core/core.js b/core/core.js index 410117cd..236eb08b 100644 --- a/core/core.js +++ b/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, };