mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
feat: Implement optimized contact fetching by public key to enhance performance
This commit is contained in:
@@ -686,6 +686,30 @@ class ConnectionProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a single contact by public key from device
|
||||
///
|
||||
/// This is more efficient than getContacts() when you only need to refresh
|
||||
/// one specific contact (e.g., after receiving an advertisement or path update).
|
||||
///
|
||||
/// The contact will be delivered via the onContactReceived callback.
|
||||
Future<void> getContact(Uint8List publicKey) async {
|
||||
if (!_bleService.isConnected) {
|
||||
_error = 'Not connected to device';
|
||||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await _bleService.getContactByKey(publicKey);
|
||||
} catch (e) {
|
||||
_error = 'Failed to get contact: $e';
|
||||
debugPrint('⚠️ [Provider] Failed to get contact by key, falling back to full contact sync');
|
||||
// Fallback to full contact sync if command not supported
|
||||
await _bleService.getContacts();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
/// Sync all channels from device
|
||||
Future<void> syncChannels({int? maxChannels}) async {
|
||||
if (!_bleService.isConnected) {
|
||||
|
||||
Reference in New Issue
Block a user