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 weak var copyProtectionTooltipController: TooltipController?
|
||||||
|
|
||||||
|
private lazy var hapticFeedback = { HapticFeedback() }()
|
||||||
|
|
||||||
private var didSetReady: Bool = false
|
private var didSetReady: Bool = false
|
||||||
private let _ready = Promise<Void>()
|
private let _ready = Promise<Void>()
|
||||||
public override func ready() -> Signal<Void, NoError> {
|
public override func ready() -> Signal<Void, NoError> {
|
||||||
@ -1392,6 +1394,10 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
|||||||
let peerId = peer.id
|
let peerId = peer.id
|
||||||
if let strongSelf = self, let _ = peerSelectionController {
|
if let strongSelf = self, let _ = peerSelectionController {
|
||||||
if peerId == strongSelf.context.account.peerId {
|
if peerId == strongSelf.context.account.peerId {
|
||||||
|
Queue.mainQueue().after(0.88) {
|
||||||
|
strongSelf.hapticFeedback.success()
|
||||||
|
}
|
||||||
|
|
||||||
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
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))
|
(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)
|
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 {
|
if self.hapticFeedback == nil {
|
||||||
self.hapticFeedback = HapticFeedback()
|
self.hapticFeedback = HapticFeedback()
|
||||||
}
|
}
|
||||||
|
@ -2658,6 +2658,9 @@ public final class VoiceChatControllerImpl: ViewController, VoiceChatController
|
|||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.call.setShouldBeRecording(false, title: nil, videoOrientation: nil)
|
strongSelf.call.setShouldBeRecording(false, title: nil, videoOrientation: nil)
|
||||||
|
|
||||||
|
Queue.mainQueue().after(0.88) {
|
||||||
|
strongSelf.hapticFeedback.success()
|
||||||
|
}
|
||||||
|
|
||||||
let text: String
|
let text: String
|
||||||
if let channel = strongSelf.peer as? TelegramChannel, case .broadcast = channel.info {
|
if let channel = strongSelf.peer as? TelegramChannel, case .broadcast = channel.info {
|
||||||
@ -2665,7 +2668,6 @@ public final class VoiceChatControllerImpl: ViewController, VoiceChatController
|
|||||||
} else {
|
} else {
|
||||||
text = strongSelf.presentationData.strings.VideoChat_RecordingSaved
|
text = strongSelf.presentationData.strings.VideoChat_RecordingSaved
|
||||||
}
|
}
|
||||||
|
|
||||||
strongSelf.presentUndoOverlay(content: .forward(savedMessages: true, text: text), action: { [weak self] value in
|
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 {
|
if case .info = value, let strongSelf = self, let navigationController = strongSelf.controller?.navigationController as? NavigationController {
|
||||||
let context = strongSelf.context
|
let context = strongSelf.context
|
||||||
|
@ -16072,6 +16072,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
strongSelf.searchResultsController = nil
|
strongSelf.searchResultsController = nil
|
||||||
strongController.dismiss()
|
strongController.dismiss()
|
||||||
} else if peerId == strongSelf.context.account.peerId {
|
} else if peerId == strongSelf.context.account.peerId {
|
||||||
|
Queue.mainQueue().after(0.88) {
|
||||||
|
strongSelf.chatDisplayNode.hapticFeedback.success()
|
||||||
|
}
|
||||||
|
|
||||||
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
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
|
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 {
|
if case .info = value, let strongSelf = self {
|
||||||
|
@ -164,7 +164,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
private var scheduledAnimateInAsOverlayFromNode: ASDisplayNode?
|
private var scheduledAnimateInAsOverlayFromNode: ASDisplayNode?
|
||||||
private var dismissAsOverlayLayout: ContainerViewLayout?
|
private var dismissAsOverlayLayout: ContainerViewLayout?
|
||||||
|
|
||||||
private var hapticFeedback: HapticFeedback?
|
lazy var hapticFeedback = { HapticFeedback() }()
|
||||||
private var scrollViewDismissStatus = false
|
private var scrollViewDismissStatus = false
|
||||||
|
|
||||||
var chatPresentationInterfaceState: ChatPresentationInterfaceState
|
var chatPresentationInterfaceState: ChatPresentationInterfaceState
|
||||||
@ -2904,10 +2904,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
|
|
||||||
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
|
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
|
||||||
if let scrollContainerNode = self.scrollContainerNode, scrollView === scrollContainerNode.view {
|
if let scrollContainerNode = self.scrollContainerNode, scrollView === scrollContainerNode.view {
|
||||||
if self.hapticFeedback == nil {
|
self.hapticFeedback.prepareImpact()
|
||||||
self.hapticFeedback = HapticFeedback()
|
|
||||||
}
|
|
||||||
self.hapticFeedback?.prepareImpact()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2917,7 +2914,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
if dismissStatus != self.scrollViewDismissStatus {
|
if dismissStatus != self.scrollViewDismissStatus {
|
||||||
self.scrollViewDismissStatus = dismissStatus
|
self.scrollViewDismissStatus = dismissStatus
|
||||||
if !self.dismissedAsOverlay {
|
if !self.dismissedAsOverlay {
|
||||||
self.hapticFeedback?.impact()
|
self.hapticFeedback.impact()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1950,7 +1950,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
|||||||
private var editingSections: [AnyHashable: PeerInfoScreenItemSectionContainerNode] = [:]
|
private var editingSections: [AnyHashable: PeerInfoScreenItemSectionContainerNode] = [:]
|
||||||
private let paneContainerNode: PeerInfoPaneContainerNode
|
private let paneContainerNode: PeerInfoPaneContainerNode
|
||||||
private var ignoreScrolling: Bool = false
|
private var ignoreScrolling: Bool = false
|
||||||
private var hapticFeedback: HapticFeedback?
|
private lazy var hapticFeedback = { HapticFeedback() }()
|
||||||
|
|
||||||
private var customStatusData: (PeerInfoStatusData?, PeerInfoStatusData?, CGFloat?)
|
private var customStatusData: (PeerInfoStatusData?, PeerInfoStatusData?, CGFloat?)
|
||||||
private let customStatusPromise = Promise<(PeerInfoStatusData?, PeerInfoStatusData?, CGFloat?)>((nil, nil, nil))
|
private let customStatusPromise = Promise<(PeerInfoStatusData?, PeerInfoStatusData?, CGFloat?)>((nil, nil, nil))
|
||||||
@ -3096,7 +3096,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
|||||||
for (_, section) in strongSelf.editingSections {
|
for (_, section) in strongSelf.editingSections {
|
||||||
section.animateErrorIfNeeded()
|
section.animateErrorIfNeeded()
|
||||||
}
|
}
|
||||||
strongSelf.hapticFeedback?.error()
|
strongSelf.hapticFeedback.error()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3146,10 +3146,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
|||||||
|
|
||||||
if (peer.firstName ?? "") != firstName || (peer.lastName ?? "") != lastName {
|
if (peer.firstName ?? "") != firstName || (peer.lastName ?? "") != lastName {
|
||||||
if firstName.isEmpty && lastName.isEmpty {
|
if firstName.isEmpty && lastName.isEmpty {
|
||||||
if strongSelf.hapticFeedback == nil {
|
strongSelf.hapticFeedback.error()
|
||||||
strongSelf.hapticFeedback = HapticFeedback()
|
|
||||||
}
|
|
||||||
strongSelf.hapticFeedback?.error()
|
|
||||||
strongSelf.headerNode.editingContentNode.shakeTextForKey(.firstName)
|
strongSelf.headerNode.editingContentNode.shakeTextForKey(.firstName)
|
||||||
} else {
|
} else {
|
||||||
var dismissStatus: (() -> Void)?
|
var dismissStatus: (() -> Void)?
|
||||||
@ -3212,10 +3209,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
|||||||
let description = strongSelf.headerNode.editingContentNode.editingTextForKey(.description) ?? ""
|
let description = strongSelf.headerNode.editingContentNode.editingTextForKey(.description) ?? ""
|
||||||
|
|
||||||
if title.isEmpty {
|
if title.isEmpty {
|
||||||
if strongSelf.hapticFeedback == nil {
|
strongSelf.hapticFeedback.error()
|
||||||
strongSelf.hapticFeedback = HapticFeedback()
|
|
||||||
}
|
|
||||||
strongSelf.hapticFeedback?.error()
|
|
||||||
|
|
||||||
strongSelf.headerNode.editingContentNode.shakeTextForKey(.title)
|
strongSelf.headerNode.editingContentNode.shakeTextForKey(.title)
|
||||||
} else {
|
} else {
|
||||||
@ -8024,6 +8018,10 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
|||||||
|
|
||||||
if let strongSelf = self, let _ = peerSelectionController {
|
if let strongSelf = self, let _ = peerSelectionController {
|
||||||
if peerId == strongSelf.context.account.peerId {
|
if peerId == strongSelf.context.account.peerId {
|
||||||
|
Queue.mainQueue().after(0.88) {
|
||||||
|
strongSelf.hapticFeedback.success()
|
||||||
|
}
|
||||||
|
|
||||||
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
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)
|
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
|
shouldBeExpanded = true
|
||||||
|
|
||||||
if self.canOpenAvatarByDragging && self.headerNode.isAvatarExpanded && offsetY <= -32.0 {
|
if self.canOpenAvatarByDragging && self.headerNode.isAvatarExpanded && offsetY <= -32.0 {
|
||||||
if self.hapticFeedback == nil {
|
self.hapticFeedback.impact()
|
||||||
self.hapticFeedback = HapticFeedback()
|
|
||||||
}
|
|
||||||
self.hapticFeedback?.impact()
|
|
||||||
|
|
||||||
self.canOpenAvatarByDragging = false
|
self.canOpenAvatarByDragging = false
|
||||||
let contentOffset = scrollView.contentOffset.y
|
let contentOffset = scrollView.contentOffset.y
|
||||||
@ -9078,13 +9073,10 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
|||||||
if let shouldBeExpanded = shouldBeExpanded, shouldBeExpanded != self.headerNode.isAvatarExpanded {
|
if let shouldBeExpanded = shouldBeExpanded, shouldBeExpanded != self.headerNode.isAvatarExpanded {
|
||||||
let transition: ContainedViewLayoutTransition = .animated(duration: 0.35, curve: .spring)
|
let transition: ContainedViewLayoutTransition = .animated(duration: 0.35, curve: .spring)
|
||||||
|
|
||||||
if self.hapticFeedback == nil {
|
|
||||||
self.hapticFeedback = HapticFeedback()
|
|
||||||
}
|
|
||||||
if shouldBeExpanded {
|
if shouldBeExpanded {
|
||||||
self.hapticFeedback?.impact()
|
self.hapticFeedback.impact()
|
||||||
} else {
|
} else {
|
||||||
self.hapticFeedback?.tap()
|
self.hapticFeedback.tap()
|
||||||
}
|
}
|
||||||
|
|
||||||
self.headerNode.updateIsAvatarExpanded(shouldBeExpanded, transition: transition)
|
self.headerNode.updateIsAvatarExpanded(shouldBeExpanded, transition: transition)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user