Refactor contact handling by removing unnecessary mapping and improving clarity across multiple screens

This commit is contained in:
Winston Lowe
2026-03-26 16:46:01 -07:00
parent 5dfccb9a94
commit 4ce7878539
5 changed files with 37 additions and 45 deletions
+26 -21
View File
@@ -139,9 +139,7 @@ class _MapScreenState extends State<MapScreen> {
builder: (context, connector, settingsService, pathHistory, child) {
final tileCache = context.read<MapTileCacheService>();
final settings = settingsService.settings;
final allContacts = connector.allContacts
.map((c) => connector.getFromDiscovered(c))
.toList();
final allContacts = connector.allContacts;
final contacts = settings.mapShowDiscoveryContacts
? allContacts
@@ -491,10 +489,11 @@ class _MapScreenState extends State<MapScreen> {
),
),
),
..._buildGuessedMarker(
guessedLocations,
showLabels: _showNodeLabels,
),
if (!settings.mapShowOverlaps)
..._buildGuessedMarker(
guessedLocations,
showLabels: _showNodeLabels,
),
..._buildMarkers(
contactsWithLocation,
settings,
@@ -881,23 +880,29 @@ class _MapScreenState extends State<MapScreen> {
addContact = true;
}
final hasOverlap = contacts
.where(
(c) =>
c.publicKeyHex != contact.publicKeyHex &&
c.publicKey.first == contact.publicKey.first &&
(c.type == advTypeRepeater || c.type == advTypeRoom) &&
(contact.type == advTypeRepeater ||
contact.type == advTypeRoom),
)
.firstOrNull;
if (hasOverlap == null &&
settings.mapShowOverlaps &&
!_isBuildingPathTrace) {
if (contact.type == advTypeChat && _isBuildingPathTrace) {
addContact = false;
}
if (settings.mapShowOverlaps) {
final hasOverlap = contacts
.where(
(c) =>
c.publicKeyHex != contact.publicKeyHex &&
c.publicKey.first == contact.publicKey.first &&
(c.type == advTypeRepeater || c.type == advTypeRoom) &&
(contact.type == advTypeRepeater ||
contact.type == advTypeRoom),
)
.firstOrNull;
if (hasOverlap == null &&
settings.mapShowOverlaps &&
!_isBuildingPathTrace) {
addContact = false;
}
}
if (addContact) {
filtered.add(contact);
}