Răsfoiți Sursa

really start background-thread

B. Petersen 4 ani în urmă
părinte
comite
551dc717ea

+ 4 - 4
deltachat-ios/Chat/ChatViewController.swift

@@ -268,7 +268,7 @@ class ChatViewController: UITableViewController {
 
         // things that do not affect the chatview
         // and are delayed after the view is displayed
-        DispatchQueue.main.async { [weak self] in
+        DispatchQueue.global(qos: .background).async { [weak self] in
             guard let self = self else { return }
             self.dcContext.marknoticedChat(chatId: self.chatId)
         }
@@ -397,7 +397,7 @@ class ChatViewController: UITableViewController {
         if let indexPaths = tableView.indexPathsForVisibleRows {
             let visibleMessagesIds = indexPaths.map { UInt32(messageIds[$0.row]) }
             if !visibleMessagesIds.isEmpty {
-                DispatchQueue.main.async { [weak self] in
+                DispatchQueue.global(qos: .background).async { [weak self] in
                     self?.dcContext.markSeenMessages(messageIds: visibleMessagesIds)
                 }
             }
@@ -865,7 +865,7 @@ class ChatViewController: UITableViewController {
 
     func updateMessage(_ messageId: Int) {
         if messageIds.firstIndex(where: { $0 == messageId }) != nil {
-            DispatchQueue.main.async { [weak self] in
+            DispatchQueue.global(qos: .background).async { [weak self] in
                 self?.dcContext.markSeenMessages(messageIds: [UInt32(messageId)])
             }
             let wasLastSectionVisible = self.isLastRowVisible()
@@ -882,7 +882,7 @@ class ChatViewController: UITableViewController {
     }
 
     func insertMessage(_ message: DcMsg) {
-        DispatchQueue.main.async { [weak self] in
+        DispatchQueue.global(qos: .background).async { [weak self] in
             self?.dcContext.markSeenMessages(messageIds: [UInt32(message.id)])
         }
         messageIds.append(message.id)

+ 2 - 2
deltachat-ios/Controller/ChatListController.swift

@@ -348,12 +348,12 @@ class ChatListController: UITableViewController {
             self.showChat(chatId: chat.id)
         }))
         alert.addAction(UIAlertAction(title: String.localized("not_now"), style: .default, handler: { _ in
-            DispatchQueue.main.async {
+            DispatchQueue.global(qos: .background).async {
                 dcContact.marknoticed()
             }
         }))
         alert.addAction(UIAlertAction(title: String.localized("menu_block_contact"), style: .destructive, handler: { _ in
-            DispatchQueue.main.async {
+            DispatchQueue.global(qos: .background).async {
                 dcContact.block()
             }
         }))