mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
Refactor contact handling by removing unnecessary mapping and improving clarity across multiple screens
This commit is contained in:
parent
5dfccb9a94
commit
4ce7878539
5 changed files with 37 additions and 45 deletions
|
|
@ -40,12 +40,7 @@ class ChannelMessagePathScreen extends StatelessWidget {
|
|||
final primaryPath = !channelMessage && !message.isOutgoing
|
||||
? Uint8List.fromList(primaryPathTmp.reversed.toList())
|
||||
: primaryPathTmp;
|
||||
<<<<<<< HEAD
|
||||
final hops = _buildPathHops(primaryPath, connector, l10n);
|
||||
=======
|
||||
final contacts = connector.allContactsUnfiltered;
|
||||
final hops = _buildPathHops(primaryPath, contacts, l10n);
|
||||
>>>>>>> da74560 (Enhance contact handling and UI updates across multiple screens)
|
||||
final hasHopDetails = primaryPath.isNotEmpty;
|
||||
final observedLabel = _formatObservedHops(
|
||||
primaryPath.length,
|
||||
|
|
@ -390,10 +385,7 @@ class _ChannelMessagePathMapScreenState
|
|||
: selectedPathTmp;
|
||||
|
||||
final selectedIndex = _indexForPath(selectedPath, observedPaths);
|
||||
final contacts = connector.allContactsUnfiltered
|
||||
.map((c) => connector.getFromDiscovered(c))
|
||||
.toList();
|
||||
final hops = _buildPathHops(selectedPath, contacts, context.l10n);
|
||||
final hops = _buildPathHops(selectedPath, connector, context.l10n);
|
||||
|
||||
final points = <LatLng>[];
|
||||
|
||||
|
|
@ -830,7 +822,8 @@ List<_PathHop> _buildPathHops(
|
|||
) {
|
||||
if (pathBytes.isEmpty) return const [];
|
||||
final candidatesByPrefix = <int, List<Contact>>{};
|
||||
for (final contact in connector.allContacts) {
|
||||
final allContacts = connector.allContacts;
|
||||
for (final contact in allContacts) {
|
||||
if (contact.publicKey.isEmpty) continue;
|
||||
if (contact.type != advTypeRepeater && contact.type != advTypeRoom) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ class _CompanionRadioStatsScreenState extends State<CompanionRadioStatsScreen> {
|
|||
final c = context.read<MeshCoreConnector>();
|
||||
_connector = c;
|
||||
c.acquireRadioStatsPolling();
|
||||
c.setPollingInterval(1);
|
||||
c.radioStatsNotifier.addListener(_onStatsUpdate);
|
||||
}
|
||||
|
||||
|
|
@ -44,6 +45,7 @@ class _CompanionRadioStatsScreenState extends State<CompanionRadioStatsScreen> {
|
|||
void dispose() {
|
||||
_connector?.radioStatsNotifier.removeListener(_onStatsUpdate);
|
||||
_connector?.releaseRadioStatsPolling();
|
||||
_connector?.setPollingInterval(30);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -283,9 +283,7 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen> {
|
|||
if (widget.pathContacts != null) {
|
||||
pathContacts = {for (var c in widget.pathContacts!) c.publicKey[0]: c};
|
||||
} else {
|
||||
final contacts = connector.allContactsUnfiltered
|
||||
.map((c) => connector.getFromDiscovered(c))
|
||||
.toList();
|
||||
final contacts = connector.allContactsUnfiltered;
|
||||
contacts.where((c) => c.type != advTypeChat).forEach((repeater) {
|
||||
if (lastContact.latitude != null &&
|
||||
lastContact.longitude != null &&
|
||||
|
|
|
|||
|
|
@ -58,10 +58,9 @@ class GpxExport {
|
|||
}
|
||||
|
||||
void addRepeaters() {
|
||||
final contacts = _connector.allContacts
|
||||
.where((c) => c.type == advTypeRepeater || c.type == advTypeRoom)
|
||||
.map((c) => _connector.getFromDiscovered(c))
|
||||
.toList();
|
||||
final contacts = _connector.allContacts.where(
|
||||
(c) => c.type == advTypeRepeater || c.type == advTypeRoom,
|
||||
);
|
||||
for (var contact in contacts) {
|
||||
if (contact.latitude == null || contact.longitude == null) {
|
||||
continue;
|
||||
|
|
@ -80,10 +79,7 @@ class GpxExport {
|
|||
}
|
||||
|
||||
void addContacts() {
|
||||
final contacts = _connector.allContacts
|
||||
.where((c) => c.type == advTypeChat)
|
||||
.map((c) => _connector.getFromDiscovered(c))
|
||||
.toList();
|
||||
final contacts = _connector.allContacts.where((c) => c.type == advTypeChat);
|
||||
for (var contact in contacts) {
|
||||
if (contact.latitude == null || contact.longitude == null) {
|
||||
continue;
|
||||
|
|
@ -102,9 +98,7 @@ class GpxExport {
|
|||
}
|
||||
|
||||
void addAll() {
|
||||
final contacts = _connector.allContacts
|
||||
.map((c) => _connector.getFromDiscovered(c))
|
||||
.toList();
|
||||
final contacts = _connector.allContacts;
|
||||
for (var contact in contacts) {
|
||||
if (contact.latitude == null || contact.longitude == null) {
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue