diff --git a/apps/ios/Shared/Views/ChatList/ChatListView.swift b/apps/ios/Shared/Views/ChatList/ChatListView.swift index 984dc64892..cc74d9657b 100644 --- a/apps/ios/Shared/Views/ChatList/ChatListView.swift +++ b/apps/ios/Shared/Views/ChatList/ChatListView.swift @@ -605,7 +605,8 @@ struct SubsStatusIndicator: View { task = Task { logger.debug("SUBS_TRACE poll loop: started") while !Task.isCancelled { - let appActive = AppChatState.shared.value == .active + let appState = AppChatState.shared.value + let appActive = appState == .active let running = ChatModel.shared.chatRunning == true if appActive, running { do { @@ -620,7 +621,7 @@ struct SubsStatusIndicator: View { logger.error("getSubsTotal error: \(responseError(error))") } } else { - logger.debug("SUBS_TRACE poll skipped tick: appActive=\(appActive) chatRunning=\(running) (gated out, not fetching)") + logger.debug("SUBS_TRACE poll skipped tick: appState=\(appState.rawValue) appActive=\(appActive) chatRunning=\(running) (gated out, not fetching)") } try? await Task.sleep(nanoseconds: 1_000_000_000) // Sleep for 1 second } diff --git a/apps/ios/SimpleXChat/API.swift b/apps/ios/SimpleXChat/API.swift index 6bf46fb0dd..0b281f6850 100644 --- a/apps/ios/SimpleXChat/API.swift +++ b/apps/ios/SimpleXChat/API.swift @@ -114,9 +114,17 @@ public func resetChatCtrl() { @inline(__always) public func sendSimpleXCmd(_ cmd: ChatCmdProtocol, _ ctrl: chat_ctrl? = nil, retryNum: Int32 = 0) -> APIResult { if let d = sendSimpleXCmdStr(cmd.cmdString, ctrl, retryNum: retryNum) { - decodeAPIResult(d) + // SUBS_TRACE: log the exact bytes the core sends back for the subs-total query, + // before any decoding — this is what the UI actually receives from the core. + if cmd.cmdString.hasPrefix("/get subs total") { + logger.debug("SUBS_TRACE raw core->UI for '\(cmd.cmdString)': \(dataToString(d))") + } + return decodeAPIResult(d) } else { - APIResult.error(.invalidJSON(json: nil)) + if cmd.cmdString.hasPrefix("/get subs total") { + logger.debug("SUBS_TRACE raw core->UI for '\(cmd.cmdString)': nil (core returned no data)") + } + return APIResult.error(.invalidJSON(json: nil)) } }