[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,6 +505,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
}
deinit {
let _ = { () -> Void in
self.pauseAnimations()
self.displayLink.invalidate()
@ -521,6 +522,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
self.waitingForNodesDisposable.dispose()
self.reorderFeedbackDisposable?.dispose()
}()
}
@objc private func tapGesture(_ gestureRecognizer: UITapGestureRecognizer) {

View File

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

View File

@ -636,7 +636,11 @@ public final class MediaBox {
subscriber.putCompletion()
return EmptyDisposable
} 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.putCompletion()
return EmptyDisposable
@ -677,6 +681,15 @@ public final class MediaBox {
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,6 +5287,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
let _ = ChatControllerCount.modify { value in
return value - 1
}
let deallocate: () -> Void = {
self.historyStateDisposable?.dispose()
self.messageIndexDisposable.dispose()
self.navigationActionDisposable.dispose()
@ -5360,6 +5362,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
self.sendAsPeersDisposable?.dispose()
self.preloadAttachBotIconsDisposables?.dispose()
}
deallocate()
}
public func updatePresentationMode(_ mode: ChatControllerPresentationMode) {
self.updateChatPresentationInterfaceState(animated: false, interactive: false, {

View File

@ -818,7 +818,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
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 layoutConstants = chatMessageItemLayoutConstants(layoutConstants, params: params, presentationData: item.presentationData)
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
}
return (ListViewItemNodeLayout(contentSize: layoutSize, insets: layoutInsets), { [weak self] animation, _, synchronousLoads in
if let strongSelf = self {
func finishLayout(_ animation: ListViewItemUpdateAnimation, _ apply: ListViewItemApply, _ synchronousLoads: Bool) {
if let strongSelf = weakSelf.value {
strongSelf.appliedForwardInfo = (forwardSource, forwardAuthorSignature)
strongSelf.updateAccessibilityData(accessibilityData)
@ -1473,7 +1473,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
} else {
isAppearing = true
deliveryFailedNode = ChatMessageDeliveryFailedNode(tapped: {
if let item = self?.item {
if let strongSelf = weakSelf.value, let item = strongSelf.item {
item.controllerInteraction.requestRedeliveryOfFailedMessages(item.content.firstMessage.id)
}
})
@ -1504,12 +1504,12 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
if actionButtonsNode !== strongSelf.actionButtonsNode {
strongSelf.actionButtonsNode = actionButtonsNode
actionButtonsNode.buttonPressed = { button in
if let strongSelf = self {
if let strongSelf = weakSelf.value {
strongSelf.performMessageButtonAction(button: button)
}
}
actionButtonsNode.buttonLongTapped = { button in
if let strongSelf = self {
if let strongSelf = weakSelf.value {
strongSelf.presentMessageButtonContextMenu(button: button)
}
}
@ -1536,13 +1536,13 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
if reactionButtonsNode !== strongSelf.reactionButtonsNode {
strongSelf.reactionButtonsNode = reactionButtonsNode
reactionButtonsNode.reactionSelected = { value in
guard let strongSelf = self, let item = strongSelf.item else {
guard let strongSelf = weakSelf.value, let item = strongSelf.item else {
return
}
item.controllerInteraction.updateMessageReaction(item.message, .reaction(value))
}
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()
return
}
@ -1590,7 +1590,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
if let forwardInfo = item.message.forwardInfo, forwardInfo.flags.contains(.isImported) {
strongSelf.dateAndStatusNode.pressed = {
guard let strongSelf = self else {
guard let strongSelf = weakSelf.value else {
return
}
item.controllerInteraction.displayImportedMessageTooltip(strongSelf.dateAndStatusNode)
@ -1605,8 +1605,16 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
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) {

View File

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

View File

@ -345,7 +345,7 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
let currentShareButtonNode = self.shareButtonNode
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 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
if let strongSelf = self {
func finishAsyncLayout(_ animation: ListViewItemUpdateAnimation, _ synchronousLoads: Bool) {
if let strongSelf = weakSelf.value {
var transition: ContainedViewLayoutTransition = .immediate
if case let .System(duration, _) = animation {
transition = .animated(duration: duration, curve: .spring)
@ -951,7 +951,7 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
} else {
isAppearing = true
deliveryFailedNode = ChatMessageDeliveryFailedNode(tapped: {
if let item = self?.item {
if let strongSelf = weakSelf.value, let item = strongSelf.item {
item.controllerInteraction.requestRedeliveryOfFailedMessages(item.content.firstMessage.id)
}
})
@ -982,12 +982,12 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
if actionButtonsNode !== strongSelf.actionButtonsNode {
strongSelf.actionButtonsNode = actionButtonsNode
actionButtonsNode.buttonPressed = { button in
if let strongSelf = self {
if let strongSelf = weakSelf.value {
strongSelf.performMessageButtonAction(button: button)
}
}
actionButtonsNode.buttonLongTapped = { button in
if let strongSelf = self {
if let strongSelf = weakSelf.value {
strongSelf.presentMessageButtonContextMenu(button: button)
}
}
@ -1014,13 +1014,13 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
if reactionButtonsNode !== strongSelf.reactionButtonsNode {
strongSelf.reactionButtonsNode = reactionButtonsNode
reactionButtonsNode.reactionSelected = { value in
guard let strongSelf = self, let item = strongSelf.item else {
guard let strongSelf = weakSelf.value, let item = strongSelf.item else {
return
}
item.controllerInteraction.updateMessageReaction(item.message, .reaction(value))
}
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()
return
}
@ -1070,7 +1070,7 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
if let forwardInfo = item.message.forwardInfo, forwardInfo.flags.contains(.isImported) {
strongSelf.dateAndStatusNode.pressed = {
guard let strongSelf = self else {
guard let strongSelf = weakSelf.value else {
return
}
item.controllerInteraction.displayImportedMessageTooltip(strongSelf.dateAndStatusNode)
@ -1085,8 +1085,17 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
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) {

View File

@ -734,7 +734,7 @@ final class PeerChannelMemberCategoriesContext {
let context: ChannelMemberCategoryListContext
let emptyTimeout: Double
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
default:
emptyTimeout = 0.0