Merge pull request #814 from meshtastic/filter-unreachable-users

Don't Show unreachable nodes in the contact list
This commit is contained in:
Garth Vander Houwen 2024-12-22 09:13:01 -08:00 committed by GitHub
commit e2ce6bff07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -45,8 +45,9 @@ struct UserList: View {
NSSortDescriptor(key: "pkiEncrypted", ascending: false),
NSSortDescriptor(key: "userNode.lastHeard", ascending: false),
NSSortDescriptor(key: "longName", ascending: true)],
predicate: NSPredicate(format: "userNode.ignored == false && longName != ''"),
animation: .default
predicate: NSPredicate(
format: "userNode.ignored == false && longName != '' AND NOT (userNode.viaMqtt == YES AND userNode.hopsAway > 0)"
), animation: .default
)
var users: FetchedResults<UserEntity>
@ -297,7 +298,7 @@ struct UserList: View {
let textSearchPredicate = NSCompoundPredicate(type: .or, subpredicates: searchPredicates)
/// Create an array of predicates to hold our AND predicates
var predicates: [NSPredicate] = []
/// Mqtt
/// Mqtt and lora
if !(viaLora && viaMqtt) {
if viaLora {
let loraPredicate = NSPredicate(format: "userNode.viaMqtt == NO")
@ -307,9 +308,8 @@ struct UserList: View {
predicates.append(mqttPredicate)
}
} else {
/// Only show mqtt nodes that can be contacted (zero hops) on the default key
// let bothPredicate = NSPredicate(format: "userNode.viaMqtt == YES AND userNode.hopsAway == 0 OR userNode.viaMqtt == NO")
// predicates.append(bothPredicate)
let mqttPredicate = NSPredicate(format: "NOT (userNode.viaMqtt == YES AND userNode.hopsAway > 0)")
predicates.append(mqttPredicate)
}
/// Roles
if roleFilter && deviceRoles.count > 0 {