mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix intents donation
This commit is contained in:
parent
82d850506e
commit
315eb736b6
@ -1615,7 +1615,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
|
|||||||
strongSelf.chatListDisplayNode.chatListNode.setCurrentRemovingPeerId(nil)
|
strongSelf.chatListDisplayNode.chatListNode.setCurrentRemovingPeerId(nil)
|
||||||
|
|
||||||
for peerId in peerIds {
|
for peerId in peerIds {
|
||||||
deleteSendMessageIntents(account: strongSelf.context.account, peerId: peerId)
|
deleteSendMessageIntents(peerId: peerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
let action: (Bool) -> Void = { shouldCommit in
|
let action: (Bool) -> Void = { shouldCommit in
|
||||||
@ -1741,7 +1741,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
|
|||||||
})
|
})
|
||||||
strongSelf.chatListDisplayNode.chatListNode.setCurrentRemovingPeerId(nil)
|
strongSelf.chatListDisplayNode.chatListNode.setCurrentRemovingPeerId(nil)
|
||||||
|
|
||||||
deleteSendMessageIntents(account: strongSelf.context.account, peerId: peerId)
|
deleteSendMessageIntents(peerId: peerId)
|
||||||
})
|
})
|
||||||
completion()
|
completion()
|
||||||
} else {
|
} else {
|
||||||
|
@ -1028,7 +1028,7 @@ public func userInfoController(context: AccountContext, peerId: PeerId, mode: Pe
|
|||||||
let _ = reportPeer(account: context.account, peerId: peerId, reason: .spam).start()
|
let _ = reportPeer(account: context.account, peerId: peerId, reason: .spam).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteSendMessageIntents(account: context.account, peerId: peerId)
|
deleteSendMessageIntents(peerId: peerId)
|
||||||
})
|
})
|
||||||
]),
|
]),
|
||||||
ActionSheetItemGroup(items: [ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, action: { dismissAction() })])
|
ActionSheetItemGroup(items: [ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, action: { dismissAction() })])
|
||||||
@ -1098,7 +1098,7 @@ public func userInfoController(context: AccountContext, peerId: PeerId, mode: Pe
|
|||||||
dismissImpl?()
|
dismissImpl?()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
deleteSendMessageIntents(account: context.account, peerId: peerId)
|
deleteSendMessageIntents(peerId: peerId)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
]),
|
]),
|
||||||
|
@ -274,19 +274,19 @@ public func intentsSettingsController(context: AccountContext) -> ViewController
|
|||||||
}
|
}
|
||||||
let accountPeerId = context.account.peerId
|
let accountPeerId = context.account.peerId
|
||||||
if previous.contacts && !updated.contacts {
|
if previous.contacts && !updated.contacts {
|
||||||
deleteAllSendMessageIntents(accountPeerId: accountPeerId, subject: .contact)
|
deleteAllSendMessageIntents()
|
||||||
}
|
}
|
||||||
if previous.savedMessages && !updated.savedMessages {
|
if previous.savedMessages && !updated.savedMessages {
|
||||||
deleteAllSendMessageIntents(accountPeerId: accountPeerId, subject: .savedMessages)
|
deleteAllSendMessageIntents()
|
||||||
}
|
}
|
||||||
if previous.privateChats && !updated.privateChats {
|
if previous.privateChats && !updated.privateChats {
|
||||||
deleteAllSendMessageIntents(accountPeerId: accountPeerId, subject: .privateChat)
|
deleteAllSendMessageIntents()
|
||||||
}
|
}
|
||||||
if previous.groups && !updated.groups {
|
if previous.groups && !updated.groups {
|
||||||
deleteAllSendMessageIntents(accountPeerId: accountPeerId, subject: .group)
|
deleteAllSendMessageIntents()
|
||||||
}
|
}
|
||||||
if previous.account != updated.account, let previousAccount = previous.account {
|
if previous.account != updated.account, let previousAccount = previous.account {
|
||||||
deleteAllSendMessageIntents(accountPeerId: previousAccount)
|
deleteAllSendMessageIntents()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, resetAll: {
|
}, resetAll: {
|
||||||
|
@ -181,8 +181,7 @@ public func donateSendMessageIntent(account: Account, sharedContext: SharedAccou
|
|||||||
}
|
}
|
||||||
let interaction = INInteraction(intent: intent, response: nil)
|
let interaction = INInteraction(intent: intent, response: nil)
|
||||||
interaction.direction = .outgoing
|
interaction.direction = .outgoing
|
||||||
interaction.identifier = "sendMessage_\(account.peerId.toInt64())_\(peer.id.toInt64())"
|
interaction.groupIdentifier = "sendMessage_\(peer.id.toInt64())"
|
||||||
interaction.groupIdentifier = "sendMessage_\(subject.toString())_\(account.peerId.toInt64())"
|
|
||||||
interaction.donate { error in
|
interaction.donate { error in
|
||||||
if let error = error {
|
if let error = error {
|
||||||
print(error)
|
print(error)
|
||||||
@ -193,25 +192,14 @@ public func donateSendMessageIntent(account: Account, sharedContext: SharedAccou
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func deleteSendMessageIntents(account: Account, peerId: PeerId) {
|
public func deleteSendMessageIntents(peerId: PeerId) {
|
||||||
if #available(iOS 10.0, *) {
|
if #available(iOS 10.0, *) {
|
||||||
INInteraction.delete(with: ["sendMessage_\(account.peerId.toInt64())_\(peerId.toInt64())"])
|
INInteraction.delete(with: "sendMessage_\(peerId.toInt64())")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func deleteAllSendMessageIntents(accountPeerId: PeerId? = nil, subject: SendMessageIntentSubject? = nil) {
|
public func deleteAllSendMessageIntents() {
|
||||||
if #available(iOS 10.0, *) {
|
if #available(iOS 10.0, *) {
|
||||||
if let peerId = accountPeerId {
|
INInteraction.deleteAll()
|
||||||
if let subject = subject {
|
|
||||||
INInteraction.delete(with: "sendMessage_\(subject.toString())_\(peerId.toInt64())")
|
|
||||||
} else {
|
|
||||||
INInteraction.delete(with: "sendMessage_\(peerId.toInt64())")
|
|
||||||
for subject in SendMessageIntentSubject.allCases {
|
|
||||||
INInteraction.delete(with: "sendMessage_\(subject.toString())_\(peerId.toInt64())")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
INInteraction.deleteAll()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1232,14 +1232,12 @@ final class SharedApplicationContext {
|
|||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for peerId in loggedOutAccountPeerIds {
|
|
||||||
deleteAllSendMessageIntents(accountPeerId: peerId)
|
|
||||||
}
|
|
||||||
|
|
||||||
let _ = (updateIntentsSettingsInteractively(accountManager: accountManager) { current in
|
let _ = (updateIntentsSettingsInteractively(accountManager: accountManager) { current in
|
||||||
var updated = current
|
var updated = current
|
||||||
for peerId in loggedOutAccountPeerIds {
|
for peerId in loggedOutAccountPeerIds {
|
||||||
if peerId == updated.account {
|
if peerId == updated.account {
|
||||||
|
deleteAllSendMessageIntents()
|
||||||
updated = updated.withUpdatedAccount(nil)
|
updated = updated.withUpdatedAccount(nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -202,8 +202,8 @@ public class ShareRootControllerImpl {
|
|||||||
if #available(iOS 13.2, *), let sendMessageIntent = self.getExtensionContext()?.intent as? INSendMessageIntent {
|
if #available(iOS 13.2, *), let sendMessageIntent = self.getExtensionContext()?.intent as? INSendMessageIntent {
|
||||||
if let contact = sendMessageIntent.recipients?.first, let handle = contact.customIdentifier, handle.hasPrefix("tg") {
|
if let contact = sendMessageIntent.recipients?.first, let handle = contact.customIdentifier, handle.hasPrefix("tg") {
|
||||||
let string = handle.suffix(from: handle.index(handle.startIndex, offsetBy: 2))
|
let string = handle.suffix(from: handle.index(handle.startIndex, offsetBy: 2))
|
||||||
if let userId = Int32(string) {
|
if let peerId = Int64(string) {
|
||||||
immediatePeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
immediatePeerId = PeerId(peerId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user