diff --git a/src/main.ts b/src/main.ts index 7fdbe70..e86f6b1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1021,7 +1021,7 @@ function startDeviceListeners() { } trackerTimeouts[trackerName] = setTimeout(() => { device.emit("disconnect", trackerName); - log(`Tracker ${trackerName} assumed disconnected due to inactivity.`); + log(`Tracker ${trackerName} assumed disconnected due to inactivity.`, "tracker"); }, 5000); }; diff --git a/src/static/html/index.html b/src/static/html/index.html index 0d12232..7819580 100644 --- a/src/static/html/index.html +++ b/src/static/html/index.html @@ -109,7 +109,7 @@

Tracker informati - @@ -120,7 +120,6 @@

Tracker informati @@ -344,7 +343,7 @@

diff --git a/src/static/js/index.ts b/src/static/js/index.ts index 0520774..3a76ba6 100644 --- a/src/static/js/index.ts +++ b/src/static/js/index.ts @@ -3,6 +3,7 @@ */ let isActive = false; +let refreshingDeviceList = false; let bluetoothEnabled = false; let comEnabled = false; @@ -625,7 +626,7 @@ window.ipc.on("device-connected-to-server", (_event, deviceID) => { window.ipc.on("device-data", async (_event: any, arg) => { const { trackerName, rotation, gravity, rawRotation, rawGravity } = arg; - if (!isActive) return; + if (!isActive || refreshingDeviceList) return; const trackerElement = document.getElementById(trackerName); if (!trackerElement) { @@ -964,6 +965,22 @@ window.ipc.on("set-status", (_event, msg) => { }); function addEventListeners() { + function refreshDeviceList() { + refreshingDeviceList = true; + + document.getElementById("device-list").textContent = ""; + deviceQueue.length = 0; + + const devices = document.querySelectorAll(".card"); + devices.forEach((device) => { + deviceQueue.push(device.id); + }); + + processQueue().then(() => { + refreshingDeviceList = false; + }); + } + /* * "Tracker info" event listeners */ @@ -976,6 +993,8 @@ function addEventListeners() { compactView: compactView, }, }); + + refreshDeviceList(); }); document.getElementById("censor-serial-switch").addEventListener("change", function () { @@ -1038,6 +1057,8 @@ function addEventListeners() { trackerVisualization: trackerVisualization, }, }); + + refreshDeviceList(); }); /*