fix(client): 刷新节点列表时保留已有 ping,修延迟被 refresh 清成 — 的根因

日志实证:urltest 回写正常(best=561ms→setLivePing),但看门狗/节点页每15s refresh()
重拉服务端列表、解析时 ping=0(占位),state=result 把刚写进去的延迟清零 → 显示 —,
下一帧 setLivePing 又写回 → 来回闪。修:refresh 用 _mergePings 按 uuid 保留已有 ping
(ping 是客户端实测,服务端列表不带)。去掉诊断日志。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-30 00:50:58 +08:00
parent 53eb982254
commit 795082066e
2 changed files with 15 additions and 11 deletions
+1 -10
View File
@@ -87,7 +87,6 @@ class ConnectionController extends StateNotifier<ConnectionState> {
Timer? _elapsed;
Timer? _watchdog;
bool _probing = false;
int _statsTick = 0; // 仅诊断:_onStats 限频打日志
// 本次 off 的提示语(节点异常/自动切换);kernel off 与显式断开都读它,避免被互相覆盖。
// 仅 _connect 开始时清空。用户主动断开则保持 null(无提示)。
String? _offNotice;
@@ -233,16 +232,8 @@ class ConnectionController extends StateNotifier<ConnectionState> {
final node = _connectedNode;
if (node == null || node.uuid.isEmpty) return;
final ds = e.urltestResults.where((r) => r.delayMs > 0).map((r) => r.delayMs);
if (ds.isEmpty) {
// 诊断:urltest 为空(每 ~10 帧打一次,免刷屏)。
if (_statsTick++ % 10 == 0) {
logLine('Latency',
'urltest empty: rawResults=${e.urltestResults.length} node=${node.code} nodePing=${node.ping}');
}
return;
}
if (ds.isEmpty) return;
final best = ds.reduce((a, b) => a < b ? a : b);
if (_statsTick++ % 10 == 0) logLine('Latency', 'urltest best=${best}ms → setLivePing ${node.code}');
_ref.read(nodesProvider.notifier).setLivePing(node.uuid, best);
}