mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-24 03:14:30 +10:00
fix: improve BLE scanning reliability and filter out own node from contacts list improve text scaling
This commit is contained in:
@@ -625,6 +625,17 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
_scanResults.clear();
|
_scanResults.clear();
|
||||||
_setState(MeshCoreConnectionState.scanning);
|
_setState(MeshCoreConnectionState.scanning);
|
||||||
|
|
||||||
|
// Ensure any previous scan is fully stopped
|
||||||
|
await FlutterBluePlus.stopScan();
|
||||||
|
await _scanSubscription?.cancel();
|
||||||
|
|
||||||
|
// On iOS/macOS, add a small delay to allow BLE stack to reset
|
||||||
|
// This prevents cached results from interfering with new scans
|
||||||
|
if (defaultTargetPlatform == TargetPlatform.iOS ||
|
||||||
|
defaultTargetPlatform == TargetPlatform.macOS) {
|
||||||
|
await Future.delayed(const Duration(milliseconds: 300));
|
||||||
|
}
|
||||||
|
|
||||||
_scanSubscription = FlutterBluePlus.scanResults.listen((results) {
|
_scanSubscription = FlutterBluePlus.scanResults.listen((results) {
|
||||||
_scanResults.clear();
|
_scanResults.clear();
|
||||||
for (var result in results) {
|
for (var result in results) {
|
||||||
|
|||||||
@@ -313,6 +313,14 @@ class _ContactsScreenState extends State<ContactsScreen>
|
|||||||
return matchesContactQuery(contact, _searchQuery);
|
return matchesContactQuery(contact, _searchQuery);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
|
// Filter out own node from the list
|
||||||
|
if (connector.selfPublicKey != null) {
|
||||||
|
final selfPubKeyHex = pubKeyToHex(connector.selfPublicKey!);
|
||||||
|
filtered = filtered.where((contact) {
|
||||||
|
return contact.publicKeyHex != selfPubKeyHex;
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
if (_typeFilter != ContactTypeFilter.all) {
|
if (_typeFilter != ContactTypeFilter.all) {
|
||||||
filtered = filtered.where(_matchesTypeFilter).toList();
|
filtered = filtered.where(_matchesTypeFilter).toList();
|
||||||
}
|
}
|
||||||
@@ -863,21 +871,30 @@ class _ContactTile extends StatelessWidget {
|
|||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
'${contact.typeLabel} • ${contact.pathLabel} $shotPublicKey',
|
'${contact.typeLabel} • ${contact.pathLabel} $shotPublicKey',
|
||||||
),
|
),
|
||||||
trailing: Column(
|
// Clamp text scaling in trailing section to prevent overflow while
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
// maintaining accessibility. Primary content (title/subtitle) scales normally.
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
trailing: MediaQuery(
|
||||||
children: [
|
data: MediaQuery.of(context).copyWith(
|
||||||
if (unreadCount > 0) ...[
|
textScaler: TextScaler.linear(
|
||||||
UnreadBadge(count: unreadCount),
|
MediaQuery.textScalerOf(context).scale(1.0).clamp(1.0, 1.3),
|
||||||
const SizedBox(height: 4),
|
|
||||||
],
|
|
||||||
Text(
|
|
||||||
_formatLastSeen(context, lastSeen),
|
|
||||||
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
|
|
||||||
),
|
),
|
||||||
if (contact.hasLocation)
|
),
|
||||||
Icon(Icons.location_on, size: 14, color: Colors.grey[400]),
|
child: Column(
|
||||||
],
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
if (unreadCount > 0) ...[
|
||||||
|
UnreadBadge(count: unreadCount),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
],
|
||||||
|
Text(
|
||||||
|
_formatLastSeen(context, lastSeen),
|
||||||
|
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
|
||||||
|
),
|
||||||
|
if (contact.hasLocation)
|
||||||
|
Icon(Icons.location_on, size: 14, color: Colors.grey[400]),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
onLongPress: onLongPress,
|
onLongPress: onLongPress,
|
||||||
|
|||||||
Reference in New Issue
Block a user