浏览代码

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

cyberta 3 年之前
父节点
当前提交
a20ff8c944
共有 1 个文件被更改,包括 5 次插入3 次删除
  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)
         }
     }