fix: dedupe delay alerts to reduce music stutter

This commit is contained in:
2026-08-02 19:19:00 +08:00
parent 906594008a
commit 04591fc0c8
+5 -4
View File
@@ -2,7 +2,7 @@
-- ============================================================================ -- ============================================================================
-- 1. Configuration & Constants -- 1. Configuration & Constants
-- ============================================================================ -- ============================================================================
local APP_VERSION_TEXT = "v1.0.39" local APP_VERSION_TEXT = "v1.0.40"
local CONFIG = { local CONFIG = {
CLOUD_URL = "ws://stabadmin.fse-media.group", CLOUD_URL = "ws://stabadmin.fse-media.group",
@@ -2537,8 +2537,9 @@ function Main.loop()
reason = reason reason = reason
}) })
local alertKey = announceKey .. "::delay=" .. tostring(displayDelayMinutes) .. "::reason=" .. tostring(reason or "") .. "::cancel=" .. tostring(cancelled) local alertType = cancelled and "cancelled" or ((displayDelayMinutes > 0) and "delayed" or nil)
if cancelled or displayDelayMinutes > 0 then local alertKey = alertType and (announceKey .. "::" .. alertType) or nil
if alertKey then
if not State.announcedAlerts[alertKey] then if not State.announcedAlerts[alertKey] then
State.announcedAlerts[alertKey] = now State.announcedAlerts[alertKey] = now
Utils.log("INFO", string.format("Train Alert: %s (ETA: %ds, Delay: %dm, Cancelled: %s, Reason: %s)", trainName, etaSeconds, displayDelayMinutes, tostring(cancelled), tostring(reason or ""))) Utils.log("INFO", string.format("Train Alert: %s (ETA: %ds, Delay: %dm, Cancelled: %s, Reason: %s)", trainName, etaSeconds, displayDelayMinutes, tostring(cancelled), tostring(reason or "")))
@@ -2650,7 +2651,7 @@ function Main.loop()
reason = nil reason = nil
}) })
local alertKey = announceKey .. "::delay=" .. tostring(delay) local alertKey = announceKey .. "::delayed"
if delay > 0 then if delay > 0 then
if not State.announcedAlerts[alertKey] then if not State.announcedAlerts[alertKey] then
State.announcedAlerts[alertKey] = now State.announcedAlerts[alertKey] = now