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

Crash fixes #922

Merged
merged 4 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions Meshtastic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.5.3;
MARKETING_VERSION = 2.5.4;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
Expand Down Expand Up @@ -1721,7 +1721,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.5.3;
MARKETING_VERSION = 2.5.4;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
Expand Down Expand Up @@ -1753,7 +1753,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.5.3;
MARKETING_VERSION = 2.5.4;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -1786,7 +1786,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.5.3;
MARKETING_VERSION = 2.5.4;
PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient.Widgets;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
46 changes: 33 additions & 13 deletions Meshtastic/Views/Messages/UserList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ struct UserList: View {
var boolFilters: [Bool] {[
isFavorite,
isOnline,
isPkiEncrypted,
isEnvironment,
distanceFilter,
roleFilter
Expand All @@ -45,11 +44,12 @@ struct UserList: View {
sortDescriptors: [NSSortDescriptor(key: "lastMessage", ascending: false),
NSSortDescriptor(key: "userNode.favorite", ascending: false),
NSSortDescriptor(key: "pkiEncrypted", ascending: false),
NSSortDescriptor(key: "userNode.lastHeard", ascending: false),
NSSortDescriptor(key: "longName", ascending: true)],
predicate: NSPredicate(format: "hwModelId != nil"),
predicate: NSPredicate(format: "longName != ''"),
animation: .default
)
private var users: FetchedResults<UserEntity>
var users: FetchedResults<UserEntity>

@Binding var node: NodeInfoEntity?
@Binding var userSelection: UserEntity?
Expand Down Expand Up @@ -202,34 +202,55 @@ struct UserList: View {
DirectMessagesHelp()
}
.onChange(of: searchText) { _ in
searchUserList()
Task {
await searchUserList()
}
}
.onChange(of: viaLora) { _ in
if !viaLora && !viaMqtt {
viaMqtt = true
}
searchUserList()
Task {
await searchUserList()
}
}
.onChange(of: viaMqtt) { _ in
if !viaLora && !viaMqtt {
viaLora = true
}
searchUserList()
Task {
await searchUserList()
}
}
.onChange(of: [deviceRoles]) { _ in
searchUserList()
Task {
await searchUserList()
}
}
.onChange(of: hopsAway) { _ in
searchUserList()
Task {
await searchUserList()
}
}
.onChange(of: [boolFilters]) { _ in
searchUserList()
Task {
await searchUserList()
}
}
.onChange(of: maxDistance) { _ in
searchUserList()
Task {
await searchUserList()
}
}
.onChange(of: isPkiEncrypted) { _ in
Task {
await searchUserList()
}
}
.onAppear {
searchUserList()
Task {
await searchUserList()
}
}
.safeAreaInset(edge: .bottom, alignment: .leading) {
HStack {
Expand Down Expand Up @@ -267,8 +288,7 @@ struct UserList: View {
.scrollDismissesKeyboard(.immediately)
}
}

private func searchUserList() {
private func searchUserList() async {

/// Case Insensitive Search Text Predicates
let searchPredicates = ["userId", "numString", "hwModel", "hwDisplayName", "longName", "shortName"].map { property in
Expand Down
4 changes: 3 additions & 1 deletion Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ struct NodeMapSwiftUI: View {
if node.positions?.count ?? 0 > 1 {
position = .automatic
} else {
position = .camera(MapCamera(centerCoordinate: mostRecent!.coordinate, distance: 8000, heading: 0, pitch: 60))
if let mrCoord = mostRecent?.coordinate {
position = .camera(MapCamera(centerCoordinate: mrCoord, distance: 8000, heading: 0, pitch: 60))
}
}
if self.scene == nil {
Task {
Expand Down
6 changes: 3 additions & 3 deletions Meshtastic/Views/Settings/Channels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct Channels: View {
preciseLocation = true
positionsEnabled = true
if channelKey == "AQ==" {
positionPrecision = 13
positionPrecision = 14
preciseLocation = false
}
} else if !supportedVersion && channelRole == 2 {
Expand All @@ -103,8 +103,8 @@ struct Channels: View {
} else {
if channelKey == "AQ==" {
preciseLocation = false
if (positionPrecision > 0 && positionPrecision < 10) || positionPrecision > 16 {
positionPrecision = 13
if (positionPrecision > 0 && positionPrecision < 11) || positionPrecision > 14 {
positionPrecision = 14
}
} else if positionPrecision == 32 {
preciseLocation = true
Expand Down
8 changes: 4 additions & 4 deletions Meshtastic/Views/Settings/Channels/ChannelForm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ struct ChannelForm: View {
.listRowSeparator(.visible)
.onChange(of: preciseLocation) { pl in
if pl == false {
positionPrecision = 13
positionPrecision = 14
}
}
}
Expand All @@ -158,7 +158,7 @@ struct ChannelForm: View {
VStack(alignment: .leading) {
Label("Approximate Location", systemImage: "location.slash.circle.fill")

Slider(value: $positionPrecision, in: 10...16, step: 1) {
Slider(value: $positionPrecision, in: 11...14, step: 1) {
} minimumValueLabel: {
Image(systemName: "minus")
} maximumValueLabel: {
Expand Down Expand Up @@ -220,7 +220,7 @@ struct ChannelForm: View {
}
positionPrecision = 32
} else {
positionPrecision = 13
positionPrecision = 14
}
hasChanges = true
}
Expand All @@ -230,7 +230,7 @@ struct ChannelForm: View {
.onChange(of: positionsEnabled) { pe in
if pe {
if positionPrecision == 0 {
positionPrecision = 13
positionPrecision = 14
}
} else {
positionPrecision = 0
Expand Down
50 changes: 16 additions & 34 deletions Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ struct MQTTConfig: View {
@State var nearbyTopics = [String]()
@State var mapReportingEnabled = false
@State var mapPublishIntervalSecs = 3600
@State var preciseLocation: Bool = false
@State var mapPositionPrecision: Double = 13.0
@State var mapPositionPrecision: Double = 14.0

let locale = Locale.current

Expand Down Expand Up @@ -105,35 +104,17 @@ struct MQTTConfig: View {
}
}
.pickerStyle(DefaultPickerStyle())

VStack(alignment: .leading) {
Toggle(isOn: $preciseLocation) {
Label("Precise Location", systemImage: "scope")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
.listRowSeparator(.visible)
.onChange(of: preciseLocation) { pl in
if pl == false {
mapPositionPrecision = 12
} else {
mapPositionPrecision = 32
}
}
}

if !preciseLocation {
VStack(alignment: .leading) {
Label("Approximate Location", systemImage: "location.slash.circle.fill")
Slider(value: $mapPositionPrecision, in: 11...16, step: 1) {
} minimumValueLabel: {
Image(systemName: "minus")
} maximumValueLabel: {
Image(systemName: "plus")
}
Text(PositionPrecision(rawValue: Int(mapPositionPrecision))?.description ?? "")
.foregroundColor(.gray)
.font(.callout)
Label("Approximate Location", systemImage: "location.slash.circle.fill")
Slider(value: $mapPositionPrecision, in: 11...14, step: 1) {
} minimumValueLabel: {
Image(systemName: "minus")
} maximumValueLabel: {
Image(systemName: "plus")
}
Text(PositionPrecision(rawValue: Int(mapPositionPrecision))?.description ?? "")
.foregroundColor(.gray)
.font(.callout)
}
}
}
Expand Down Expand Up @@ -429,11 +410,12 @@ struct MQTTConfig: View {
self.mqttConnected = bleManager.mqttProxyConnected
self.mapReportingEnabled = node?.mqttConfig?.mapReportingEnabled ?? false
self.mapPublishIntervalSecs = Int(node?.mqttConfig?.mapPublishIntervalSecs ?? 3600)
self.mapPositionPrecision = Double(node?.mqttConfig?.mapPositionPrecision ?? 12)
if mapPositionPrecision == 0.0 {
self.mapPositionPrecision = 12
self.mapPositionPrecision = Double(node?.mqttConfig?.mapPositionPrecision ?? 14)
if mapPositionPrecision < 11 || mapPositionPrecision > 14 {
self.mapPositionPrecision = 14
self.hasChanges = true
} else {
self.hasChanges = false
}
self.preciseLocation = mapPositionPrecision == 32
self.hasChanges = false
}
}