Browse Source

remove donated siri message intents, if account gets switched, if a chat gets deleted, if a contact gets deleted

cyberta 4 năm trước cách đây
mục cha
commit
3b989251bb

+ 2 - 1
DcCore/DcCore/Helper/DcUtils.swift

@@ -22,7 +22,7 @@ public struct DcUtils {
             let sendMessageIntent = INSendMessageIntent(recipients: nil,
                                                         content: nil,
                                                         speakableGroupName: groupName,
-                                                        conversationIdentifier: "\(chat.id)",
+                                                        conversationIdentifier: "\(context.id).\(chatId)",
                                                         serviceName: nil,
                                                         sender: nil)
 
@@ -34,6 +34,7 @@ public struct DcUtils {
 
             // Donate the intent.
             let interaction = INInteraction(intent: sendMessageIntent, response: nil)
+            interaction.groupIdentifier = "\(context.id)"
             interaction.donate(completion: { error in
                 if error != nil {
                     context.logger?.error(error.debugDescription)

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

@@ -1,5 +1,6 @@
 import UIKit
 import DcCore
+import Intents
 
 // this is also used as ChatDetail for SingleChats
 class ContactDetailViewController: UITableViewController {
@@ -430,6 +431,7 @@ class ContactDetailViewController: UITableViewController {
         }
         viewModel.context.deleteChat(chatId: viewModel.chatId)
         NotificationManager.removeNotificationsForChat(dcContext: viewModel.context, chatId: viewModel.chatId)
+        INInteraction.delete(with: ["\(viewModel.context.id).\(viewModel.chatId)"])
 
         // just pop to viewControllers - we've in chatlist or archive then
         // (no not use `navigationController?` here: popping self will make the reference becoming nil)

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

@@ -1,6 +1,7 @@
 import UIKit
 import DcCore
 import QuickLook
+import Intents
 
 class GroupChatDetailViewController: UIViewController {
 
@@ -327,6 +328,7 @@ class GroupChatDetailViewController: UIViewController {
     private func deleteChat() {
         dcContext.deleteChat(chatId: chatId)
         NotificationManager.removeNotificationsForChat(dcContext: dcContext, chatId: chatId)
+        INInteraction.delete(with: ["\(dcContext.id).\(chatId)"])
 
         // just pop to viewControllers - we've in chatlist or archive then
         // (no not use `navigationController?` here: popping self will make the reference becoming nil)

+ 2 - 0
deltachat-ios/Controller/SettingsController.swift

@@ -1,6 +1,7 @@
 import UIKit
 import DcCore
 import DBDebugToolkit
+import Intents
 
 internal final class SettingsViewController: UITableViewController, ProgressAlertHandler {
 
@@ -484,6 +485,7 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
                     guard let self = self else { return }
                     appDelegate.locationManager.disableLocationStreamingInAllChats()
                     _ = self.dcAccounts.remove(id: selectedAccountId)
+                    INInteraction.delete(with: "\(selectedAccountId)", completion: nil)
                     if self.dcAccounts.getAll().isEmpty {
                         _ = self.dcAccounts.add()
                     }

+ 2 - 0
deltachat-ios/ViewModel/ChatListViewModel.swift

@@ -1,5 +1,6 @@
 import UIKit
 import DcCore
+import Intents
 
 
 // MARK: - ChatListViewModel
@@ -178,6 +179,7 @@ class ChatListViewModel: NSObject {
     func deleteChat(chatId: Int) {
         dcContext.deleteChat(chatId: chatId)
         NotificationManager.removeNotificationsForChat(dcContext: dcContext, chatId: chatId)
+        INInteraction.delete(with: ["\(dcContext.id).\(chatId)"])
     }
 
     func archiveChatToggle(chatId: Int) {