Browse Source

fix direct share short cuts preselecting correct chat

cyberta 4 years ago
parent
commit
5805299456
1 changed files with 7 additions and 2 deletions
  1. 7 2
      DcShare/Controller/ShareViewController.swift

+ 7 - 2
DcShare/Controller/ShareViewController.swift

@@ -82,8 +82,13 @@ class ShareViewController: SLComposeServiceViewController {
         isAccountConfigured = dcContext.isConfigured()
         if isAccountConfigured {
             if #available(iOSApplicationExtension 13.0, *) {
-               if let intent = self.extensionContext?.intent as? INSendMessageIntent, let chatId = Int(intent.conversationIdentifier ?? "") {
-                   selectedChatId = chatId
+                if let intent = self.extensionContext?.intent as? INSendMessageIntent,
+                   let identifiers = intent.conversationIdentifier?.split(separator: ".") {
+                    let contextId = Int(identifiers[0])
+                    let chatId = Int(identifiers[1])
+                    if dcContext.id == contextId {
+                        selectedChatId = chatId
+                    }
                }
             }