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:
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
-- 1. Configuration & Constants
|
-- 1. Configuration & Constants
|
||||||
local APP_VERSION_TEXT = "v1.0.50"
|
local APP_VERSION_TEXT = "v1.0.51"
|
||||||
|
|
||||||
local CONFIG = {
|
local CONFIG = {
|
||||||
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
||||||
@@ -2704,6 +2704,7 @@ function Main.loop()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if etaSeconds >= 0 and etaSeconds <= 45 then
|
if etaSeconds >= 0 and etaSeconds <= 45 then
|
||||||
|
if not seenApproachKeys[announceKey] then
|
||||||
seenApproachKeys[announceKey] = true
|
seenApproachKeys[announceKey] = true
|
||||||
local pending = State.pendingApproaching[announceKey]
|
local pending = State.pendingApproaching[announceKey]
|
||||||
if not pending then
|
if not pending then
|
||||||
@@ -2734,8 +2735,7 @@ function Main.loop()
|
|||||||
reason = reason
|
reason = reason
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
else
|
end
|
||||||
State.pendingApproaching[announceKey] = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2838,12 +2838,13 @@ function Main.loop()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if etaSeconds >= 0 and etaSeconds <= 45 then
|
if etaSeconds >= 0 and etaSeconds <= 45 then
|
||||||
|
if not seenApproachKeys[announceKey] then
|
||||||
seenApproachKeys[announceKey] = true
|
seenApproachKeys[announceKey] = true
|
||||||
local pending = State.pendingApproaching[announceKey]
|
local pending = State.pendingApproaching[announceKey]
|
||||||
if not pending then
|
if not pending then
|
||||||
State.pendingApproaching[announceKey] = { since = now, lastEta = etaSeconds }
|
State.pendingApproaching[announceKey] = { since = now, lastEta = etaSeconds }
|
||||||
else
|
else
|
||||||
if etaSeconds > (tonumber(pending.lastEta) or etaSeconds) + 3 then
|
if etaSeconds > (tonumber(pending.lastEta) or etaSeconds) + 15 then
|
||||||
pending.since = now
|
pending.since = now
|
||||||
end
|
end
|
||||||
pending.lastEta = etaSeconds
|
pending.lastEta = etaSeconds
|
||||||
@@ -2866,8 +2867,7 @@ function Main.loop()
|
|||||||
delay = delay
|
delay = delay
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
else
|
end
|
||||||
State.pendingApproaching[announceKey] = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user