fix(client): 修复多个同名同目的地的列车互相清除 pending 状态的问题

当存在多个列车(如无名列车 ??? 开往同一目的地)时:
- 第二个 ETA 较远的列车会因为 `etaSeconds > 45` 走进 `else` 分支
- 原逻辑在 `else` 分支会直接清空该 key 的 pending 状态
- 导致排在前面的列车永远无法积累 5 秒的稳定期

修改:
1. 移除 `else` 分支,统一交由末尾的清理循环处理
2. 使用 `if not seenApproachKeys[announceKey]` 确保同一个 tick 只有 ETA 最近(排最前)的列车更新状态
This commit is contained in:
2026-08-03 11:14:40 +08:00
parent 619d4e9a20
commit eb018dbae9
+6 -6
View File
@@ -1,6 +1,6 @@
-- 1. Configuration & Constants
local APP_VERSION_TEXT = "v1.0.50"
local APP_VERSION_TEXT = "v1.0.51"
local CONFIG = {
CLOUD_URL = "ws://stabadmin.fse-media.group",
@@ -2704,6 +2704,7 @@ function Main.loop()
end
if etaSeconds >= 0 and etaSeconds <= 45 then
if not seenApproachKeys[announceKey] then
seenApproachKeys[announceKey] = true
local pending = State.pendingApproaching[announceKey]
if not pending then
@@ -2734,8 +2735,7 @@ function Main.loop()
reason = reason
})
end
else
State.pendingApproaching[announceKey] = nil
end
end
end
end
@@ -2838,12 +2838,13 @@ function Main.loop()
end
if etaSeconds >= 0 and etaSeconds <= 45 then
if not seenApproachKeys[announceKey] then
seenApproachKeys[announceKey] = true
local pending = State.pendingApproaching[announceKey]
if not pending then
State.pendingApproaching[announceKey] = { since = now, lastEta = etaSeconds }
else
if etaSeconds > (tonumber(pending.lastEta) or etaSeconds) + 3 then
if etaSeconds > (tonumber(pending.lastEta) or etaSeconds) + 15 then
pending.since = now
end
pending.lastEta = etaSeconds
@@ -2866,8 +2867,7 @@ function Main.loop()
delay = delay
})
end
else
State.pendingApproaching[announceKey] = nil
end
end
end
end