Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't Show unreachable nodes in the contact list #814

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Meshtastic/Views/Messages/UserList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ struct UserList: View {
sortDescriptors: [NSSortDescriptor(key: "lastMessage", ascending: false),
NSSortDescriptor(key: "userNode.favorite", ascending: false),
NSSortDescriptor(key: "longName", ascending: true)],
animation: .default
predicate: NSPredicate(
format: "NOT (userNode.viaMqtt == YES AND userNode.hopsAway > 0)"
), animation: .default
)
private var users: FetchedResults<UserEntity>

Expand Down Expand Up @@ -244,15 +246,18 @@ 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")
predicates.append(loraPredicate)
} else {
let mqttPredicate = NSPredicate(format: "userNode.viaMqtt == YES")
let mqttPredicate = NSPredicate(format: "userNode.viaMqtt == YES AND userNode.hopsAway == 0")
predicates.append(mqttPredicate)
}
} else {
let mqttPredicate = NSPredicate(format: "NOT (userNode.viaMqtt == YES AND userNode.hopsAway > 0)")
predicates.append(mqttPredicate)
}
/// Roles
if roleFilter && deviceRoles.count > 0 {
Expand Down