From f4b68b1d9700152320847da5e46d5a51cb98d85e Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Fri, 17 Apr 2026 21:19:07 -0700 Subject: [PATCH] Channel display fix (#1674) * Add deep link documentation to README (#1655) Agent-Logs-Url: https://github.com/meshtastic/Meshtastic-Apple/sessions/df28c94e-7e3d-44fc-8264-6ae1b875fb23 Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com> * Channel display fix --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com> --- Localizable.xcstrings | 3 +++ Meshtastic/Views/Settings/Channels.swift | 18 +++++++++--------- Meshtastic/Views/Settings/Settings.swift | 6 +++++- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Localizable.xcstrings b/Localizable.xcstrings index 34a26370..c7de260b 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -29054,6 +29054,9 @@ } } } + }, + "Loading..." : { + }, "Loading TAK config from the node." : { diff --git a/Meshtastic/Views/Settings/Channels.swift b/Meshtastic/Views/Settings/Channels.swift index f5c89071..ef3cead4 100644 --- a/Meshtastic/Views/Settings/Channels.swift +++ b/Meshtastic/Views/Settings/Channels.swift @@ -28,7 +28,7 @@ struct Channels: View { @Environment(\.sizeCategory) var sizeCategory @Environment(\.colorScheme) private var colorScheme - var node: NodeInfoEntity? + @ObservedObject var node: NodeInfoEntity @State var hasChanges = false @State var hasValidKey = true @@ -65,8 +65,8 @@ struct Channels: View { TipView(CreateChannelsTip(), arrowEdge: .bottom) .tipBackground(colorScheme == .dark ? Color(.systemBackground) : Color(.secondarySystemBackground)) .listRowSeparator(.hidden) - if node != nil && node?.myInfo != nil { - ForEach(node?.myInfo?.channels?.array as? [ChannelEntity] ?? [], id: \.self) { (channel: ChannelEntity) in + if node.myInfo != nil { + ForEach(node.myInfo?.channels?.array as? [ChannelEntity] ?? [], id: \.self) { (channel: ChannelEntity) in Button(action: { channelIndex = channel.index channelRole = Int(channel.role) @@ -177,7 +177,7 @@ struct Channels: View { selectedChannel!.downlinkEnabled = downlink selectedChannel!.positionPrecision = Int32(positionPrecision) - guard let mutableChannels = node?.myInfo?.channels?.mutableCopy() as? NSMutableOrderedSet else { + guard let mutableChannels = node.myInfo?.channels?.mutableCopy() as? NSMutableOrderedSet else { return } if mutableChannels.contains(selectedChannel as Any) { @@ -186,7 +186,7 @@ struct Channels: View { } else { mutableChannels.add(selectedChannel as Any) } - node?.myInfo?.channels = mutableChannels.copy() as? NSOrderedSet + node.myInfo?.channels = mutableChannels.copy() as? NSOrderedSet context.refresh(selectedChannel!, mergeChanges: true) if channel.role != Channel.Role.disabled { do { @@ -216,14 +216,14 @@ struct Channels: View { } } Task { - _ = try await accessoryManager.saveChannel(channel: channel, fromUser: node!.user!, toUser: node!.user!) + _ = try await accessoryManager.saveChannel(channel: channel, fromUser: node.user!, toUser: node.user!) Task { @MainActor in selectedChannel = nil channelName = "" channelRole = 2 hasChanges = false } - accessoryManager.mqttManager.connectFromConfigSettings(node: node!) + accessoryManager.mqttManager.connectFromConfigSettings(node: node) } } label: { Label("Save", systemImage: "square.and.arrow.down") @@ -246,10 +246,10 @@ struct Channels: View { #endif } } - if node?.myInfo?.channels?.array.count ?? 0 < 8 && node != nil { + if node.myInfo?.channels?.array.count ?? 0 < 8 { Button { - let channelIndexes = node?.myInfo?.channels?.compactMap({(ch) -> Int in + let channelIndexes = node.myInfo?.channels?.compactMap({(ch) -> Int in return (ch as AnyObject).index }) let firstChannelIndex = firstMissingChannelIndex(channelIndexes ?? []) diff --git a/Meshtastic/Views/Settings/Settings.swift b/Meshtastic/Views/Settings/Settings.swift index 32e59df3..8da2e195 100644 --- a/Meshtastic/Views/Settings/Settings.swift +++ b/Meshtastic/Views/Settings/Settings.swift @@ -532,7 +532,11 @@ struct Settings: View { case .lora: LoRaConfig(node: nodes.first(where: { $0.num == selectedNode })) case .channels: - Channels(node: node) + if let node = node { + Channels(node: node) + } else { + Text("Loading...") + } case .shareQRCode: ShareChannels(node: node) case .user: