Merge pull request #2809 from nextcloud/fix/noid/receive-messages-history-userstatu

fix: Receive messages history userstatus
This commit is contained in:
Ivan Sein authored and GitHub committed 2026-11-05 11:45:00 +01:00
commit 8ec16c3a7b
3 files changed
+18 -2

No files matched your search

+1 -1
View File
@@ -826,7 +826,7 @@ public class NCChatController: NSObject {
self.pullMessagesTask?.cancel()
}
pullMessagesTask = NCAPIController.sharedInstance().receiveChatMessages(ofRoom: room.token, fromLastMessageId: lastChatBlock?.newestMessageId ?? 0, inThread: threadId, history: false, includeLastMessage: false, timeout: false, limit: NCAPIController.shared.kReceivedChatMessagesLimit, lastCommonReadMessage: room.lastCommonReadMessage, setReadMarker: false, markNotificationsAsRead: false, forAccount: account) { messages, lastKnownMessage, lastCommonReadMessage, error, _ in
pullMessagesTask = NCAPIController.sharedInstance().receiveChatMessages(ofRoom: room.token, fromLastMessageId: lastChatBlock?.newestMessageId ?? 0, inThread: threadId, history: false, includeLastMessage: false, timeout: false, limit: NCAPIController.shared.kReceivedChatMessagesLimit, lastCommonReadMessage: room.lastCommonReadMessage, setReadMarker: false, markNotificationsAsRead: false, updateStatus: false, forAccount: account) { messages, lastKnownMessage, lastCommonReadMessage, error, _ in
if expired {
completion?(error)
bgTask.stopBackgroundTask()
@@ -2684,6 +2684,7 @@ class NCAPIController: NSObject, NKCommonDelegate {
lastCommonReadMessage: Int,
setReadMarker: Bool,
markNotificationsAsRead: Bool,
updateStatus: Bool = true,
forAccount account: TalkAccount,
completionBlock: @escaping (_ messages: [[String: Any]]?, _ lastKnownMessage: Int, _ lastCommonReadMessage: Int, _ error: OcsError?, _ statusCode: Int) -> Void) -> URLSessionDataTask? {
@@ -2708,6 +2709,7 @@ class NCAPIController: NSObject, NKCommonDelegate {
"setReadMarker": setReadMarker ? 1 : 0,
"includeLastKnown": includeLastMessage ? 1 : 0,
"markNotificationsAsRead": markNotificationsAsRead ? 1 : 0,
"noStatusUpdate": updateStatus ? 0 : 1,
"threadId": threadId
]
@@ -159,6 +159,7 @@ class RoomsTableViewController: UITableViewController, CCCertificateDelegate, UI
notificationCenter.addObserver(self, selector: #selector(serverCapabilitiesUpdated(_:)), name: .NCServerCapabilitiesUpdated, object: nil)
notificationCenter.addObserver(self, selector: #selector(userProfileImageUpdated(_:)), name: .NCUserProfileImageUpdated, object: nil)
notificationCenter.addObserver(self, selector: #selector(appWillEnterForeground(_:)), name: UIApplication.willEnterForegroundNotification, object: nil)
notificationCenter.addObserver(self, selector: #selector(appDidBecomeActive(_:)), name: UIApplication.didBecomeActiveNotification, object: nil)
notificationCenter.addObserver(self, selector: #selector(appWillResignActive(_:)), name: UIApplication.willResignActiveNotification, object: nil)
notificationCenter.addObserver(self, selector: #selector(roomCreated(_:)), name: .NCRoomCreated, object: nil)
notificationCenter.addObserver(self, selector: #selector(activeAccountDidChange(_:)), name: .NCSettingsControllerDidChangeActiveAccount, object: nil)
@@ -450,6 +451,14 @@ class RoomsTableViewController: UITableViewController, CCCertificateDelegate, UI
}
}
@objc private func appDidBecomeActive(_ notification: Notification) {
// Returning from Control Center or a system alert posts no willEnterForeground, so nothing else restarts the timer
guard refreshRoomsTimer == nil, NCConnectionController.shared.appState == .ready, viewIfLoaded?.window != nil else { return }
refreshRooms()
startRefreshRoomsTimer()
}
@objc private func appWillResignActive(_ notification: Notification) {
stopRefreshRoomsTimer()
self.tableView.contextMenuInteraction?.dismissMenu()
@@ -1252,7 +1261,12 @@ class RoomsTableViewController: UITableViewController, CCCertificateDelegate, UI
updateUserStatus()
getUserThreads()
refreshConversationTags()
startRefreshRoomsTimer()
// Reachability changes also land here in the background, the timer would then bump the user status on every later wake
if UIApplication.shared.applicationState != .background {
startRefreshRoomsTimer()
}
setupNavigationBar()
default:
break