@@ -173,7 +173,9 @@ class ChatListController: UITableViewController {
@objc func applicationDidBecomeActive(_ notification: NSNotification) {
if navigationController?.visibleViewController == self {
startTimer()
- viewModel.refreshData()
+ DispatchQueue.global(qos: .userInteractive).async { [weak self] in
+ self?.viewModel.refreshData()
+ }
}
@@ -79,8 +79,14 @@ class ChatListViewModel: NSObject, ChatListViewModelProtocol {
gclFlags |= DC_GCL_FOR_FORWARDING
self.chatList = dcContext.getChatlist(flags: gclFlags, queryString: nil, queryId: 0)
- if notifyListener {
- onChatListUpdate?()
+ if notifyListener, let onChatListUpdate = onChatListUpdate {
+ if Thread.isMainThread {
+ onChatListUpdate()
+ } else {
+ DispatchQueue.main.async {