[WIP] build with Xcode 14 [skip-ci]

This commit is contained in:
Ali 2022-09-13 14:56:15 +04:00
parent e551335483
commit 8fe1e77376
8 changed files with 187 additions and 142 deletions

View File

@ -505,22 +505,24 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
} }
deinit { deinit {
self.pauseAnimations() let _ = { () -> Void in
self.displayLink.invalidate() self.pauseAnimations()
self.displayLink.invalidate()
for i in (0 ..< self.itemNodes.count).reversed() {
var itemNode: AnyObject? = self.itemNodes[i] for i in (0 ..< self.itemNodes.count).reversed() {
self.itemNodes.remove(at: i) var itemNode: AnyObject? = self.itemNodes[i]
ASPerformMainThreadDeallocation(&itemNode) self.itemNodes.remove(at: i)
} ASPerformMainThreadDeallocation(&itemNode)
for key in self.itemHeaderNodes.keys { }
var itemHeaderNode: AnyObject? = self.itemHeaderNodes[key] for key in self.itemHeaderNodes.keys {
self.itemHeaderNodes.removeValue(forKey: key) var itemHeaderNode: AnyObject? = self.itemHeaderNodes[key]
ASPerformMainThreadDeallocation(&itemHeaderNode) self.itemHeaderNodes.removeValue(forKey: key)
} ASPerformMainThreadDeallocation(&itemHeaderNode)
}
self.waitingForNodesDisposable.dispose()
self.reorderFeedbackDisposable?.dispose() self.waitingForNodesDisposable.dispose()
self.reorderFeedbackDisposable?.dispose()
}()
} }
@objc private func tapGesture(_ gestureRecognizer: UITapGestureRecognizer) { @objc private func tapGesture(_ gestureRecognizer: UITapGestureRecognizer) {

View File

@ -5,7 +5,7 @@ import TelegramCore
func spacingBetweenBlocks(upper: InstantPageBlock?, lower: InstantPageBlock?) -> CGFloat { func spacingBetweenBlocks(upper: InstantPageBlock?, lower: InstantPageBlock?) -> CGFloat {
if let upper = upper, let lower = lower { if let upper = upper, let lower = lower {
switch (upper, lower) { switch (upper, lower) {
case (_, .cover), (_, .channelBanner), (.details, .details), (.relatedArticles, nil), (_, .anchor): case (_, .cover), (_, .channelBanner), (.details, .details), (.relatedArticles, _), (_, .anchor):
return 0.0 return 0.0
case (.divider, _), (_, .divider): case (.divider, _), (_, .divider):
return 25.0 return 25.0

View File

@ -636,7 +636,11 @@ public final class MediaBox {
subscriber.putCompletion() subscriber.putCompletion()
return EmptyDisposable return EmptyDisposable
} else { } else {
if let data = MediaBoxPartialFile.extractPartialData(manager: MediaBoxFileManager(queue: nil), path: paths.partial, metaPath: paths.partial + ".meta", range: range) { let tempManager = MediaBoxFileManager(queue: nil)
let data = withExtendedLifetime(tempManager, {
return MediaBoxPartialFile.extractPartialData(manager: tempManager, path: paths.partial, metaPath: paths.partial + ".meta", range: range)
})
if let data = data {
subscriber.putNext((data, true)) subscriber.putNext((data, true))
subscriber.putCompletion() subscriber.putCompletion()
return EmptyDisposable return EmptyDisposable
@ -677,6 +681,15 @@ public final class MediaBox {
subscriber.putNext((Data(), false)) subscriber.putNext((Data(), false))
} }
} }
} else {
switch mode {
case .complete, .incremental:
if notifyAboutIncomplete {
subscriber.putNext((Data(), false))
}
case .partial:
subscriber.putNext((Data(), false))
}
} }
}) })

View File

@ -5287,78 +5287,82 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
let _ = ChatControllerCount.modify { value in let _ = ChatControllerCount.modify { value in
return value - 1 return value - 1
} }
self.historyStateDisposable?.dispose()
self.messageIndexDisposable.dispose() let deallocate: () -> Void = {
self.navigationActionDisposable.dispose() self.historyStateDisposable?.dispose()
self.galleryHiddenMesageAndMediaDisposable.dispose() self.messageIndexDisposable.dispose()
self.temporaryHiddenGalleryMediaDisposable.dispose() self.navigationActionDisposable.dispose()
self.peerDisposable.dispose() self.galleryHiddenMesageAndMediaDisposable.dispose()
self.accountPeerDisposable?.dispose() self.temporaryHiddenGalleryMediaDisposable.dispose()
self.titleDisposable.dispose() self.peerDisposable.dispose()
self.messageContextDisposable.dispose() self.accountPeerDisposable?.dispose()
self.controllerNavigationDisposable.dispose() self.titleDisposable.dispose()
self.sentMessageEventsDisposable.dispose() self.messageContextDisposable.dispose()
self.failedMessageEventsDisposable.dispose() self.controllerNavigationDisposable.dispose()
self.messageActionCallbackDisposable.dispose() self.sentMessageEventsDisposable.dispose()
self.messageActionUrlAuthDisposable.dispose() self.failedMessageEventsDisposable.dispose()
self.editMessageDisposable.dispose() self.messageActionCallbackDisposable.dispose()
self.editMessageErrorsDisposable.dispose() self.messageActionUrlAuthDisposable.dispose()
self.enqueueMediaMessageDisposable.dispose() self.editMessageDisposable.dispose()
self.resolvePeerByNameDisposable?.dispose() self.editMessageErrorsDisposable.dispose()
self.shareStatusDisposable?.dispose() self.enqueueMediaMessageDisposable.dispose()
self.clearCacheDisposable?.dispose() self.resolvePeerByNameDisposable?.dispose()
self.bankCardDisposable?.dispose() self.shareStatusDisposable?.dispose()
self.botCallbackAlertMessageDisposable?.dispose() self.clearCacheDisposable?.dispose()
self.selectMessagePollOptionDisposables?.dispose() self.bankCardDisposable?.dispose()
for (_, info) in self.contextQueryStates { self.botCallbackAlertMessageDisposable?.dispose()
info.1.dispose() self.selectMessagePollOptionDisposables?.dispose()
for (_, info) in self.contextQueryStates {
info.1.dispose()
}
self.urlPreviewQueryState?.1.dispose()
self.audioRecorderDisposable?.dispose()
self.audioRecorderStatusDisposable?.dispose()
self.videoRecorderDisposable?.dispose()
self.buttonKeyboardMessageDisposable?.dispose()
self.cachedDataDisposable?.dispose()
self.resolveUrlDisposable?.dispose()
self.chatUnreadCountDisposable?.dispose()
self.buttonUnreadCountDisposable?.dispose()
self.chatUnreadMentionCountDisposable?.dispose()
self.peerInputActivitiesDisposable?.dispose()
self.interactiveEmojiSyncDisposable.dispose()
self.recentlyUsedInlineBotsDisposable?.dispose()
self.unpinMessageDisposable?.dispose()
self.inputActivityDisposable?.dispose()
self.recordingActivityDisposable?.dispose()
self.acquiredRecordingActivityDisposable?.dispose()
self.presentationDataDisposable?.dispose()
self.searchDisposable?.dispose()
self.applicationInForegroundDisposable?.dispose()
self.applicationInFocusDisposable?.dispose()
self.canReadHistoryDisposable?.dispose()
self.networkStateDisposable?.dispose()
self.chatAdditionalDataDisposable.dispose()
self.shareStatusDisposable?.dispose()
self.context.sharedContext.mediaManager.galleryHiddenMediaManager.removeTarget(self)
self.preloadHistoryPeerIdDisposable.dispose()
self.preloadNextChatPeerIdDisposable.dispose()
self.reportIrrelvantGeoDisposable?.dispose()
self.reminderActivity?.invalidate()
self.updateSlowmodeStatusDisposable.dispose()
self.keepPeerInfoScreenDataHotDisposable.dispose()
self.preloadAvatarDisposable.dispose()
self.peekTimerDisposable.dispose()
self.hasActiveGroupCallDisposable?.dispose()
self.createVoiceChatDisposable.dispose()
self.checksTooltipDisposable.dispose()
self.peerSuggestionsDisposable.dispose()
self.peerSuggestionsDismissDisposable.dispose()
self.selectAddMemberDisposable.dispose()
self.addMemberDisposable.dispose()
self.importStateDisposable?.dispose()
self.nextChannelToReadDisposable?.dispose()
self.inviteRequestsDisposable.dispose()
self.sendAsPeersDisposable?.dispose()
self.preloadAttachBotIconsDisposables?.dispose()
} }
self.urlPreviewQueryState?.1.dispose() deallocate()
self.audioRecorderDisposable?.dispose()
self.audioRecorderStatusDisposable?.dispose()
self.videoRecorderDisposable?.dispose()
self.buttonKeyboardMessageDisposable?.dispose()
self.cachedDataDisposable?.dispose()
self.resolveUrlDisposable?.dispose()
self.chatUnreadCountDisposable?.dispose()
self.buttonUnreadCountDisposable?.dispose()
self.chatUnreadMentionCountDisposable?.dispose()
self.peerInputActivitiesDisposable?.dispose()
self.interactiveEmojiSyncDisposable.dispose()
self.recentlyUsedInlineBotsDisposable?.dispose()
self.unpinMessageDisposable?.dispose()
self.inputActivityDisposable?.dispose()
self.recordingActivityDisposable?.dispose()
self.acquiredRecordingActivityDisposable?.dispose()
self.presentationDataDisposable?.dispose()
self.searchDisposable?.dispose()
self.applicationInForegroundDisposable?.dispose()
self.applicationInFocusDisposable?.dispose()
self.canReadHistoryDisposable?.dispose()
self.networkStateDisposable?.dispose()
self.chatAdditionalDataDisposable.dispose()
self.shareStatusDisposable?.dispose()
self.context.sharedContext.mediaManager.galleryHiddenMediaManager.removeTarget(self)
self.preloadHistoryPeerIdDisposable.dispose()
self.preloadNextChatPeerIdDisposable.dispose()
self.reportIrrelvantGeoDisposable?.dispose()
self.reminderActivity?.invalidate()
self.updateSlowmodeStatusDisposable.dispose()
self.keepPeerInfoScreenDataHotDisposable.dispose()
self.preloadAvatarDisposable.dispose()
self.peekTimerDisposable.dispose()
self.hasActiveGroupCallDisposable?.dispose()
self.createVoiceChatDisposable.dispose()
self.checksTooltipDisposable.dispose()
self.peerSuggestionsDisposable.dispose()
self.peerSuggestionsDismissDisposable.dispose()
self.selectAddMemberDisposable.dispose()
self.addMemberDisposable.dispose()
self.importStateDisposable?.dispose()
self.nextChannelToReadDisposable?.dispose()
self.inviteRequestsDisposable.dispose()
self.sendAsPeersDisposable?.dispose()
self.preloadAttachBotIconsDisposables?.dispose()
} }
public func updatePresentationMode(_ mode: ChatControllerPresentationMode) { public func updatePresentationMode(_ mode: ChatControllerPresentationMode) {

View File

@ -818,7 +818,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
let textLayout = TextNodeWithEntities.asyncLayout(self.textNode) let textLayout = TextNodeWithEntities.asyncLayout(self.textNode)
return { item, params, mergedTop, mergedBottom, dateHeaderAtBottom in func continueAsyncLayout(_ weakSelf: Weak<ChatMessageAnimatedStickerItemNode>, _ item: ChatMessageItem, _ params: ListViewItemLayoutParams, _ mergedTop: ChatMessageMerge, _ mergedBottom: ChatMessageMerge, _ dateHeaderAtBottom: Bool) -> (ListViewItemNodeLayout, (ListViewItemUpdateAnimation, ListViewItemApply, Bool) -> Void) {
let accessibilityData = ChatMessageAccessibilityData(item: item, isSelected: nil) let accessibilityData = ChatMessageAccessibilityData(item: item, isSelected: nil)
let layoutConstants = chatMessageItemLayoutConstants(layoutConstants, params: params, presentationData: item.presentationData) let layoutConstants = chatMessageItemLayoutConstants(layoutConstants, params: params, presentationData: item.presentationData)
let incoming = item.content.effectivelyIncoming(item.context.account.peerId, associatedData: item.associatedData) let incoming = item.content.effectivelyIncoming(item.context.account.peerId, associatedData: item.associatedData)
@ -1255,8 +1255,8 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
layoutSize.height += 4.0 + reactionButtonsSizeAndApply.0.height layoutSize.height += 4.0 + reactionButtonsSizeAndApply.0.height
} }
return (ListViewItemNodeLayout(contentSize: layoutSize, insets: layoutInsets), { [weak self] animation, _, synchronousLoads in func finishLayout(_ animation: ListViewItemUpdateAnimation, _ apply: ListViewItemApply, _ synchronousLoads: Bool) {
if let strongSelf = self { if let strongSelf = weakSelf.value {
strongSelf.appliedForwardInfo = (forwardSource, forwardAuthorSignature) strongSelf.appliedForwardInfo = (forwardSource, forwardAuthorSignature)
strongSelf.updateAccessibilityData(accessibilityData) strongSelf.updateAccessibilityData(accessibilityData)
@ -1473,7 +1473,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
} else { } else {
isAppearing = true isAppearing = true
deliveryFailedNode = ChatMessageDeliveryFailedNode(tapped: { deliveryFailedNode = ChatMessageDeliveryFailedNode(tapped: {
if let item = self?.item { if let strongSelf = weakSelf.value, let item = strongSelf.item {
item.controllerInteraction.requestRedeliveryOfFailedMessages(item.content.firstMessage.id) item.controllerInteraction.requestRedeliveryOfFailedMessages(item.content.firstMessage.id)
} }
}) })
@ -1504,12 +1504,12 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
if actionButtonsNode !== strongSelf.actionButtonsNode { if actionButtonsNode !== strongSelf.actionButtonsNode {
strongSelf.actionButtonsNode = actionButtonsNode strongSelf.actionButtonsNode = actionButtonsNode
actionButtonsNode.buttonPressed = { button in actionButtonsNode.buttonPressed = { button in
if let strongSelf = self { if let strongSelf = weakSelf.value {
strongSelf.performMessageButtonAction(button: button) strongSelf.performMessageButtonAction(button: button)
} }
} }
actionButtonsNode.buttonLongTapped = { button in actionButtonsNode.buttonLongTapped = { button in
if let strongSelf = self { if let strongSelf = weakSelf.value {
strongSelf.presentMessageButtonContextMenu(button: button) strongSelf.presentMessageButtonContextMenu(button: button)
} }
} }
@ -1536,13 +1536,13 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
if reactionButtonsNode !== strongSelf.reactionButtonsNode { if reactionButtonsNode !== strongSelf.reactionButtonsNode {
strongSelf.reactionButtonsNode = reactionButtonsNode strongSelf.reactionButtonsNode = reactionButtonsNode
reactionButtonsNode.reactionSelected = { value in reactionButtonsNode.reactionSelected = { value in
guard let strongSelf = self, let item = strongSelf.item else { guard let strongSelf = weakSelf.value, let item = strongSelf.item else {
return return
} }
item.controllerInteraction.updateMessageReaction(item.message, .reaction(value)) item.controllerInteraction.updateMessageReaction(item.message, .reaction(value))
} }
reactionButtonsNode.openReactionPreview = { gesture, sourceView, value in reactionButtonsNode.openReactionPreview = { gesture, sourceView, value in
guard let strongSelf = self, let item = strongSelf.item else { guard let strongSelf = weakSelf.value, let item = strongSelf.item else {
gesture?.cancel() gesture?.cancel()
return return
} }
@ -1590,7 +1590,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
if let forwardInfo = item.message.forwardInfo, forwardInfo.flags.contains(.isImported) { if let forwardInfo = item.message.forwardInfo, forwardInfo.flags.contains(.isImported) {
strongSelf.dateAndStatusNode.pressed = { strongSelf.dateAndStatusNode.pressed = {
guard let strongSelf = self else { guard let strongSelf = weakSelf.value else {
return return
} }
item.controllerInteraction.displayImportedMessageTooltip(strongSelf.dateAndStatusNode) item.controllerInteraction.displayImportedMessageTooltip(strongSelf.dateAndStatusNode)
@ -1605,8 +1605,16 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
f() f()
} }
} }
}
return (ListViewItemNodeLayout(contentSize: layoutSize, insets: layoutInsets), { (animation: ListViewItemUpdateAnimation, apply: ListViewItemApply, synchronousLoads: Bool) -> Void in
finishLayout(animation, apply, synchronousLoads)
}) })
} }
let weakSelf = Weak(self)
return { (_ item: ChatMessageItem, _ params: ListViewItemLayoutParams, _ mergedTop: ChatMessageMerge, _ mergedBottom: ChatMessageMerge, _ dateHeaderAtBottom: Bool) -> (ListViewItemNodeLayout, (ListViewItemUpdateAnimation, ListViewItemApply, Bool) -> Void) in
return continueAsyncLayout(weakSelf, item, params, mergedTop, mergedBottom, dateHeaderAtBottom)
}
} }
@objc private func tapLongTapOrDoubleTapGesture(_ recognizer: TapLongTapOrDoubleTapGestureRecognizer) { @objc private func tapLongTapOrDoubleTapGesture(_ recognizer: TapLongTapOrDoubleTapGestureRecognizer) {

View File

@ -20,43 +20,43 @@ private let inlineBotNameFont = nameFont
class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerDelegate { class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerDelegate {
let contextSourceNode: ContextExtractedContentContainingNode let contextSourceNode: ContextExtractedContentContainingNode
private let containerNode: ContextControllerSourceNode let containerNode: ContextControllerSourceNode
private let interactiveVideoNode: ChatMessageInteractiveInstantVideoNode let interactiveVideoNode: ChatMessageInteractiveInstantVideoNode
private var selectionNode: ChatMessageSelectionNode? var selectionNode: ChatMessageSelectionNode?
private var deliveryFailedNode: ChatMessageDeliveryFailedNode? var deliveryFailedNode: ChatMessageDeliveryFailedNode?
private var shareButtonNode: ChatMessageShareButton? var shareButtonNode: ChatMessageShareButton?
private var swipeToReplyNode: ChatMessageSwipeToReplyNode? var swipeToReplyNode: ChatMessageSwipeToReplyNode?
private var swipeToReplyFeedback: HapticFeedback? var swipeToReplyFeedback: HapticFeedback?
private var appliedParams: ListViewItemLayoutParams? var appliedParams: ListViewItemLayoutParams?
private var appliedItem: ChatMessageItem? var appliedItem: ChatMessageItem?
private var appliedForwardInfo: (Peer?, String?)? var appliedForwardInfo: (Peer?, String?)?
private var appliedHasAvatar = false var appliedHasAvatar = false
private var appliedCurrentlyPlaying: Bool? var appliedCurrentlyPlaying: Bool?
private var appliedAutomaticDownload = false var appliedAutomaticDownload = false
private var avatarOffset: CGFloat? var avatarOffset: CGFloat?
private var animatingHeight: Bool { var animatingHeight: Bool {
return self.apparentHeightTransition != nil return self.apparentHeightTransition != nil
} }
private var viaBotNode: TextNode? var viaBotNode: TextNode?
private var replyInfoNode: ChatMessageReplyInfoNode? var replyInfoNode: ChatMessageReplyInfoNode?
private var replyBackgroundNode: NavigationBackgroundNode? var replyBackgroundNode: NavigationBackgroundNode?
private var forwardInfoNode: ChatMessageForwardInfoNode? var forwardInfoNode: ChatMessageForwardInfoNode?
private var actionButtonsNode: ChatMessageActionButtonsNode? var actionButtonsNode: ChatMessageActionButtonsNode?
private var reactionButtonsNode: ChatMessageReactionButtonsNode? var reactionButtonsNode: ChatMessageReactionButtonsNode?
private let messageAccessibilityArea: AccessibilityAreaNode let messageAccessibilityArea: AccessibilityAreaNode
private var currentSwipeToReplyTranslation: CGFloat = 0.0 var currentSwipeToReplyTranslation: CGFloat = 0.0
private var recognizer: TapLongTapOrDoubleTapGestureRecognizer? var recognizer: TapLongTapOrDoubleTapGestureRecognizer?
private var currentSwipeAction: ChatControllerInteractionSwipeAction? var currentSwipeAction: ChatControllerInteractionSwipeAction?
override var visibility: ListViewItemNodeVisibility { override var visibility: ListViewItemNodeVisibility {
didSet { didSet {
@ -70,7 +70,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
} }
} }
private var wasPlaying = false fileprivate var wasPlaying = false
required init() { required init() {
self.contextSourceNode = ContextExtractedContentContainingNode() self.contextSourceNode = ContextExtractedContentContainingNode()
@ -266,7 +266,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
let currentForwardInfo = self.appliedForwardInfo let currentForwardInfo = self.appliedForwardInfo
let currentPlaying = self.appliedCurrentlyPlaying let currentPlaying = self.appliedCurrentlyPlaying
return { item, params, mergedTop, mergedBottom, dateHeaderAtBottom in func continueAsyncLayout(_ weakSelf: Weak<ChatMessageInstantVideoItemNode>, _ item: ChatMessageItem, _ params: ListViewItemLayoutParams, _ mergedTop: ChatMessageMerge, _ mergedBottom: ChatMessageMerge, _ dateHeaderAtBottom: Bool) -> (ListViewItemNodeLayout, (ListViewItemUpdateAnimation, ListViewItemApply, Bool) -> Void) {
let accessibilityData = ChatMessageAccessibilityData(item: item, isSelected: nil) let accessibilityData = ChatMessageAccessibilityData(item: item, isSelected: nil)
let layoutConstants = chatMessageItemLayoutConstants(layoutConstants, params: params, presentationData: item.presentationData) let layoutConstants = chatMessageItemLayoutConstants(layoutConstants, params: params, presentationData: item.presentationData)
@ -582,8 +582,8 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
layoutSize.height += 6.0 + reactionButtonsSizeAndApply.0.height layoutSize.height += 6.0 + reactionButtonsSizeAndApply.0.height
} }
return (ListViewItemNodeLayout(contentSize: layoutSize, insets: layoutInsets), { [weak self] animation, _, synchronousLoads in func finishAsyncLayout(_ animation: ListViewItemUpdateAnimation, _ synchronousLoads: Bool) {
if let strongSelf = self { if let strongSelf = weakSelf.value {
strongSelf.contextSourceNode.frame = CGRect(origin: CGPoint(), size: layoutSize) strongSelf.contextSourceNode.frame = CGRect(origin: CGPoint(), size: layoutSize)
strongSelf.containerNode.frame = CGRect(origin: CGPoint(), size: layoutSize) strongSelf.containerNode.frame = CGRect(origin: CGPoint(), size: layoutSize)
strongSelf.contextSourceNode.contentNode.frame = CGRect(origin: CGPoint(), size: layoutSize) strongSelf.contextSourceNode.contentNode.frame = CGRect(origin: CGPoint(), size: layoutSize)
@ -738,7 +738,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
} else { } else {
isAppearing = true isAppearing = true
deliveryFailedNode = ChatMessageDeliveryFailedNode(tapped: { deliveryFailedNode = ChatMessageDeliveryFailedNode(tapped: {
if let item = self?.item { if let strongSelf = weakSelf.value, let item = strongSelf.item {
item.controllerInteraction.requestRedeliveryOfFailedMessages(item.content.firstMessage.id) item.controllerInteraction.requestRedeliveryOfFailedMessages(item.content.firstMessage.id)
} }
}) })
@ -773,13 +773,13 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
if reactionButtonsNode !== strongSelf.reactionButtonsNode { if reactionButtonsNode !== strongSelf.reactionButtonsNode {
strongSelf.reactionButtonsNode = reactionButtonsNode strongSelf.reactionButtonsNode = reactionButtonsNode
reactionButtonsNode.reactionSelected = { value in reactionButtonsNode.reactionSelected = { value in
guard let strongSelf = self, let item = strongSelf.item else { guard let strongSelf = weakSelf.value, let item = strongSelf.item else {
return return
} }
item.controllerInteraction.updateMessageReaction(item.message, .reaction(value)) item.controllerInteraction.updateMessageReaction(item.message, .reaction(value))
} }
reactionButtonsNode.openReactionPreview = { gesture, sourceNode, value in reactionButtonsNode.openReactionPreview = { gesture, sourceNode, value in
guard let strongSelf = self, let item = strongSelf.item else { guard let strongSelf = weakSelf.value, let item = strongSelf.item else {
gesture?.cancel() gesture?.cancel()
return return
} }
@ -823,12 +823,12 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
if actionButtonsNode !== strongSelf.actionButtonsNode { if actionButtonsNode !== strongSelf.actionButtonsNode {
strongSelf.actionButtonsNode = actionButtonsNode strongSelf.actionButtonsNode = actionButtonsNode
actionButtonsNode.buttonPressed = { button in actionButtonsNode.buttonPressed = { button in
if let strongSelf = self { if let strongSelf = weakSelf.value {
strongSelf.performMessageButtonAction(button: button) strongSelf.performMessageButtonAction(button: button)
} }
} }
actionButtonsNode.buttonLongTapped = { button in actionButtonsNode.buttonLongTapped = { button in
if let strongSelf = self { if let strongSelf = weakSelf.value {
strongSelf.presentMessageButtonContextMenu(button: button) strongSelf.presentMessageButtonContextMenu(button: button)
} }
} }
@ -861,8 +861,17 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
f() f()
} }
} }
}
return (ListViewItemNodeLayout(contentSize: layoutSize, insets: layoutInsets), { animation, _, synchronousLoads in
finishAsyncLayout(animation, synchronousLoads)
}) })
} }
let weakSelf = Weak(self)
return { item, params, mergedTop, mergedBottom, dateHeaderAtBottom -> (ListViewItemNodeLayout, (ListViewItemUpdateAnimation, ListViewItemApply, Bool) -> Void) in
continueAsyncLayout(weakSelf, item, params, mergedTop, mergedBottom, dateHeaderAtBottom)
}
} }
@objc func tapLongTapOrDoubleTapGesture(_ recognizer: TapLongTapOrDoubleTapGestureRecognizer) { @objc func tapLongTapOrDoubleTapGesture(_ recognizer: TapLongTapOrDoubleTapGestureRecognizer) {

View File

@ -345,7 +345,7 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
let currentShareButtonNode = self.shareButtonNode let currentShareButtonNode = self.shareButtonNode
let currentForwardInfo = self.appliedForwardInfo let currentForwardInfo = self.appliedForwardInfo
return { item, params, mergedTop, mergedBottom, dateHeaderAtBottom in func continueAsyncLayout(_ weakSelf: Weak<ChatMessageStickerItemNode>, _ item: ChatMessageItem, _ params: ListViewItemLayoutParams, _ mergedTop: ChatMessageMerge, _ mergedBottom: ChatMessageMerge, _ dateHeaderAtBottom: Bool) -> (ListViewItemNodeLayout, (ListViewItemUpdateAnimation, ListViewItemApply, Bool) -> Void) {
let accessibilityData = ChatMessageAccessibilityData(item: item, isSelected: nil) let accessibilityData = ChatMessageAccessibilityData(item: item, isSelected: nil)
let layoutConstants = chatMessageItemLayoutConstants(layoutConstants, params: params, presentationData: item.presentationData) let layoutConstants = chatMessageItemLayoutConstants(layoutConstants, params: params, presentationData: item.presentationData)
@ -785,8 +785,8 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
} }
} }
return (ListViewItemNodeLayout(contentSize: layoutSize, insets: layoutInsets), { [weak self] animation, _, synchronousLoads in func finishAsyncLayout(_ animation: ListViewItemUpdateAnimation, _ synchronousLoads: Bool) {
if let strongSelf = self { if let strongSelf = weakSelf.value {
var transition: ContainedViewLayoutTransition = .immediate var transition: ContainedViewLayoutTransition = .immediate
if case let .System(duration, _) = animation { if case let .System(duration, _) = animation {
transition = .animated(duration: duration, curve: .spring) transition = .animated(duration: duration, curve: .spring)
@ -951,7 +951,7 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
} else { } else {
isAppearing = true isAppearing = true
deliveryFailedNode = ChatMessageDeliveryFailedNode(tapped: { deliveryFailedNode = ChatMessageDeliveryFailedNode(tapped: {
if let item = self?.item { if let strongSelf = weakSelf.value, let item = strongSelf.item {
item.controllerInteraction.requestRedeliveryOfFailedMessages(item.content.firstMessage.id) item.controllerInteraction.requestRedeliveryOfFailedMessages(item.content.firstMessage.id)
} }
}) })
@ -982,12 +982,12 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
if actionButtonsNode !== strongSelf.actionButtonsNode { if actionButtonsNode !== strongSelf.actionButtonsNode {
strongSelf.actionButtonsNode = actionButtonsNode strongSelf.actionButtonsNode = actionButtonsNode
actionButtonsNode.buttonPressed = { button in actionButtonsNode.buttonPressed = { button in
if let strongSelf = self { if let strongSelf = weakSelf.value {
strongSelf.performMessageButtonAction(button: button) strongSelf.performMessageButtonAction(button: button)
} }
} }
actionButtonsNode.buttonLongTapped = { button in actionButtonsNode.buttonLongTapped = { button in
if let strongSelf = self { if let strongSelf = weakSelf.value {
strongSelf.presentMessageButtonContextMenu(button: button) strongSelf.presentMessageButtonContextMenu(button: button)
} }
} }
@ -1014,13 +1014,13 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
if reactionButtonsNode !== strongSelf.reactionButtonsNode { if reactionButtonsNode !== strongSelf.reactionButtonsNode {
strongSelf.reactionButtonsNode = reactionButtonsNode strongSelf.reactionButtonsNode = reactionButtonsNode
reactionButtonsNode.reactionSelected = { value in reactionButtonsNode.reactionSelected = { value in
guard let strongSelf = self, let item = strongSelf.item else { guard let strongSelf = weakSelf.value, let item = strongSelf.item else {
return return
} }
item.controllerInteraction.updateMessageReaction(item.message, .reaction(value)) item.controllerInteraction.updateMessageReaction(item.message, .reaction(value))
} }
reactionButtonsNode.openReactionPreview = { gesture, sourceNode, value in reactionButtonsNode.openReactionPreview = { gesture, sourceNode, value in
guard let strongSelf = self, let item = strongSelf.item else { guard let strongSelf = weakSelf.value, let item = strongSelf.item else {
gesture?.cancel() gesture?.cancel()
return return
} }
@ -1070,7 +1070,7 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
if let forwardInfo = item.message.forwardInfo, forwardInfo.flags.contains(.isImported) { if let forwardInfo = item.message.forwardInfo, forwardInfo.flags.contains(.isImported) {
strongSelf.dateAndStatusNode.pressed = { strongSelf.dateAndStatusNode.pressed = {
guard let strongSelf = self else { guard let strongSelf = weakSelf.value else {
return return
} }
item.controllerInteraction.displayImportedMessageTooltip(strongSelf.dateAndStatusNode) item.controllerInteraction.displayImportedMessageTooltip(strongSelf.dateAndStatusNode)
@ -1085,8 +1085,17 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
f() f()
} }
} }
}
return (ListViewItemNodeLayout(contentSize: layoutSize, insets: layoutInsets), { animation, _, synchronousLoads in
finishAsyncLayout(animation, synchronousLoads)
}) })
} }
let weakSelf = Weak(self)
return { item, params, mergedTop, mergedBottom, dateHeaderAtBottom -> (ListViewItemNodeLayout, (ListViewItemUpdateAnimation, ListViewItemApply, Bool) -> Void) in
return continueAsyncLayout(weakSelf, item, params, mergedTop, mergedBottom, dateHeaderAtBottom)
}
} }
@objc func tapLongTapOrDoubleTapGesture(_ recognizer: TapLongTapOrDoubleTapGestureRecognizer) { @objc func tapLongTapOrDoubleTapGesture(_ recognizer: TapLongTapOrDoubleTapGestureRecognizer) {

View File

@ -734,7 +734,7 @@ final class PeerChannelMemberCategoriesContext {
let context: ChannelMemberCategoryListContext let context: ChannelMemberCategoryListContext
let emptyTimeout: Double let emptyTimeout: Double
switch key { switch key {
case .admins(nil), .banned(nil), .recentSearch(nil), .restricted(nil), .restrictedAndBanned(nil), .recent, .contacts: case .admins(nil), .banned(nil), .recentSearch(""), .restricted(nil), .restrictedAndBanned(nil), .recent, .contacts:
emptyTimeout = defaultEmptyTimeout emptyTimeout = defaultEmptyTimeout
default: default:
emptyTimeout = 0.0 emptyTimeout = 0.0