mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Load unread message state when the app loads.
This commit is contained in:
parent
38501624c2
commit
0598b26f53
2 changed files with 10 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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?
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue