Kaynağa Gözat

Merge pull request #1596 from deltachat/conditional_chatlist_update

emit DC_MSGS_CHANGED event after sharing from Delta to Delta
cyBerta 3 yıl önce
ebeveyn
işleme
8689abb1b2

+ 16 - 12
deltachat-ios/AppDelegate.swift

@@ -203,18 +203,22 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                 self.dcAccounts.maybeNetwork()
             }
 
-            if let userDefaults = UserDefaults.shared, userDefaults.bool(forKey: UserDefaults.hasExtensionAttemptedToSend) {
-                userDefaults.removeObject(forKey: UserDefaults.hasExtensionAttemptedToSend)
-                DispatchQueue.main.async {
-                    NotificationCenter.default.post(
-                        name: dcNotificationChanged,
-                        object: nil,
-                        userInfo: [
-                            "message_id": Int(0),
-                            "chat_id": Int(0),
-                        ]
-                    )
-                }
+            AppDelegate.emitMsgsChangedIfShareExtensionWasUsed()
+        }
+    }
+
+    static func emitMsgsChangedIfShareExtensionWasUsed() {
+        if let userDefaults = UserDefaults.shared, userDefaults.bool(forKey: UserDefaults.hasExtensionAttemptedToSend) {
+            userDefaults.removeObject(forKey: UserDefaults.hasExtensionAttemptedToSend)
+            DispatchQueue.main.async {
+                NotificationCenter.default.post(
+                    name: dcNotificationChanged,
+                    object: nil,
+                    userInfo: [
+                        "message_id": Int(0),
+                        "chat_id": Int(0),
+                    ]
+                )
             }
         }
     }

+ 3 - 0
deltachat-ios/Controller/ContactDetailViewController.swift

@@ -125,6 +125,9 @@ class ContactDetailViewController: UITableViewController {
         updateHeader() // maybe contact name has been edited
         updateCellValues()
         tableView.reloadData()
+
+        // see comment in GroupChatDetailViewController.viewWillAppear()
+        AppDelegate.emitMsgsChangedIfShareExtensionWasUsed()
     }
 
     override func viewWillDisappear(_ animated: Bool) {

+ 5 - 0
deltachat-ios/Controller/GroupChatDetailViewController.swift

@@ -218,6 +218,11 @@ class GroupChatDetailViewController: UIViewController {
         updateHeader()
         updateMediaCellValues()
         updateEphemeralTimerCellValue()
+
+        // when sharing to ourself in DocumentGalleryController,
+        // end of sharing is not easily catchable nor results in applicationWillEnterForeground();
+        // therefore, do the update here.
+        AppDelegate.emitMsgsChangedIfShareExtensionWasUsed()
     }