Sfoglia il codice sorgente

don't update search results if app is not in foreground, search involves debouncing, which might exceed the available background time

cyberta 3 anni fa
parent
commit
a20ff8c944
1 ha cambiato i file con 5 aggiunte e 3 eliminazioni
  1. 5 3
      deltachat-ios/Controller/ChatListController.swift

+ 5 - 3
deltachat-ios/Controller/ChatListController.swift

@@ -87,15 +87,17 @@ class ChatListController: UITableViewController {
             object: nil,
             queue: nil) { [weak self] _ in
             guard let self = self else { return }
-            if self.viewModel.searchActive {
+            if let appDelegate = UIApplication.shared.delegate as? AppDelegate,
+               self.viewModel.searchActive,
+               appDelegate.appIsInForeground() {
                 self.viewModel.updateSearchResults(for: self.searchController)
             }
         }
     }
 
     deinit {
-        if let msgChagnedResultObserver = self.msgChangedSearchResultObserver {
-            NotificationCenter.default.removeObserver(msgChagnedResultObserver)
+        if let msgChangedResultObserver = self.msgChangedSearchResultObserver {
+            NotificationCenter.default.removeObserver(msgChangedResultObserver)
         }
     }