mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix haptic delay when sharing to saved messages
This commit is contained in:
parent
b8f0bb1620
commit
824e887294
@ -128,6 +128,8 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
||||
|
||||
private weak var copyProtectionTooltipController: TooltipController?
|
||||
|
||||
private lazy var hapticFeedback = { HapticFeedback() }()
|
||||
|
||||
private var didSetReady: Bool = false
|
||||
private let _ready = Promise<Void>()
|
||||
public override func ready() -> Signal<Void, NoError> {
|
||||
@ -1392,6 +1394,10 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
||||
let peerId = peer.id
|
||||
if let strongSelf = self, let _ = peerSelectionController {
|
||||
if peerId == strongSelf.context.account.peerId {
|
||||
Queue.mainQueue().after(0.88) {
|
||||
strongSelf.hapticFeedback.success()
|
||||
}
|
||||
|
||||
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
||||
(strongSelf.navigationController?.topViewController as? ViewController)?.present(UndoOverlayController(presentationData: presentationData, content: .forward(savedMessages: true, text: messages.count == 1 ? presentationData.strings.Conversation_ForwardTooltip_SavedMessages_One : presentationData.strings.Conversation_ForwardTooltip_SavedMessages_Many), elevatedLayout: false, animateInAsReplacement: true, action: { _ in return false }), in: .window(.root))
|
||||
|
||||
|
@ -876,7 +876,14 @@ final class ShareControllerNode: ViewControllerTracingNode, UIScrollViewDelegate
|
||||
})
|
||||
self.completed?(peerIds)
|
||||
|
||||
Queue.mainQueue().after(0.44) {
|
||||
let delay: Double
|
||||
if let peerId = peerIds.first, peerIds.count == 1 && peerId == self.context?.account.peerId {
|
||||
delay = 0.88
|
||||
} else {
|
||||
delay = 0.44
|
||||
}
|
||||
|
||||
Queue.mainQueue().after(delay) {
|
||||
if self.hapticFeedback == nil {
|
||||
self.hapticFeedback = HapticFeedback()
|
||||
}
|
||||
|
@ -2658,6 +2658,9 @@ public final class VoiceChatControllerImpl: ViewController, VoiceChatController
|
||||
if let strongSelf = self {
|
||||
strongSelf.call.setShouldBeRecording(false, title: nil, videoOrientation: nil)
|
||||
|
||||
Queue.mainQueue().after(0.88) {
|
||||
strongSelf.hapticFeedback.success()
|
||||
}
|
||||
|
||||
let text: String
|
||||
if let channel = strongSelf.peer as? TelegramChannel, case .broadcast = channel.info {
|
||||
@ -2665,7 +2668,6 @@ public final class VoiceChatControllerImpl: ViewController, VoiceChatController
|
||||
} else {
|
||||
text = strongSelf.presentationData.strings.VideoChat_RecordingSaved
|
||||
}
|
||||
|
||||
strongSelf.presentUndoOverlay(content: .forward(savedMessages: true, text: text), action: { [weak self] value in
|
||||
if case .info = value, let strongSelf = self, let navigationController = strongSelf.controller?.navigationController as? NavigationController {
|
||||
let context = strongSelf.context
|
||||
|
@ -16072,6 +16072,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
strongSelf.searchResultsController = nil
|
||||
strongController.dismiss()
|
||||
} else if peerId == strongSelf.context.account.peerId {
|
||||
Queue.mainQueue().after(0.88) {
|
||||
strongSelf.chatDisplayNode.hapticFeedback.success()
|
||||
}
|
||||
|
||||
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
||||
strongSelf.present(UndoOverlayController(presentationData: presentationData, content: .forward(savedMessages: true, text: messages.count == 1 ? presentationData.strings.Conversation_ForwardTooltip_SavedMessages_One : presentationData.strings.Conversation_ForwardTooltip_SavedMessages_Many), elevatedLayout: false, animateInAsReplacement: true, action: { [weak self] value in
|
||||
if case .info = value, let strongSelf = self {
|
||||
|
@ -164,7 +164,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
private var scheduledAnimateInAsOverlayFromNode: ASDisplayNode?
|
||||
private var dismissAsOverlayLayout: ContainerViewLayout?
|
||||
|
||||
private var hapticFeedback: HapticFeedback?
|
||||
lazy var hapticFeedback = { HapticFeedback() }()
|
||||
private var scrollViewDismissStatus = false
|
||||
|
||||
var chatPresentationInterfaceState: ChatPresentationInterfaceState
|
||||
@ -2904,10 +2904,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
|
||||
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
|
||||
if let scrollContainerNode = self.scrollContainerNode, scrollView === scrollContainerNode.view {
|
||||
if self.hapticFeedback == nil {
|
||||
self.hapticFeedback = HapticFeedback()
|
||||
}
|
||||
self.hapticFeedback?.prepareImpact()
|
||||
self.hapticFeedback.prepareImpact()
|
||||
}
|
||||
}
|
||||
|
||||
@ -2917,7 +2914,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
if dismissStatus != self.scrollViewDismissStatus {
|
||||
self.scrollViewDismissStatus = dismissStatus
|
||||
if !self.dismissedAsOverlay {
|
||||
self.hapticFeedback?.impact()
|
||||
self.hapticFeedback.impact()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1950,7 +1950,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
||||
private var editingSections: [AnyHashable: PeerInfoScreenItemSectionContainerNode] = [:]
|
||||
private let paneContainerNode: PeerInfoPaneContainerNode
|
||||
private var ignoreScrolling: Bool = false
|
||||
private var hapticFeedback: HapticFeedback?
|
||||
private lazy var hapticFeedback = { HapticFeedback() }()
|
||||
|
||||
private var customStatusData: (PeerInfoStatusData?, PeerInfoStatusData?, CGFloat?)
|
||||
private let customStatusPromise = Promise<(PeerInfoStatusData?, PeerInfoStatusData?, CGFloat?)>((nil, nil, nil))
|
||||
@ -3096,7 +3096,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
||||
for (_, section) in strongSelf.editingSections {
|
||||
section.animateErrorIfNeeded()
|
||||
}
|
||||
strongSelf.hapticFeedback?.error()
|
||||
strongSelf.hapticFeedback.error()
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -3146,10 +3146,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
||||
|
||||
if (peer.firstName ?? "") != firstName || (peer.lastName ?? "") != lastName {
|
||||
if firstName.isEmpty && lastName.isEmpty {
|
||||
if strongSelf.hapticFeedback == nil {
|
||||
strongSelf.hapticFeedback = HapticFeedback()
|
||||
}
|
||||
strongSelf.hapticFeedback?.error()
|
||||
strongSelf.hapticFeedback.error()
|
||||
strongSelf.headerNode.editingContentNode.shakeTextForKey(.firstName)
|
||||
} else {
|
||||
var dismissStatus: (() -> Void)?
|
||||
@ -3212,10 +3209,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
||||
let description = strongSelf.headerNode.editingContentNode.editingTextForKey(.description) ?? ""
|
||||
|
||||
if title.isEmpty {
|
||||
if strongSelf.hapticFeedback == nil {
|
||||
strongSelf.hapticFeedback = HapticFeedback()
|
||||
}
|
||||
strongSelf.hapticFeedback?.error()
|
||||
strongSelf.hapticFeedback.error()
|
||||
|
||||
strongSelf.headerNode.editingContentNode.shakeTextForKey(.title)
|
||||
} else {
|
||||
@ -8024,6 +8018,10 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
||||
|
||||
if let strongSelf = self, let _ = peerSelectionController {
|
||||
if peerId == strongSelf.context.account.peerId {
|
||||
Queue.mainQueue().after(0.88) {
|
||||
strongSelf.hapticFeedback.success()
|
||||
}
|
||||
|
||||
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
||||
strongSelf.controller?.present(UndoOverlayController(presentationData: presentationData, content: .forward(savedMessages: true, text: messageIds.count == 1 ? presentationData.strings.Conversation_ForwardTooltip_SavedMessages_One : presentationData.strings.Conversation_ForwardTooltip_SavedMessages_Many), elevatedLayout: false, animateInAsReplacement: true, action: { _ in return false }), in: .current)
|
||||
|
||||
@ -9055,10 +9053,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
||||
shouldBeExpanded = true
|
||||
|
||||
if self.canOpenAvatarByDragging && self.headerNode.isAvatarExpanded && offsetY <= -32.0 {
|
||||
if self.hapticFeedback == nil {
|
||||
self.hapticFeedback = HapticFeedback()
|
||||
}
|
||||
self.hapticFeedback?.impact()
|
||||
self.hapticFeedback.impact()
|
||||
|
||||
self.canOpenAvatarByDragging = false
|
||||
let contentOffset = scrollView.contentOffset.y
|
||||
@ -9078,13 +9073,10 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
||||
if let shouldBeExpanded = shouldBeExpanded, shouldBeExpanded != self.headerNode.isAvatarExpanded {
|
||||
let transition: ContainedViewLayoutTransition = .animated(duration: 0.35, curve: .spring)
|
||||
|
||||
if self.hapticFeedback == nil {
|
||||
self.hapticFeedback = HapticFeedback()
|
||||
}
|
||||
if shouldBeExpanded {
|
||||
self.hapticFeedback?.impact()
|
||||
self.hapticFeedback.impact()
|
||||
} else {
|
||||
self.hapticFeedback?.tap()
|
||||
self.hapticFeedback.tap()
|
||||
}
|
||||
|
||||
self.headerNode.updateIsAvatarExpanded(shouldBeExpanded, transition: transition)
|
||||
|
Loading…
x
Reference in New Issue
Block a user