diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 88b00ce4..4e5db2f0 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -614,10 +614,17 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate do { let fetchedNodeInfo = try context?.fetch(fetchNodeInfoRequest) as? [NodeInfoEntity] ?? [] if fetchedNodeInfo.count == 1 && fetchedNodeInfo[0].mqttConfig != nil { - //Subscribe to Mqtt Client Proxy if enabled - if fetchedNodeInfo[0].mqttConfig?.proxyToClientEnabled ?? false { + // Subscribe to Mqtt Client Proxy if enabled + if fetchedNodeInfo[0].mqttConfig?.enabled ?? false && fetchedNodeInfo[0].mqttConfig?.proxyToClientEnabled ?? false { mqttManager.connectFromConfigSettings(node: fetchedNodeInfo[0]) } + // Set initial unread message badge states + var appState = AppState.shared + appState.unreadChannelMessages = fetchedNodeInfo[0].myInfo?.unreadMessages ?? 0 + appState.unreadDirectMessages = fetchedNodeInfo[0].user?.unreadMessages ?? 0 + appState.connectedNode = fetchedNodeInfo[0] + UIApplication.shared.applicationIconBadgeNumber = appState.unreadChannelMessages + appState.unreadDirectMessages + } if fetchedNodeInfo.count == 1 && fetchedNodeInfo[0].rangeTestConfig?.enabled == true { wantRangeTestPackets = true; diff --git a/Meshtastic/MeshtasticApp.swift b/Meshtastic/MeshtasticApp.swift index d92d14b9..6092371e 100644 --- a/Meshtastic/MeshtasticApp.swift +++ b/Meshtastic/MeshtasticApp.swift @@ -124,4 +124,5 @@ class AppState: ObservableObject { @Published var tabSelection: Tab = .ble @Published var unreadDirectMessages: Int = 0 @Published var unreadChannelMessages: Int = 0 + @Published var connectedNode: NodeInfoEntity? }