Skip to content

Commit e2ce6bf

Browse files
authored
Merge pull request #814 from meshtastic/filter-unreachable-users
Don't Show unreachable nodes in the contact list
2 parents da6d92f + 3a2f2a7 commit e2ce6bf

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Meshtastic/Views/Messages/UserList.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ struct UserList: View {
4545
NSSortDescriptor(key: "pkiEncrypted", ascending: false),
4646
NSSortDescriptor(key: "userNode.lastHeard", ascending: false),
4747
NSSortDescriptor(key: "longName", ascending: true)],
48-
predicate: NSPredicate(format: "userNode.ignored == false && longName != ''"),
49-
animation: .default
48+
predicate: NSPredicate(
49+
format: "userNode.ignored == false && longName != '' AND NOT (userNode.viaMqtt == YES AND userNode.hopsAway > 0)"
50+
), animation: .default
5051
)
5152
var users: FetchedResults<UserEntity>
5253

@@ -297,7 +298,7 @@ struct UserList: View {
297298
let textSearchPredicate = NSCompoundPredicate(type: .or, subpredicates: searchPredicates)
298299
/// Create an array of predicates to hold our AND predicates
299300
var predicates: [NSPredicate] = []
300-
/// Mqtt
301+
/// Mqtt and lora
301302
if !(viaLora && viaMqtt) {
302303
if viaLora {
303304
let loraPredicate = NSPredicate(format: "userNode.viaMqtt == NO")
@@ -307,9 +308,8 @@ struct UserList: View {
307308
predicates.append(mqttPredicate)
308309
}
309310
} else {
310-
/// Only show mqtt nodes that can be contacted (zero hops) on the default key
311-
// let bothPredicate = NSPredicate(format: "userNode.viaMqtt == YES AND userNode.hopsAway == 0 OR userNode.viaMqtt == NO")
312-
// predicates.append(bothPredicate)
311+
let mqttPredicate = NSPredicate(format: "NOT (userNode.viaMqtt == YES AND userNode.hopsAway > 0)")
312+
predicates.append(mqttPredicate)
313313
}
314314
/// Roles
315315
if roleFilter && deviceRoles.count > 0 {

0 commit comments

Comments
 (0)