mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-25 20:02:52 +10:00
Refactor contact search functionality to use DiscoveryContact model and simplify query matching
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:meshcore_open/models/contact.dart';
|
||||
@@ -212,17 +213,7 @@ class _DiscoveryScreenState extends State<DiscoveryScreen> {
|
||||
) {
|
||||
var filtered = contacts.where((contact) {
|
||||
if (searchQuery.isEmpty) return true;
|
||||
return matchesContactQuery(
|
||||
Contact(
|
||||
publicKey: contact.publicKey,
|
||||
name: contact.name,
|
||||
type: contact.type,
|
||||
pathLength: contact.pathLength,
|
||||
path: contact.path,
|
||||
lastSeen: contact.lastSeen,
|
||||
),
|
||||
searchQuery,
|
||||
);
|
||||
return matchesDiscoveryContactQuery(contact, searchQuery);
|
||||
}).toList();
|
||||
|
||||
// Filter out own node from the list
|
||||
@@ -237,22 +228,6 @@ class _DiscoveryScreenState extends State<DiscoveryScreen> {
|
||||
filtered = filtered.where(_matchesTypeFilter).toList();
|
||||
}
|
||||
|
||||
if (showUnreadOnly) {
|
||||
filtered = filtered.where((contact) {
|
||||
return connector.getUnreadCountForContact(
|
||||
Contact(
|
||||
publicKey: contact.publicKey,
|
||||
name: contact.name,
|
||||
type: contact.type,
|
||||
pathLength: contact.pathLength,
|
||||
path: contact.path,
|
||||
lastSeen: contact.lastSeen,
|
||||
),
|
||||
) >
|
||||
0;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
switch (sortOption) {
|
||||
case ContactSortOption.lastSeen:
|
||||
filtered.sort(
|
||||
|
||||
Reference in New Issue
Block a user