Address review: stable tie-breaker and accurate log message

- Add node id tie-breaker to sort comparator so equal-distance nodes
  have deterministic ordering across renders (prevents flicker)
- Log validNodesCount instead of allNodes.length so the message
  reflects the actual post-filter count

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Doug Borg
2026-03-10 14:38:58 -06:00
parent fe401cc04b
commit ebb7fd090f

View File

@@ -88,7 +88,8 @@ class MapDataManager {
(a.coord.longitude - centerLng) * (a.coord.longitude - centerLng);
final distB = (b.coord.latitude - centerLat) * (b.coord.latitude - centerLat) +
(b.coord.longitude - centerLng) * (b.coord.longitude - centerLng);
return distA.compareTo(distB);
final cmp = distA.compareTo(distB);
return cmp != 0 ? cmp : a.id.compareTo(b.id);
});
nodesToRender = validNodes.take(maxNodes).toList();
isLimitActive = true;
@@ -107,7 +108,7 @@ class MapDataManager {
if (isLimitActive != _lastNodeLimitState) {
_lastNodeLimitState = isLimitActive;
if (isLimitActive) {
debugPrint('[MapDataManager] Node limit active: rendering ${nodesToRender.length} of ${allNodes.length} devices');
debugPrint('[MapDataManager] Node limit active: rendering ${nodesToRender.length} of $validNodesCount valid devices');
}
// Schedule callback after build completes to avoid setState during build
WidgetsBinding.instance.addPostFrameCallback((_) {