Remove corresponding share suggestion on chat deletion, leaving, archiving and contact removal

This commit is contained in:
Ilya Laktyushin
2019-11-27 18:46:32 +04:00
parent 8162bd5ae8
commit f1664fa0ba
14 changed files with 55 additions and 38 deletions

View File

@@ -9,7 +9,7 @@ import TelegramUIPreferences
import ItemListUI
import ItemListPeerItem
import AccountContext
import AppIntents
import TelegramIntents
import AccountUtils
private final class IntentsSettingsControllerArguments {
@@ -268,7 +268,27 @@ public func intentsSettingsController(context: AccountContext) -> ViewController
let updateDisposable = MetaDisposable()
let arguments = IntentsSettingsControllerArguments(context: context, updateSettings: { f in
let _ = updateIntentsSettingsInteractively(accountManager: context.sharedContext.accountManager, f).start()
let _ = updateIntentsSettingsInteractively(accountManager: context.sharedContext.accountManager, f).start(next: { previous, updated in
guard let previous = previous, let updated = updated else {
return
}
let accountPeerId = context.account.peerId
if previous.contacts && !updated.contacts {
deleteAllSendMessageIntents(accountPeerId: accountPeerId, subject: .contact)
}
if previous.savedMessages && !updated.savedMessages {
deleteAllSendMessageIntents(accountPeerId: accountPeerId, subject: .savedMessages)
}
if previous.privateChats && !updated.privateChats {
deleteAllSendMessageIntents(accountPeerId: accountPeerId, subject: .privateChat)
}
if previous.groups && !updated.groups {
deleteAllSendMessageIntents(accountPeerId: accountPeerId, subject: .group)
}
if previous.account != updated.account, let previousAccount = previous.account {
deleteAllSendMessageIntents(accountPeerId: previousAccount)
}
})
}, resetAll: {
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
let actionSheet = ActionSheetController(presentationData: presentationData)