mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
Merge pull request #251 from zjs81/dev-discoverScreen
Contact discovery
This commit is contained in:
commit
d96cd34771
43 changed files with 3084 additions and 105 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import 'package:meshcore_open/models/discovery_contact.dart';
|
||||
|
||||
import '../models/contact.dart';
|
||||
|
||||
bool matchesContactQuery(Contact contact, String query) {
|
||||
|
|
@ -14,6 +16,20 @@ bool matchesContactQuery(Contact contact, String query) {
|
|||
return contact.publicKeyHex.toLowerCase().startsWith(hexPrefix);
|
||||
}
|
||||
|
||||
bool matchesDiscoveryContactQuery(DiscoveryContact contact, String query) {
|
||||
final normalizedQuery = query.trim().toLowerCase();
|
||||
if (normalizedQuery.isEmpty) return true;
|
||||
|
||||
if (contact.name.toLowerCase().contains(normalizedQuery)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final hexPrefix = _extractHexPrefix(normalizedQuery);
|
||||
if (hexPrefix == null) return false;
|
||||
|
||||
return contact.publicKeyHex.toLowerCase().startsWith(hexPrefix);
|
||||
}
|
||||
|
||||
String? _extractHexPrefix(String query) {
|
||||
var cleaned = query;
|
||||
if (cleaned.startsWith('<')) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue