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

@ -41,6 +41,7 @@ static_library(
"//submodules/AppBundle:AppBundle",
"//submodules/ContextUI:ContextUI",
"//submodules/PhoneNumberFormat:PhoneNumberFormat",
"//submodules/TelegramIntents:TelegramIntents",
],
frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework",

View File

@ -20,6 +20,7 @@ import LanguageSuggestionUI
import ContextUI
import AppBundle
import LocalizedPeerData
import TelegramIntents
public func useSpecialTabBarIcons() -> Bool {
return (Date(timeIntervalSince1970: 1545642000)...Date(timeIntervalSince1970: 1546387200)).contains(Date())
@ -122,9 +123,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
private var badgeIconDisposable: Disposable?
private var dismissSearchOnDisappear = false
private var didSetup3dTouch = false
private var passcodeLockTooltipDisposable = MetaDisposable()
private var didShowPasscodeLockTooltipController = false
@ -226,7 +225,6 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
}
strongSelf.chatListDisplayNode.chatListNode.scrollToPosition(.top)
}
//.auto for unread navigation
}
self.longTapWithTabBar = { [weak self] in
guard let strongSelf = self else {
@ -760,17 +758,6 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
self.displayNodeDidLoad()
}
override public func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
if #available(iOSApplicationExtension 9.0, iOS 9.0, *) {
if !self.didSetup3dTouch && self.traitCollection.forceTouchCapability != .unknown {
self.didSetup3dTouch = true
//self.registerForPreviewingNonNative(with: self, sourceView: self.view, theme: PeekControllerTheme(presentationTheme: self.presentationData.theme))
}
}
}
override public func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
@ -884,13 +871,6 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
return true
})
}
if #available(iOSApplicationExtension 9.0, iOS 9.0, *) {
if !self.didSetup3dTouch {
self.didSetup3dTouch = true
//self.registerForPreviewingNonNative(with: self, sourceView: self.view, theme: PeekControllerTheme(presentationTheme: self.presentationData.theme))
}
}
}
override public func viewWillDisappear(_ animated: Bool) {
@ -1634,6 +1614,10 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
}
strongSelf.chatListDisplayNode.chatListNode.setCurrentRemovingPeerId(nil)
for peerId in peerIds {
deleteSendMessageIntents(account: strongSelf.context.account, peerId: peerId)
}
let action: (Bool) -> Void = { shouldCommit in
guard let strongSelf = self else {
return
@ -1755,7 +1739,9 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
state.pendingRemovalPeerIds.remove(peer.peerId)
return state
})
self?.chatListDisplayNode.chatListNode.setCurrentRemovingPeerId(nil)
strongSelf.chatListDisplayNode.chatListNode.setCurrentRemovingPeerId(nil)
deleteSendMessageIntents(account: strongSelf.context.account, peerId: peerId)
})
completion()
} else {
@ -1765,7 +1751,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
state.pendingRemovalPeerIds.remove(peer.peerId)
return state
})
self?.chatListDisplayNode.chatListNode.setCurrentRemovingPeerId(nil)
strongSelf.chatListDisplayNode.chatListNode.setCurrentRemovingPeerId(nil)
}
}), in: .current)
}

View File

@ -61,6 +61,7 @@ static_library(
"//submodules/AppBundle:AppBundle",
"//submodules/Markdown:Markdown",
"//submodules/PhoneNumberFormat:PhoneNumberFormat",
"//submodules/TelegramIntents:TelegramIntents",
],
frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework",

View File

@ -27,6 +27,7 @@ import NotificationSoundSelectionUI
import Markdown
import LocalizedPeerData
import PhoneNumberFormat
import TelegramIntents
private final class UserInfoControllerArguments {
let account: Account
@ -1026,6 +1027,8 @@ public func userInfoController(context: AccountContext, peerId: PeerId, mode: Pe
} else if reportSpam {
let _ = reportPeer(account: context.account, peerId: peerId, reason: .spam).start()
}
deleteSendMessageIntents(account: context.account, peerId: peerId)
})
]),
ActionSheetItemGroup(items: [ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, action: { dismissAction() })])
@ -1094,6 +1097,8 @@ public func userInfoController(context: AccountContext, peerId: PeerId, mode: Pe
|> deliverOnMainQueue).start(completed: {
dismissImpl?()
}))
deleteSendMessageIntents(account: context.account, peerId: peerId)
})
})
]),

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)

View File

@ -23,7 +23,7 @@ static_library(
"//submodules/ActivityIndicator:ActivityIndicator",
"//submodules/AppBundle:AppBundle",
"//submodules/TelegramStringFormatting:TelegramStringFormatting",
"//submodules/AppIntents:AppIntents",
"//submodules/TelegramIntents:TelegramIntents",
],
frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework",

View File

@ -8,7 +8,7 @@ import TelegramCore
import SyncCore
import TelegramPresentationData
import AccountContext
import AppIntents
import TelegramIntents
enum ShareState {
case preparing

View File

@ -1,7 +1,7 @@
load("//Config:buck_rule_macros.bzl", "static_library")
static_library(
name = "AppIntents",
name = "TelegramIntents",
srcs = glob([
"Sources/**/*.swift",
]),

View File

@ -82,8 +82,7 @@ public func donateSendMessageIntent(account: Account, sharedContext: SharedAccou
continue
}
subject = .savedMessages
}
if transaction.isPeerContact(peerId: peerId) {
} else if transaction.isPeerContact(peerId: peerId) {
if !settings.contacts {
continue
}
@ -169,7 +168,7 @@ public func donateSendMessageIntent(account: Account, sharedContext: SharedAccou
}
let interaction = INInteraction(intent: intent, response: nil)
interaction.direction = .outgoing
//interaction.identifier = "sendMessage_\(account.peerId.toInt64())_\(peer.id.toInt64)"
interaction.identifier = "sendMessage_\(account.peerId.toInt64())_\(peer.id.toInt64)"
interaction.groupIdentifier = "sendMessage_\(subject.toString())_\(account.peerId.toInt64())"
interaction.donate()
}

View File

@ -197,7 +197,7 @@ framework(
"//submodules/AppLock:AppLock",
"//submodules/NotificationsPresentationData:NotificationsPresentationData",
"//submodules/UrlWhitelist:UrlWhitelist",
"//submodules/AppIntents:AppIntents",
"//submodules/TelegramIntents:TelegramIntents",
"//submodules/LocationResources:LocationResources",
"//submodules/ItemListVenueItem:ItemListVenueItem",
"//submodules/SemanticStatusNode:SemanticStatusNode",

View File

@ -33,7 +33,7 @@ import WalletCore
import OpenSSLEncryptionProvider
import AppLock
import PresentationDataUtils
import AppIntents
import TelegramIntents
import AccountUtils
#if canImport(BackgroundTasks)

View File

@ -55,7 +55,7 @@ import LocalizedPeerData
import PhoneNumberFormat
import SettingsUI
import UrlWhitelist
import AppIntents
import TelegramIntents
public enum ChatControllerPeekActions {
case standard

View File

@ -88,8 +88,10 @@ public struct IntentsSettings: PreferencesEntry, Equatable {
}
public func updateIntentsSettingsInteractively(accountManager: AccountManager, _ f: @escaping (IntentsSettings) -> IntentsSettings) -> Signal<Void, NoError> {
return accountManager.transaction { transaction -> Void in
public func updateIntentsSettingsInteractively(accountManager: AccountManager, _ f: @escaping (IntentsSettings) -> IntentsSettings) -> Signal<(IntentsSettings?, IntentsSettings?), NoError> {
return accountManager.transaction { transaction -> (IntentsSettings?, IntentsSettings?) in
var previousSettings: IntentsSettings? = nil
var updatedSettings: IntentsSettings? = nil
transaction.updateSharedData(ApplicationSpecificSharedDataKeys.intentsSettings, { entry in
let currentSettings: IntentsSettings
if let entry = entry as? IntentsSettings {
@ -97,7 +99,10 @@ public func updateIntentsSettingsInteractively(accountManager: AccountManager, _
} else {
currentSettings = IntentsSettings.defaultSettings
}
return f(currentSettings)
previousSettings = currentSettings
updatedSettings = f(currentSettings)
return updatedSettings
})
return (previousSettings, updatedSettings)
}
}