From 2d993379bf487a3dc837c4c172582697a32c9508 Mon Sep 17 00:00:00 2001 From: jwinterm Date: Sun, 28 Sep 2025 09:23:00 -0400 Subject: [PATCH] single_game payment and audio alerts working --- html/js/ui/audioAlerts.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/html/js/ui/audioAlerts.js b/html/js/ui/audioAlerts.js index 7edf073..d842ffc 100644 --- a/html/js/ui/audioAlerts.js +++ b/html/js/ui/audioAlerts.js @@ -126,8 +126,14 @@ const AudioAlerts = { playFile(tag) { if (!this._enabled) return; const now = Date.now(); - if (now - this._lastPlay < this._cooldownMs) return; - this._lastPlay = now; + // Per-tag cooldown so different event types can fire back-to-back (e.g. payment_confirmed -> game_start) + if (!this._audioTagTimes) this._audioTagTimes = {}; // tag -> last play timestamp + const lastForTag = this._audioTagTimes[tag] || 0; + const elapsed = now - lastForTag; + const allow = elapsed >= this._cooldownMs || (tag === 'game_start' && this._lastTag !== 'game_start'); + if (!allow) return; + this._audioTagTimes[tag] = now; + this._lastTag = tag; const el = this._getAudio(tag); if (!el) return; try { el.currentTime = 0; el.play().catch(()=>{}); } catch(_) {}