From f1345b001076e9608233dac48e8a63dffa91bdcd Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sun, 28 Jun 2026 14:52:22 -0500 Subject: [PATCH] fix: clear pending icon timeout on rapid heartbeat re-click Prevents spinner color bleed and mid-flight icon reset when user clicks the heartbeat button again before the 3s revert. Claude-Session: https://claude.ai/code/session_01Jo2JpjCwfHAh2HHRSjczKq --- source/packages/com_mokosuiteclient/media/js/dashboard.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/packages/com_mokosuiteclient/media/js/dashboard.js b/source/packages/com_mokosuiteclient/media/js/dashboard.js index 15817773..4ab80ad8 100644 --- a/source/packages/com_mokosuiteclient/media/js/dashboard.js +++ b/source/packages/com_mokosuiteclient/media/js/dashboard.js @@ -112,6 +112,7 @@ document.addEventListener('DOMContentLoaded', function () { // Heartbeat + PIN send button var hbBtn = document.getElementById('mokosuiteclient-btn-heartbeat-pin'); + var hbIconTimeout = null; if (hbBtn) { hbBtn.addEventListener('click', function () { var btn = this; @@ -119,8 +120,9 @@ document.addEventListener('DOMContentLoaded', function () { var token = btn.dataset.token; var icon = btn.querySelector('span'); + if (hbIconTimeout) { clearTimeout(hbIconTimeout); hbIconTimeout = null; } btn.disabled = true; - if (icon) icon.className = 'icon-spinner icon-spin'; + if (icon) { icon.className = 'icon-spinner icon-spin'; icon.style.color = ''; } var fd = new FormData(); fd.append(token, '1'); @@ -148,8 +150,9 @@ document.addEventListener('DOMContentLoaded', function () { }) .finally(function () { btn.disabled = false; - setTimeout(function () { + hbIconTimeout = setTimeout(function () { if (icon) { icon.className = 'icon-upload'; icon.style.color = ''; } + hbIconTimeout = null; }, 3000); }); });