diff --git a/submodules/AccountContext/Sources/AccountContext.swift b/submodules/AccountContext/Sources/AccountContext.swift index d0800017ce..ff0845ec2c 100644 --- a/submodules/AccountContext/Sources/AccountContext.swift +++ b/submodules/AccountContext/Sources/AccountContext.swift @@ -738,6 +738,6 @@ public protocol AccountContext: class { func applyMaxReadIndex(for location: ChatLocation, contextHolder: Atomic, messageIndex: MessageIndex) func scheduleGroupCall(peerId: PeerId) - func joinGroupCall(peerId: PeerId, invite: String?, requestJoinAsPeerId: ((@escaping (PeerId?) -> Void) -> Void)?, activeCall: CachedChannelData.ActiveCall) + func joinGroupCall(peerId: PeerId, invite: String?, requestJoinAsPeerId: ((@escaping (PeerId?) -> Void) -> Void)?, activeCall: EngineGroupCallDescription) func requestCall(peerId: PeerId, isVideo: Bool, completion: @escaping () -> Void) } diff --git a/submodules/AccountContext/Sources/PresentationCallManager.swift b/submodules/AccountContext/Sources/PresentationCallManager.swift index 0d0983bb68..4e47725f2b 100644 --- a/submodules/AccountContext/Sources/PresentationCallManager.swift +++ b/submodules/AccountContext/Sources/PresentationCallManager.swift @@ -459,11 +459,11 @@ public protocol PresentationGroupCall: class { func loadMoreMembers(token: String) } -public protocol PresentationCallManager: class { +public protocol PresentationCallManager: AnyObject { var currentCallSignal: Signal { get } var currentGroupCallSignal: Signal { get } func requestCall(context: AccountContext, peerId: PeerId, isVideo: Bool, endCurrentIfAny: Bool) -> RequestCallResult - func joinGroupCall(context: AccountContext, peerId: PeerId, invite: String?, requestJoinAsPeerId: ((@escaping (PeerId?) -> Void) -> Void)?, initialCall: CachedChannelData.ActiveCall, endCurrentIfAny: Bool) -> JoinGroupCallManagerResult + func joinGroupCall(context: AccountContext, peerId: PeerId, invite: String?, requestJoinAsPeerId: ((@escaping (PeerId?) -> Void) -> Void)?, initialCall: EngineGroupCallDescription, endCurrentIfAny: Bool) -> JoinGroupCallManagerResult func scheduleGroupCall(context: AccountContext, peerId: PeerId, endCurrentIfAny: Bool) -> RequestScheduleGroupCallResult } diff --git a/submodules/ActionSheetPeerItem/BUILD b/submodules/ActionSheetPeerItem/BUILD index a80d9284a8..df81383f16 100644 --- a/submodules/ActionSheetPeerItem/BUILD +++ b/submodules/ActionSheetPeerItem/BUILD @@ -7,7 +7,6 @@ swift_library( "Sources/**/*.swift", ]), deps = [ - "//submodules/Postbox:Postbox", "//submodules/TelegramCore:TelegramCore", "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", diff --git a/submodules/ActionSheetPeerItem/Sources/ActionSheetPeerItem.swift b/submodules/ActionSheetPeerItem/Sources/ActionSheetPeerItem.swift index 0ebacb71a0..ca81c18456 100644 --- a/submodules/ActionSheetPeerItem/Sources/ActionSheetPeerItem.swift +++ b/submodules/ActionSheetPeerItem/Sources/ActionSheetPeerItem.swift @@ -3,21 +3,20 @@ import UIKit import AsyncDisplayKit import Display import TelegramCore -import Postbox import TelegramPresentationData import AvatarNode import AccountContext public class ActionSheetPeerItem: ActionSheetItem { public let context: AccountContext - public let peer: Peer + public let peer: EnginePeer public let theme: PresentationTheme public let title: String public let isSelected: Bool public let strings: PresentationStrings public let action: () -> Void - public init(context: AccountContext, peer: Peer, title: String, isSelected: Bool, strings: PresentationStrings, theme: PresentationTheme, action: @escaping () -> Void) { + public init(context: AccountContext, peer: EnginePeer, title: String, isSelected: Bool, strings: PresentationStrings, theme: PresentationTheme, action: @escaping () -> Void) { self.context = context self.peer = peer self.title = title diff --git a/submodules/AnimatedAvatarSetNode/BUILD b/submodules/AnimatedAvatarSetNode/BUILD index 3e13b3823d..95d1481e21 100644 --- a/submodules/AnimatedAvatarSetNode/BUILD +++ b/submodules/AnimatedAvatarSetNode/BUILD @@ -10,7 +10,6 @@ swift_library( "//submodules/Display:Display", "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", - "//submodules/Postbox:Postbox", "//submodules/TelegramCore:TelegramCore", "//submodules/AccountContext:AccountContext", "//submodules/AvatarNode:AvatarNode", diff --git a/submodules/AnimatedAvatarSetNode/Sources/AnimatedAvatarSetNode.swift b/submodules/AnimatedAvatarSetNode/Sources/AnimatedAvatarSetNode.swift index f4d240578c..fcf565bc4b 100644 --- a/submodules/AnimatedAvatarSetNode/Sources/AnimatedAvatarSetNode.swift +++ b/submodules/AnimatedAvatarSetNode/Sources/AnimatedAvatarSetNode.swift @@ -4,7 +4,6 @@ import Display import AsyncDisplayKit import AvatarNode import SwiftSignalKit -import Postbox import TelegramCore import AccountContext import AudioBlob @@ -13,12 +12,12 @@ public final class AnimatedAvatarSetContext { public final class Content { fileprivate final class Item { fileprivate struct Key: Hashable { - var peerId: PeerId + var peerId: EnginePeer.Id } - fileprivate let peer: Peer + fileprivate let peer: EnginePeer - fileprivate init(peer: Peer) { + fileprivate init(peer: EnginePeer) { self.peer = peer } } @@ -31,20 +30,20 @@ public final class AnimatedAvatarSetContext { } private final class ItemState { - let peer: Peer + let peer: EnginePeer - init(peer: Peer) { + init(peer: EnginePeer) { self.peer = peer } } - private var peers: [Peer] = [] - private var itemStates: [PeerId: ItemState] = [:] + private var peers: [EnginePeer] = [] + private var itemStates: [EnginePeer.Id: ItemState] = [:] public init() { } - public func update(peers: [Peer], animated: Bool) -> Content { + public func update(peers: [EnginePeer], animated: Bool) -> Content { var items: [(Content.Item.Key, Content.Item)] = [] for peer in peers { items.append((Content.Item.Key(peerId: peer.id), Content.Item(peer: peer))) @@ -63,7 +62,7 @@ private final class ContentNode: ASDisplayNode { private var disposable: Disposable? - init(context: AccountContext, peer: Peer, synchronousLoad: Bool) { + init(context: AccountContext, peer: EnginePeer, synchronousLoad: Bool) { self.unclippedNode = ASImageNode() self.clippedNode = ASImageNode() @@ -72,7 +71,7 @@ private final class ContentNode: ASDisplayNode { self.addSubnode(self.unclippedNode) self.addSubnode(self.clippedNode) - if let representation = peer.smallProfileImage, let signal = peerAvatarImage(account: context.account, peerReference: PeerReference(peer), authorOfMessage: nil, representation: representation, displayDimensions: CGSize(width: 30.0, height: 30.0), synchronousLoad: synchronousLoad) { + if let representation = peer.smallProfileImage, let signal = peerAvatarImage(account: context.account, peerReference: PeerReference(peer._asPeer()), authorOfMessage: nil, representation: representation, displayDimensions: CGSize(width: 30.0, height: 30.0), synchronousLoad: synchronousLoad) { let image = generateImage(CGSize(width: 30.0, height: 30.0), rotatedContext: { size, context in context.clear(CGRect(origin: CGPoint(), size: size)) context.setFillColor(UIColor.lightGray.cgColor) @@ -252,8 +251,7 @@ public final class AnimatedAvatarSetNode: ASDisplayNode { return CGSize(width: contentWidth, height: contentHeight) } - public func updateAudioLevels(color: UIColor, backgroundColor: UIColor, levels: [PeerId: Float]) { - //print("updateAudioLevels visible: \(self.contentNodes.keys.map(\.peerId.id)) data: \(levels)") + public func updateAudioLevels(color: UIColor, backgroundColor: UIColor, levels: [EnginePeer.Id: Float]) { for (key, itemNode) in self.contentNodes { if let value = levels[key.peerId] { itemNode.updateAudioLevel(color: color, backgroundColor: backgroundColor, value: value) diff --git a/submodules/AnimationUI/BUILD b/submodules/AnimationUI/BUILD index 643f7c7cd3..8bac875566 100644 --- a/submodules/AnimationUI/BUILD +++ b/submodules/AnimationUI/BUILD @@ -7,16 +7,7 @@ swift_library( "Sources/**/*.swift", ]), deps = [ - "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", - "//submodules/Postbox:Postbox", - "//submodules/TelegramCore:TelegramCore", "//submodules/AsyncDisplayKit:AsyncDisplayKit", - "//submodules/Display:Display", - "//submodules/YuvConversion:YuvConversion", - "//submodules/StickerResources:StickerResources", - "//submodules/MediaResources:MediaResources", - "//submodules/Tuples:Tuples", - "//submodules/GZip:GZip", "//submodules/rlottie:RLottieBinding", "//submodules/lottie-ios:Lottie", "//submodules/AppBundle:AppBundle", diff --git a/submodules/AvatarNode/Sources/AvatarNode.swift b/submodules/AvatarNode/Sources/AvatarNode.swift index f8abba7970..c0cfad6ed2 100644 --- a/submodules/AvatarNode/Sources/AvatarNode.swift +++ b/submodules/AvatarNode/Sources/AvatarNode.swift @@ -1,7 +1,6 @@ import Foundation import UIKit import AsyncDisplayKit -import Postbox import Display import TelegramCore import SwiftSignalKit @@ -28,8 +27,8 @@ public enum AvatarNodeClipStyle { private class AvatarNodeParameters: NSObject { let theme: PresentationTheme? - let accountPeerId: PeerId? - let peerId: PeerId? + let accountPeerId: EnginePeer.Id? + let peerId: EnginePeer.Id? let letters: [String] let font: UIFont let icon: AvatarNodeIcon @@ -37,7 +36,7 @@ private class AvatarNodeParameters: NSObject { let hasImage: Bool let clipStyle: AvatarNodeClipStyle - init(theme: PresentationTheme?, accountPeerId: PeerId?, peerId: PeerId?, letters: [String], font: UIFont, icon: AvatarNodeIcon, explicitColorIndex: Int?, hasImage: Bool, clipStyle: AvatarNodeClipStyle) { + init(theme: PresentationTheme?, accountPeerId: EnginePeer.Id?, peerId: EnginePeer.Id?, letters: [String], font: UIFont, icon: AvatarNodeIcon, explicitColorIndex: Int?, hasImage: Bool, clipStyle: AvatarNodeClipStyle) { self.theme = theme self.accountPeerId = accountPeerId self.peerId = peerId @@ -85,7 +84,7 @@ public enum AvatarNodeExplicitIcon { private enum AvatarNodeState: Equatable { case empty - case peerAvatar(PeerId, [String], TelegramMediaImageRepresentation?) + case peerAvatar(EnginePeer.Id, [String], TelegramMediaImageRepresentation?) case custom(letter: [String], explicitColorIndex: Int?, explicitIcon: AvatarNodeExplicitIcon?) } @@ -303,7 +302,7 @@ public final class AvatarNode: ASDisplayNode { self.imageNode.isHidden = true } - public func setPeer(context: AccountContext, theme: PresentationTheme, peer: Peer?, authorOfMessage: MessageReference? = nil, overrideImage: AvatarNodeImageOverride? = nil, emptyColor: UIColor? = nil, clipStyle: AvatarNodeClipStyle = .round, synchronousLoad: Bool = false, displayDimensions: CGSize = CGSize(width: 60.0, height: 60.0), storeUnrounded: Bool = false) { + public func setPeer(context: AccountContext, theme: PresentationTheme, peer: EnginePeer?, authorOfMessage: MessageReference? = nil, overrideImage: AvatarNodeImageOverride? = nil, emptyColor: UIColor? = nil, clipStyle: AvatarNodeClipStyle = .round, synchronousLoad: Bool = false, displayDimensions: CGSize = CGSize(width: 60.0, height: 60.0), storeUnrounded: Bool = false) { var synchronousLoad = synchronousLoad var representation: TelegramMediaImageRepresentation? var icon = AvatarNodeIcon.none @@ -336,7 +335,7 @@ public final class AvatarNode: ASDisplayNode { } else if peer?.restrictionText(platform: "ios", contentSettings: context.currentContentSettings.with { $0 }) == nil { representation = peer?.smallProfileImage } - let updatedState: AvatarNodeState = .peerAvatar(peer?.id ?? PeerId(0), peer?.displayLetters ?? [], representation) + let updatedState: AvatarNodeState = .peerAvatar(peer?.id ?? EnginePeer.Id(0), peer?.displayLetters ?? [], representation) if updatedState != self.state || overrideImage != self.overrideImage || theme !== self.theme { self.state = updatedState self.overrideImage = overrideImage @@ -344,7 +343,7 @@ public final class AvatarNode: ASDisplayNode { let parameters: AvatarNodeParameters - if let peer = peer, let signal = peerAvatarImage(account: context.account, peerReference: PeerReference(peer), authorOfMessage: authorOfMessage, representation: representation, displayDimensions: displayDimensions, emptyColor: emptyColor, synchronousLoad: synchronousLoad, provideUnrounded: storeUnrounded) { + if let peer = peer, let signal = peerAvatarImage(account: context.account, peerReference: PeerReference(peer._asPeer()), authorOfMessage: authorOfMessage, representation: representation, displayDimensions: displayDimensions, emptyColor: emptyColor, synchronousLoad: synchronousLoad, provideUnrounded: storeUnrounded) { self.contents = nil self.displaySuspended = true self.imageReady.set(self.imageNode.contentReady) @@ -380,7 +379,7 @@ public final class AvatarNode: ASDisplayNode { } self.editOverlayNode?.isHidden = true - parameters = AvatarNodeParameters(theme: theme, accountPeerId: context.account.peerId, peerId: peer?.id ?? PeerId(0), letters: peer?.displayLetters ?? [], font: self.font, icon: icon, explicitColorIndex: nil, hasImage: false, clipStyle: clipStyle) + parameters = AvatarNodeParameters(theme: theme, accountPeerId: context.account.peerId, peerId: peer?.id ?? EnginePeer.Id(0), letters: peer?.displayLetters ?? [], font: self.font, icon: icon, explicitColorIndex: nil, hasImage: false, clipStyle: clipStyle) } if self.parameters == nil || self.parameters != parameters { self.parameters = parameters @@ -593,7 +592,7 @@ public final class AvatarNode: ASDisplayNode { } } - static func asyncLayout(_ node: AvatarNode?) -> (_ context: AccountContext, _ peer: Peer, _ font: UIFont) -> () -> AvatarNode? { + static func asyncLayout(_ node: AvatarNode?) -> (_ context: AccountContext, _ peer: EnginePeer, _ font: UIFont) -> () -> AvatarNode? { let currentState = node?.state let createNode = node == nil return { [weak node] context, peer, font in @@ -622,7 +621,7 @@ public final class AvatarNode: ASDisplayNode { } } -public func drawPeerAvatarLetters(context: CGContext, size: CGSize, round: Bool = true, font: UIFont, letters: [String], peerId: PeerId) { +public func drawPeerAvatarLetters(context: CGContext, size: CGSize, round: Bool = true, font: UIFont, letters: [String], peerId: EnginePeer.Id) { if round { context.beginPath() context.addEllipse(in: CGRect(x: 0.0, y: 0.0, width: size.width, height: diff --git a/submodules/BotPaymentsUI/BUILD b/submodules/BotPaymentsUI/BUILD index f99f6e631d..b8672e7958 100644 --- a/submodules/BotPaymentsUI/BUILD +++ b/submodules/BotPaymentsUI/BUILD @@ -8,7 +8,6 @@ swift_library( ]), deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", - "//submodules/Postbox:Postbox", "//submodules/TelegramCore:TelegramCore", "//submodules/TelegramPresentationData:TelegramPresentationData", "//submodules/LocalAuth:LocalAuth", diff --git a/submodules/BotPaymentsUI/Sources/BotCheckoutController.swift b/submodules/BotPaymentsUI/Sources/BotCheckoutController.swift index c9b48ea0bd..0f9fbea0ed 100644 --- a/submodules/BotPaymentsUI/Sources/BotCheckoutController.swift +++ b/submodules/BotPaymentsUI/Sources/BotCheckoutController.swift @@ -4,7 +4,6 @@ import Display import AsyncDisplayKit import TelegramCore import SwiftSignalKit -import Postbox import TelegramPresentationData import AccountContext @@ -25,7 +24,7 @@ public final class BotCheckoutController: ViewController { self.validatedFormInfo = validatedFormInfo } - public static func fetch(context: AccountContext, messageId: MessageId) -> Signal { + public static func fetch(context: AccountContext, messageId: EngineMessage.Id) -> Signal { let presentationData = context.sharedContext.currentPresentationData.with { $0 } let themeParams: [String: Any] = [ "bg_color": Int32(bitPattern: presentationData.theme.list.plainBackgroundColor.argb), @@ -78,8 +77,8 @@ public final class BotCheckoutController: ViewController { private let context: AccountContext private let invoice: TelegramMediaInvoice - private let messageId: MessageId - private let completed: (String, MessageId?) -> Void + private let messageId: EngineMessage.Id + private let completed: (String, EngineMessage.Id?) -> Void private var presentationData: PresentationData @@ -87,7 +86,7 @@ public final class BotCheckoutController: ViewController { private let inputData: Promise - public init(context: AccountContext, invoice: TelegramMediaInvoice, messageId: MessageId, inputData: Promise, completed: @escaping (String, MessageId?) -> Void) { + public init(context: AccountContext, invoice: TelegramMediaInvoice, messageId: EngineMessage.Id, inputData: Promise, completed: @escaping (String, EngineMessage.Id?) -> Void) { self.context = context self.invoice = invoice self.messageId = messageId @@ -120,8 +119,6 @@ public final class BotCheckoutController: ViewController { self?.dismiss() }, completed: self.completed) - //displayNode.enableInteractiveDismiss = true - displayNode.dismiss = { [weak self] in self?.presentingViewController?.dismiss(animated: false, completion: nil) } diff --git a/submodules/BotPaymentsUI/Sources/BotCheckoutControllerNode.swift b/submodules/BotPaymentsUI/Sources/BotCheckoutControllerNode.swift index b68909f221..99225ce428 100644 --- a/submodules/BotPaymentsUI/Sources/BotCheckoutControllerNode.swift +++ b/submodules/BotPaymentsUI/Sources/BotCheckoutControllerNode.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import AsyncDisplayKit import Display -import Postbox import TelegramCore import SwiftSignalKit import PassKit @@ -327,7 +326,7 @@ private func currentTotalPrice(paymentForm: BotPaymentForm?, validatedFormInfo: return totalPrice } -private func botCheckoutControllerEntries(presentationData: PresentationData, state: BotCheckoutControllerState, invoice: TelegramMediaInvoice, paymentForm: BotPaymentForm?, formInfo: BotPaymentRequestedInfo?, validatedFormInfo: BotPaymentValidatedFormInfo?, currentShippingOptionId: String?, currentPaymentMethod: BotCheckoutPaymentMethod?, currentTip: Int64?, botPeer: Peer?) -> [BotCheckoutEntry] { +private func botCheckoutControllerEntries(presentationData: PresentationData, state: BotCheckoutControllerState, invoice: TelegramMediaInvoice, paymentForm: BotPaymentForm?, formInfo: BotPaymentRequestedInfo?, validatedFormInfo: BotPaymentValidatedFormInfo?, currentShippingOptionId: String?, currentPaymentMethod: BotCheckoutPaymentMethod?, currentTip: Int64?, botPeer: EnginePeer?) -> [BotCheckoutEntry] { var entries: [BotCheckoutEntry] = [] var botName = "" @@ -504,10 +503,10 @@ private func availablePaymentMethods(form: BotPaymentForm, current: BotCheckoutP final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthorizationViewControllerDelegate { private weak var controller: BotCheckoutController? private let context: AccountContext - private let messageId: MessageId + private let messageId: EngineMessage.Id private let present: (ViewController, Any?) -> Void private let dismissAnimated: () -> Void - private let completed: (String, MessageId?) -> Void + private let completed: (String, EngineMessage.Id?) -> Void private var stateValue = BotCheckoutControllerState() private let state = ValuePromise(BotCheckoutControllerState(), ignoreRepeated: true) @@ -538,7 +537,7 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz private var passwordTip: String? private var passwordTipDisposable: Disposable? - init(controller: BotCheckoutController?, navigationBar: NavigationBar, context: AccountContext, invoice: TelegramMediaInvoice, messageId: MessageId, inputData: Promise, present: @escaping (ViewController, Any?) -> Void, dismissAnimated: @escaping () -> Void, completed: @escaping (String, MessageId?) -> Void) { + init(controller: BotCheckoutController?, navigationBar: NavigationBar, context: AccountContext, invoice: TelegramMediaInvoice, messageId: EngineMessage.Id, inputData: Promise, present: @escaping (ViewController, Any?) -> Void, dismissAnimated: @escaping () -> Void, completed: @escaping (String, EngineMessage.Id?) -> Void) { self.controller = controller self.context = context self.messageId = messageId @@ -566,14 +565,22 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz ensureTipInputVisibleImpl?() }) - let paymentBotPeer = paymentFormAndInfo.get() - |> map { paymentFormAndInfo -> PeerId? in - return paymentFormAndInfo?.0.paymentBotId + let paymentBotPeer: Signal = paymentFormAndInfo.get() + |> map { paymentFormAndInfo -> EnginePeer.Id? in + if let paymentBotId = paymentFormAndInfo?.0.paymentBotId { + return paymentBotId + } else { + return nil + } } |> distinctUntilChanged - |> mapToSignal { peerId -> Signal in - return context.account.postbox.transaction { transaction -> Peer? in - return peerId.flatMap(transaction.getPeer) + |> mapToSignal { peerId -> Signal in + if let peerId = peerId { + return context.engine.data.get( + TelegramEngine.EngineData.Item.Peer.Peer(id: peerId) + ) + } else { + return .single(nil) } } @@ -1124,9 +1131,10 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz } let botPeerId = self.messageId.peerId - let _ = (self.context.account.postbox.transaction({ transaction -> Peer? in - return transaction.getPeer(botPeerId) - }) |> deliverOnMainQueue).start(next: { [weak self] botPeer in + let _ = (context.engine.data.get( + TelegramEngine.EngineData.Item.Peer.Peer(id: botPeerId) + ) + |> deliverOnMainQueue).start(next: { [weak self] botPeer in if let strongSelf = self, let botPeer = botPeer { let request = PKPaymentRequest() @@ -1192,10 +1200,17 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz } if !liabilityNoticeAccepted { - let botPeer: Signal = self.context.account.postbox.transaction { transaction -> Peer? in - return transaction.getPeer(paymentForm.paymentBotId) - } - let _ = (combineLatest(ApplicationSpecificNotice.getBotPaymentLiability(accountManager: self.context.sharedContext.accountManager, peerId: paymentForm.paymentBotId), botPeer, self.context.account.postbox.loadedPeerWithId(paymentForm.providerId)) + let botPeer: Signal = context.engine.data.get( + TelegramEngine.EngineData.Item.Peer.Peer(id: paymentForm.paymentBotId) + ) + let providerPeer: Signal = context.engine.data.get( + TelegramEngine.EngineData.Item.Peer.Peer(id: paymentForm.providerId) + ) + let _ = (combineLatest( + ApplicationSpecificNotice.getBotPaymentLiability(accountManager: self.context.sharedContext.accountManager, peerId: paymentForm.paymentBotId), + botPeer, + providerPeer + ) |> deliverOnMainQueue).start(next: { [weak self] value, botPeer, providerPeer in if let strongSelf = self, let botPeer = botPeer { if value { @@ -1203,7 +1218,7 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz } else { let paymentText = strongSelf.presentationData.strings.Checkout_PaymentLiabilityAlert .replacingOccurrences(of: "{target}", with: botPeer.displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder)) - .replacingOccurrences(of: "{payment_system}", with: providerPeer.displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder)) + .replacingOccurrences(of: "{payment_system}", with: providerPeer?.displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder) ?? "") strongSelf.present(textAlertController(context: strongSelf.context, title: strongSelf.presentationData.strings.Checkout_LiabilityAlertTitle, text: paymentText, actions: [TextAlertAction(type: .genericAction, title: strongSelf.presentationData.strings.Common_Cancel, action: { }), TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: { if let strongSelf = self { @@ -1244,7 +1259,7 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz applePayController.presentingViewController?.dismiss(animated: true, completion: nil) } - let proceedWithCompletion: (Bool, MessageId?) -> Void = { success, receiptMessageId in + let proceedWithCompletion: (Bool, EngineMessage.Id?) -> Void = { success, receiptMessageId in guard let strongSelf = self else { return } diff --git a/submodules/BotPaymentsUI/Sources/BotCheckoutInfoController.swift b/submodules/BotPaymentsUI/Sources/BotCheckoutInfoController.swift index 5365164c59..b3864e50f8 100644 --- a/submodules/BotPaymentsUI/Sources/BotCheckoutInfoController.swift +++ b/submodules/BotPaymentsUI/Sources/BotCheckoutInfoController.swift @@ -3,7 +3,6 @@ import UIKit import SwiftSignalKit import Display import TelegramCore -import Postbox import TelegramPresentationData import ProgressNavigationButtonNode import AccountContext @@ -31,7 +30,7 @@ final class BotCheckoutInfoController: ViewController { private let context: AccountContext private let invoice: BotPaymentInvoice - private let messageId: MessageId + private let messageId: EngineMessage.Id private let initialFormInfo: BotPaymentRequestedInfo private let focus: BotCheckoutInfoControllerFocus @@ -44,7 +43,14 @@ final class BotCheckoutInfoController: ViewController { private var doneItem: UIBarButtonItem? private var activityItem: UIBarButtonItem? - public init(context: AccountContext, invoice: BotPaymentInvoice, messageId: MessageId, initialFormInfo: BotPaymentRequestedInfo, focus: BotCheckoutInfoControllerFocus, formInfoUpdated: @escaping (BotPaymentRequestedInfo, BotPaymentValidatedFormInfo) -> Void) { + public init( + context: AccountContext, + invoice: BotPaymentInvoice, + messageId: EngineMessage.Id, + initialFormInfo: BotPaymentRequestedInfo, + focus: BotCheckoutInfoControllerFocus, + formInfoUpdated: @escaping (BotPaymentRequestedInfo, BotPaymentValidatedFormInfo) -> Void + ) { self.context = context self.invoice = invoice self.messageId = messageId diff --git a/submodules/BotPaymentsUI/Sources/BotCheckoutInfoControllerNode.swift b/submodules/BotPaymentsUI/Sources/BotCheckoutInfoControllerNode.swift index 2a92d8c313..45093b3233 100644 --- a/submodules/BotPaymentsUI/Sources/BotCheckoutInfoControllerNode.swift +++ b/submodules/BotPaymentsUI/Sources/BotCheckoutInfoControllerNode.swift @@ -3,7 +3,6 @@ import UIKit import AsyncDisplayKit import Display import TelegramCore -import Postbox import SwiftSignalKit import TelegramPresentationData import AccountContext @@ -96,7 +95,7 @@ enum BotCheckoutInfoControllerStatus { final class BotCheckoutInfoControllerNode: ViewControllerTracingNode, UIScrollViewDelegate { private let context: AccountContext private let invoice: BotPaymentInvoice - private let messageId: MessageId + private let messageId: EngineMessage.Id private var focus: BotCheckoutInfoControllerFocus? private let dismiss: () -> Void @@ -124,7 +123,20 @@ final class BotCheckoutInfoControllerNode: ViewControllerTracingNode, UIScrollVi private let verifyDisposable = MetaDisposable() private var isVerifying = false - init(context: AccountContext, invoice: BotPaymentInvoice, messageId: MessageId, formInfo: BotPaymentRequestedInfo, focus: BotCheckoutInfoControllerFocus, theme: PresentationTheme, strings: PresentationStrings, dismiss: @escaping () -> Void, openCountrySelection: @escaping () -> Void, updateStatus: @escaping (BotCheckoutInfoControllerStatus) -> Void, formInfoUpdated: @escaping (BotPaymentRequestedInfo, BotPaymentValidatedFormInfo) -> Void, present: @escaping (ViewController, Any?) -> Void) { + init( + context: AccountContext, + invoice: BotPaymentInvoice, + messageId: EngineMessage.Id, + formInfo: BotPaymentRequestedInfo, + focus: BotCheckoutInfoControllerFocus, + theme: PresentationTheme, + strings: PresentationStrings, + dismiss: @escaping () -> Void, + openCountrySelection: @escaping () -> Void, + updateStatus: @escaping (BotCheckoutInfoControllerStatus) -> Void, + formInfoUpdated: @escaping (BotPaymentRequestedInfo, BotPaymentValidatedFormInfo) -> Void, + present: @escaping (ViewController, Any?) -> Void + ) { self.context = context self.invoice = invoice self.messageId = messageId diff --git a/submodules/BotPaymentsUI/Sources/BotCheckoutNativeCardEntryController.swift b/submodules/BotPaymentsUI/Sources/BotCheckoutNativeCardEntryController.swift index a5bb8e6564..e880872994 100644 --- a/submodules/BotPaymentsUI/Sources/BotCheckoutNativeCardEntryController.swift +++ b/submodules/BotPaymentsUI/Sources/BotCheckoutNativeCardEntryController.swift @@ -4,7 +4,6 @@ import AsyncDisplayKit import SwiftSignalKit import Display import TelegramCore -import Postbox import TelegramPresentationData import ProgressNavigationButtonNode import AccountContext diff --git a/submodules/BotPaymentsUI/Sources/BotCheckoutNativeCardEntryControllerNode.swift b/submodules/BotPaymentsUI/Sources/BotCheckoutNativeCardEntryControllerNode.swift index 2cec187417..d28cfddea6 100644 --- a/submodules/BotPaymentsUI/Sources/BotCheckoutNativeCardEntryControllerNode.swift +++ b/submodules/BotPaymentsUI/Sources/BotCheckoutNativeCardEntryControllerNode.swift @@ -3,7 +3,6 @@ import UIKit import AsyncDisplayKit import Display import TelegramCore -import Postbox import SwiftSignalKit import TelegramPresentationData import Stripe diff --git a/submodules/BotPaymentsUI/Sources/BotCheckoutPaymentShippingOptionSheetController.swift b/submodules/BotPaymentsUI/Sources/BotCheckoutPaymentShippingOptionSheetController.swift index 56587bd3c9..4c00294d07 100644 --- a/submodules/BotPaymentsUI/Sources/BotCheckoutPaymentShippingOptionSheetController.swift +++ b/submodules/BotPaymentsUI/Sources/BotCheckoutPaymentShippingOptionSheetController.swift @@ -12,7 +12,6 @@ final class BotCheckoutPaymentShippingOptionSheetController: ActionSheetControll init(context: AccountContext, currency: String, options: [BotPaymentShippingOption], currentId: String?, applyValue: @escaping (String) -> Void) { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let theme = presentationData.theme let strings = presentationData.strings super.init(theme: ActionSheetControllerTheme(presentationData: presentationData)) diff --git a/submodules/BotPaymentsUI/Sources/BotCheckoutWebInteractionController.swift b/submodules/BotPaymentsUI/Sources/BotCheckoutWebInteractionController.swift index faaa68ba27..2bf329b15d 100644 --- a/submodules/BotPaymentsUI/Sources/BotCheckoutWebInteractionController.swift +++ b/submodules/BotPaymentsUI/Sources/BotCheckoutWebInteractionController.swift @@ -4,7 +4,6 @@ import Display import AsyncDisplayKit import TelegramCore import SwiftSignalKit -import Postbox import TelegramPresentationData import AccountContext diff --git a/submodules/BotPaymentsUI/Sources/BotReceiptController.swift b/submodules/BotPaymentsUI/Sources/BotReceiptController.swift index f09ee95dce..9ba4f97970 100644 --- a/submodules/BotPaymentsUI/Sources/BotReceiptController.swift +++ b/submodules/BotPaymentsUI/Sources/BotReceiptController.swift @@ -4,7 +4,6 @@ import Display import AsyncDisplayKit import TelegramCore import SwiftSignalKit -import Postbox import TelegramPresentationData import AccountContext @@ -19,13 +18,13 @@ public final class BotReceiptController: ViewController { } private let context: AccountContext - private let messageId: MessageId + private let messageId: EngineMessage.Id private var presentationData: PresentationData private var didPlayPresentationAnimation = false - public init(context: AccountContext, messageId: MessageId) { + public init(context: AccountContext, messageId: EngineMessage.Id) { self.context = context self.messageId = messageId diff --git a/submodules/BotPaymentsUI/Sources/BotReceiptControllerNode.swift b/submodules/BotPaymentsUI/Sources/BotReceiptControllerNode.swift index a34c40d6e5..fb7524d351 100644 --- a/submodules/BotPaymentsUI/Sources/BotReceiptControllerNode.swift +++ b/submodules/BotPaymentsUI/Sources/BotReceiptControllerNode.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import AsyncDisplayKit import Display -import Postbox import TelegramCore import SwiftSignalKit import TelegramPresentationData @@ -174,7 +173,7 @@ enum BotReceiptEntry: ItemListNodeEntry { } } -private func botReceiptControllerEntries(presentationData: PresentationData, invoice: TelegramMediaInvoice?, formInvoice: BotPaymentInvoice?, formInfo: BotPaymentRequestedInfo?, shippingOption: BotPaymentShippingOption?, paymentMethodTitle: String?, botPeer: Peer?, tipAmount: Int64?) -> [BotReceiptEntry] { +private func botReceiptControllerEntries(presentationData: PresentationData, invoice: TelegramMediaInvoice?, formInvoice: BotPaymentInvoice?, formInfo: BotPaymentRequestedInfo?, shippingOption: BotPaymentShippingOption?, paymentMethodTitle: String?, botPeer: EnginePeer?, tipAmount: Int64?) -> [BotReceiptEntry] { var entries: [BotReceiptEntry] = [] var botName = "" @@ -279,7 +278,7 @@ final class BotReceiptControllerNode: ItemListControllerNode { private let actionButtonPanelSeparator: ASDisplayNode private let actionButton: BotCheckoutActionButton - init(controller: ItemListController?, navigationBar: NavigationBar, context: AccountContext, messageId: MessageId, dismissAnimated: @escaping () -> Void) { + init(controller: ItemListController?, navigationBar: NavigationBar, context: AccountContext, messageId: EngineMessage.Id, dismissAnimated: @escaping () -> Void) { self.context = context self.dismissAnimated = dismissAnimated @@ -287,7 +286,13 @@ final class BotReceiptControllerNode: ItemListControllerNode { let arguments = BotReceiptControllerArguments(account: context.account) - let signal: Signal<(ItemListPresentationData, (ItemListNodeState, Any)), NoError> = combineLatest(context.sharedContext.presentationData, receiptData.get(), context.account.postbox.loadedPeerWithId(messageId.peerId)) + let signal: Signal<(ItemListPresentationData, (ItemListNodeState, Any)), NoError> = combineLatest( + context.sharedContext.presentationData, + receiptData.get(), + context.engine.data.get( + TelegramEngine.EngineData.Item.Peer.Peer(id: messageId.peerId) + ) + ) |> map { presentationData, receiptData, botPeer -> (ItemListPresentationData, (ItemListNodeState, Any)) in let nodeState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: botReceiptControllerEntries(presentationData: presentationData, invoice: receiptData?.4, formInvoice: receiptData?.0, formInfo: receiptData?.1, shippingOption: receiptData?.2, paymentMethodTitle: receiptData?.3, botPeer: botPeer, tipAmount: receiptData?.5), style: .blocks, focusItemTag: nil, emptyStateItem: nil, animateChanges: false) diff --git a/submodules/CallListUI/BUILD b/submodules/CallListUI/BUILD index 15d61132a7..1a2c6bb541 100644 --- a/submodules/CallListUI/BUILD +++ b/submodules/CallListUI/BUILD @@ -10,7 +10,6 @@ swift_library( "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", - "//submodules/Postbox:Postbox", "//submodules/TelegramCore:TelegramCore", "//submodules/TelegramPresentationData:TelegramPresentationData", "//submodules/TelegramUIPreferences:TelegramUIPreferences", diff --git a/submodules/CallListUI/Sources/CallListCallItem.swift b/submodules/CallListUI/Sources/CallListCallItem.swift index 06674a7027..3b08bf4f70 100644 --- a/submodules/CallListUI/Sources/CallListCallItem.swift +++ b/submodules/CallListUI/Sources/CallListCallItem.swift @@ -1,7 +1,6 @@ import Foundation import UIKit import AsyncDisplayKit -import Postbox import Display import SwiftSignalKit import TelegramCore @@ -68,8 +67,8 @@ class CallListCallItem: ListViewItem { let dateTimeFormat: PresentationDateTimeFormat let context: AccountContext let style: ItemListStyle - let topMessage: Message - let messages: [Message] + let topMessage: EngineMessage + let messages: [EngineMessage] let editing: Bool let revealed: Bool let interaction: CallListNodeInteraction @@ -78,7 +77,7 @@ class CallListCallItem: ListViewItem { let headerAccessoryItem: ListViewAccessoryItem? let header: ListViewItemHeader? - init(presentationData: ItemListPresentationData, dateTimeFormat: PresentationDateTimeFormat, context: AccountContext, style: ItemListStyle, topMessage: Message, messages: [Message], editing: Bool, revealed: Bool, displayHeader: Bool, interaction: CallListNodeInteraction) { + init(presentationData: ItemListPresentationData, dateTimeFormat: PresentationDateTimeFormat, context: AccountContext, style: ItemListStyle, topMessage: EngineMessage, messages: [EngineMessage], editing: Bool, revealed: Bool, displayHeader: Bool, interaction: CallListNodeInteraction) { self.presentationData = presentationData self.dateTimeFormat = dateTimeFormat self.context = context @@ -488,7 +487,7 @@ class CallListCallItemNode: ItemListRevealOptionsItemNode { if peer.isDeleted { overrideImage = .deletedIcon } - strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: peer, overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads) + strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(peer), overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads) } return (strongSelf.avatarNode.ready, { [weak strongSelf] animated in diff --git a/submodules/CallListUI/Sources/CallListController.swift b/submodules/CallListUI/Sources/CallListController.swift index 9fb3a327d0..74c0ec4405 100644 --- a/submodules/CallListUI/Sources/CallListController.swift +++ b/submodules/CallListUI/Sources/CallListController.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import Display import AsyncDisplayKit -import Postbox import TelegramCore import SwiftSignalKit import TelegramPresentationData @@ -205,10 +204,11 @@ public final class CallListController: TelegramBaseController { } }, openInfo: { [weak self] peerId, messages in if let strongSelf = self { - let _ = (strongSelf.context.account.postbox.loadedPeerWithId(peerId) - |> take(1) + let _ = (strongSelf.context.engine.data.get( + TelegramEngine.EngineData.Item.Peer.Peer(id: peerId) + ) |> deliverOnMainQueue).start(next: { peer in - if let strongSelf = self, let controller = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer, mode: .calls(messages: messages), avatarInitiallyExpanded: false, fromChat: false) { + if let strongSelf = self, let peer = peer, let controller = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, peer: peer._asPeer(), mode: .calls(messages: messages.map({ $0._asMessage() })), avatarInitiallyExpanded: false, fromChat: false) { (strongSelf.navigationController as? NavigationController)?.pushViewController(controller) } }) @@ -436,7 +436,7 @@ public final class CallListController: TelegramBaseController { } } - private func call(_ peerId: PeerId, isVideo: Bool, began: (() -> Void)? = nil) { + private func call(_ peerId: EnginePeer.Id, isVideo: Bool, began: (() -> Void)? = nil) { self.peerViewDisposable.set((self.context.account.viewTracker.peerView(peerId) |> take(1) |> deliverOnMainQueue).start(next: { [weak self] view in diff --git a/submodules/CallListUI/Sources/CallListControllerNode.swift b/submodules/CallListUI/Sources/CallListControllerNode.swift index dcd3cbdd65..06dcda5d71 100644 --- a/submodules/CallListUI/Sources/CallListControllerNode.swift +++ b/submodules/CallListUI/Sources/CallListControllerNode.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import AsyncDisplayKit import Display -import Postbox import TelegramCore import SwiftSignalKit import TelegramPresentationData @@ -25,8 +24,8 @@ private struct CallListNodeListViewTransition { let stationaryItemRange: (Int, Int)? } -private extension CallListViewEntry { - var lowestIndex: MessageIndex { +private extension EngineCallList.Item { + var lowestIndex: EngineMessage.Index { switch self { case let .hole(index): return index @@ -42,7 +41,7 @@ private extension CallListViewEntry { } } - var highestIndex: MessageIndex { + var highestIndex: EngineMessage.Index { switch self { case let .hole(index): return index @@ -60,14 +59,14 @@ private extension CallListViewEntry { } final class CallListNodeInteraction { - let setMessageIdWithRevealedOptions: (MessageId?, MessageId?) -> Void - let call: (PeerId, Bool) -> Void - let openInfo: (PeerId, [Message]) -> Void - let delete: ([MessageId]) -> Void + let setMessageIdWithRevealedOptions: (EngineMessage.Id?, EngineMessage.Id?) -> Void + let call: (EnginePeer.Id, Bool) -> Void + let openInfo: (EnginePeer.Id, [EngineMessage]) -> Void + let delete: ([EngineMessage.Id]) -> Void let updateShowCallsTab: (Bool) -> Void - let openGroupCall: (PeerId) -> Void + let openGroupCall: (EnginePeer.Id) -> Void - init(setMessageIdWithRevealedOptions: @escaping (MessageId?, MessageId?) -> Void, call: @escaping (PeerId, Bool) -> Void, openInfo: @escaping (PeerId, [Message]) -> Void, delete: @escaping ([MessageId]) -> Void, updateShowCallsTab: @escaping (Bool) -> Void, openGroupCall: @escaping (PeerId) -> Void) { + init(setMessageIdWithRevealedOptions: @escaping (EngineMessage.Id?, EngineMessage.Id?) -> Void, call: @escaping (EnginePeer.Id, Bool) -> Void, openInfo: @escaping (EnginePeer.Id, [EngineMessage]) -> Void, delete: @escaping ([EngineMessage.Id]) -> Void, updateShowCallsTab: @escaping (Bool) -> Void, openGroupCall: @escaping (EnginePeer.Id) -> Void) { self.setMessageIdWithRevealedOptions = setMessageIdWithRevealedOptions self.call = call self.openInfo = openInfo @@ -82,7 +81,7 @@ struct CallListNodeState: Equatable { let dateTimeFormat: PresentationDateTimeFormat let disableAnimations: Bool let editing: Bool - let messageIdWithRevealedOptions: MessageId? + let messageIdWithRevealedOptions: EngineMessage.Id? func withUpdatedPresentationData(presentationData: ItemListPresentationData, dateTimeFormat: PresentationDateTimeFormat, disableAnimations: Bool) -> CallListNodeState { return CallListNodeState(presentationData: presentationData, dateTimeFormat: dateTimeFormat, disableAnimations: disableAnimations, editing: self.editing, messageIdWithRevealedOptions: self.messageIdWithRevealedOptions) @@ -92,7 +91,7 @@ struct CallListNodeState: Equatable { return CallListNodeState(presentationData: self.presentationData, dateTimeFormat: self.dateTimeFormat, disableAnimations: self.disableAnimations, editing: editing, messageIdWithRevealedOptions: self.messageIdWithRevealedOptions) } - func withUpdatedMessageIdWithRevealedOptions(_ messageIdWithRevealedOptions: MessageId?) -> CallListNodeState { + func withUpdatedMessageIdWithRevealedOptions(_ messageIdWithRevealedOptions: EngineMessage.Id?) -> CallListNodeState { return CallListNodeState(presentationData: self.presentationData, dateTimeFormat: self.dateTimeFormat, disableAnimations: self.disableAnimations, editing: self.editing, messageIdWithRevealedOptions: messageIdWithRevealedOptions) } @@ -177,9 +176,9 @@ final class CallListControllerNode: ASDisplayNode { return _ready.get() } - var peerSelected: ((PeerId) -> Void)? + var peerSelected: ((EnginePeer.Id) -> Void)? var activateSearch: (() -> Void)? - var deletePeerChat: ((PeerId) -> Void)? + var deletePeerChat: ((EnginePeer.Id) -> Void)? var startNewCall: (() -> Void)? private let viewProcessingQueue = Queue() @@ -191,7 +190,7 @@ final class CallListControllerNode: ASDisplayNode { private var currentState: CallListNodeState private let statePromise: ValuePromise - private var currentLocationAndType = CallListNodeLocationAndType(location: .initial(count: 50), type: .all) + private var currentLocationAndType = CallListNodeLocationAndType(location: .initial(count: 50), scope: .all) private let callListLocationAndType = ValuePromise() private let callListDisposable = MetaDisposable() @@ -205,9 +204,9 @@ final class CallListControllerNode: ASDisplayNode { private let emptyButtonIconNode: ASImageNode private let emptyButtonTextNode: ImmediateTextNode - private let call: (PeerId, Bool) -> Void - private let joinGroupCall: (PeerId, CachedChannelData.ActiveCall) -> Void - private let openInfo: (PeerId, [Message]) -> Void + private let call: (EnginePeer.Id, Bool) -> Void + private let joinGroupCall: (EnginePeer.Id, EngineGroupCallDescription) -> Void + private let openInfo: (EnginePeer.Id, [EngineMessage]) -> Void private let emptyStateUpdated: (Bool) -> Void private let emptyStatePromise = Promise() @@ -215,7 +214,7 @@ final class CallListControllerNode: ASDisplayNode { private let openGroupCallDisposable = MetaDisposable() - init(controller: CallListController, context: AccountContext, mode: CallListControllerMode, presentationData: PresentationData, call: @escaping (PeerId, Bool) -> Void, joinGroupCall: @escaping (PeerId, CachedChannelData.ActiveCall) -> Void, openInfo: @escaping (PeerId, [Message]) -> Void, emptyStateUpdated: @escaping (Bool) -> Void) { + init(controller: CallListController, context: AccountContext, mode: CallListControllerMode, presentationData: PresentationData, call: @escaping (EnginePeer.Id, Bool) -> Void, joinGroupCall: @escaping (EnginePeer.Id, EngineGroupCallDescription) -> Void, openInfo: @escaping (EnginePeer.Id, [EngineMessage]) -> Void, emptyStateUpdated: @escaping (Bool) -> Void) { self.controller = controller self.context = context self.mode = mode @@ -325,10 +324,9 @@ final class CallListControllerNode: ASDisplayNode { guard let strongSelf = self, let peerId = messageIds.first?.peerId else { return } - - let _ = (strongSelf.context.account.postbox.transaction { transaction -> Peer? in - return transaction.getPeer(peerId) - } + let _ = (context.engine.data.get( + TelegramEngine.EngineData.Item.Peer.Peer(id: peerId) + ) |> deliverOnMainQueue).start(next: { peer in guard let strongSelf = self, let peer = peer else { return @@ -381,19 +379,12 @@ final class CallListControllerNode: ASDisplayNode { } let disposable = strongSelf.openGroupCallDisposable - - let account = strongSelf.context.account + let engine = strongSelf.context.engine - var signal: Signal = strongSelf.context.account.postbox.transaction { transaction -> CachedChannelData.ActiveCall? in - let cachedData = transaction.getPeerCachedData(peerId: peerId) - if let cachedData = cachedData as? CachedChannelData { - return cachedData.activeCall - } else if let cachedData = cachedData as? CachedGroupData { - return cachedData.activeCall - } - return nil - } - |> mapToSignal { activeCall -> Signal in + var signal: Signal = context.engine.data.get( + TelegramEngine.EngineData.Item.Peer.GroupCallDescription(id: peerId) + ) + |> mapToSignal { activeCall -> Signal in if let activeCall = activeCall { return .single(activeCall) } else { @@ -446,7 +437,7 @@ final class CallListControllerNode: ASDisplayNode { let callListViewUpdate = self.callListLocationAndType.get() |> distinctUntilChanged |> mapToSignal { locationAndType in - return callListViewForLocationAndType(locationAndType: locationAndType, account: context.account) + return callListViewForLocationAndType(locationAndType: locationAndType, engine: context.engine) } let previousView = Atomic(value: nil) @@ -468,10 +459,10 @@ final class CallListControllerNode: ASDisplayNode { return value } - let currentGroupCallPeerId: Signal + let currentGroupCallPeerId: Signal if let callManager = context.sharedContext.callManager { currentGroupCallPeerId = callManager.currentGroupCallSignal - |> map { call -> PeerId? in + |> map { call -> EnginePeer.Id? in call?.peerId } |> distinctUntilChanged @@ -479,19 +470,14 @@ final class CallListControllerNode: ASDisplayNode { currentGroupCallPeerId = .single(nil) } - let groupCalls = context.account.postbox.tailChatListView(groupId: .root, count: 100, summaryComponents: ChatListEntrySummaryComponents()) - |> map { view -> [Peer] in - var result: [Peer] = [] - for entry in view.0.entries { - switch entry { - case let .MessageEntry(_, _, _, _, _, renderedPeer, _, _, _, _): - if let channel = renderedPeer.peer as? TelegramChannel, channel.flags.contains(.hasActiveVoiceChat) { - result.append(channel) - } else if let group = renderedPeer.peer as? TelegramGroup, group.flags.contains(.hasActiveVoiceChat) { - result.append(group) - } - default: - break + let groupCalls: Signal<[EnginePeer], NoError> = context.engine.messages.chatList(group: .root, count: 100) + |> map { chatList -> [EnginePeer] in + var result: [EnginePeer] = [] + for item in chatList.items { + if case let .channel(channel) = item.renderedPeer.peer, channel.flags.contains(.hasActiveVoiceChat) { + result.append(.channel(channel)) + } else if case let .legacyGroup(group) = item.renderedPeer.peer, group.flags.contains(.hasActiveVoiceChat) { + result.append(.legacyGroup(group)) } } return result.sorted(by: { lhs, rhs in @@ -503,19 +489,15 @@ final class CallListControllerNode: ASDisplayNode { return lhs.id < rhs.id }) } - |> distinctUntilChanged(isEqual: { lhs, rhs in - if lhs.count != rhs.count { - return false - } - for i in 0 ..< lhs.count { - if !lhs[i].isEqual(rhs[i]) { - return false - } - } - return true - }) + |> distinctUntilChanged - let callListNodeViewTransition = combineLatest(callListViewUpdate, self.statePromise.get(), groupCalls, showCallsTab, currentGroupCallPeerId) + let callListNodeViewTransition = combineLatest( + callListViewUpdate, + self.statePromise.get(), + groupCalls, + showCallsTab, + currentGroupCallPeerId + ) |> mapToQueue { (updateAndType, state, groupCalls, showCallsTab, currentGroupCallPeerId) -> Signal in let (update, type) = updateAndType @@ -545,7 +527,7 @@ final class CallListControllerNode: ASDisplayNode { } } else { if previous?.originalView === update.view { - let previousCalls = previous?.filteredEntries.compactMap { item -> PeerId? in + let previousCalls = previous?.filteredEntries.compactMap { item -> EnginePeer.Id? in switch item { case let .groupCall(peer, _, _): return peer.id @@ -553,7 +535,7 @@ final class CallListControllerNode: ASDisplayNode { return nil } } - let updatedCalls = processedView.filteredEntries.compactMap { item -> PeerId? in + let updatedCalls = processedView.filteredEntries.compactMap { item -> EnginePeer.Id? in switch item { case let .groupCall(peer, _, _): return peer.id @@ -582,12 +564,14 @@ final class CallListControllerNode: ASDisplayNode { } } - return preparedCallListNodeViewTransition(from: previous, to: processedView, reason: reason, disableAnimations: disableAnimations, account: context.account, scrollPosition: update.scrollPosition) + return preparedCallListNodeViewTransition(from: previous, to: processedView, reason: reason, disableAnimations: disableAnimations, context: context, scrollPosition: update.scrollPosition) |> map({ mappedCallListNodeViewListTransition(context: context, presentationData: state.presentationData, showSettings: showSettings, nodeInteraction: nodeInteraction, transition: $0) }) |> runOn(prepareOnMainQueue ? Queue.mainQueue() : viewProcessingQueue) } - let appliedTransition = callListNodeViewTransition |> deliverOnMainQueue |> mapToQueue { [weak self] transition -> Signal in + let appliedTransition = callListNodeViewTransition + |> deliverOnMainQueue + |> mapToQueue { [weak self] transition -> Signal in if let strongSelf = self { return strongSelf.enqueueTransition(transition) } @@ -597,14 +581,14 @@ final class CallListControllerNode: ASDisplayNode { self.listNode.displayedItemRangeChanged = { [weak self] range, transactionOpaqueState in if let strongSelf = self, let range = range.loadedRange, let view = (transactionOpaqueState as? CallListOpaqueTransactionState)?.callListView.originalView { var location: CallListNodeLocation? - if range.firstIndex < 5 && view.later != nil { - location = .navigation(index: view.entries[view.entries.count - 1].highestIndex) - } else if range.firstIndex >= 5 && range.lastIndex >= view.entries.count - 5 && view.earlier != nil { - location = .navigation(index: view.entries[0].lowestIndex) + if range.firstIndex < 5 && view.hasLater { + location = .navigation(index: view.items[view.items.count - 1].highestIndex) + } else if range.firstIndex >= 5 && range.lastIndex >= view.items.count - 5 && view.hasEarlier { + location = .navigation(index: view.items[0].lowestIndex) } if let location = location, location != strongSelf.currentLocationAndType.location { - strongSelf.currentLocationAndType = CallListNodeLocationAndType(location: location, type: strongSelf.currentLocationAndType.type) + strongSelf.currentLocationAndType = CallListNodeLocationAndType(location: location, scope: strongSelf.currentLocationAndType.scope) strongSelf.callListLocationAndType.set(strongSelf.currentLocationAndType) } } @@ -615,9 +599,10 @@ final class CallListControllerNode: ASDisplayNode { self.callListLocationAndType.set(self.currentLocationAndType) let emptySignal = self.emptyStatePromise.get() |> distinctUntilChanged - let typeSignal = self.callListLocationAndType.get() |> map { locationAndType -> CallListViewType in - return locationAndType.type - } |> distinctUntilChanged + let typeSignal = self.callListLocationAndType.get() |> map { locationAndType -> EngineCallList.Scope in + return locationAndType.scope + } + |> distinctUntilChanged self.emptyStateDisposable.set((combineLatest(emptySignal, typeSignal, self.statePromise.get()) |> deliverOnMainQueue).start(next: { [weak self] isEmpty, type, state in if let strongSelf = self { @@ -649,7 +634,7 @@ final class CallListControllerNode: ASDisplayNode { self.emptyButtonIconNode.image = generateTintedImage(image: UIImage(bundleImageName: "Call List/CallIcon"), color: presentationData.theme.list.itemAccentColor) - self.updateEmptyPlaceholder(theme: presentationData.theme, strings: presentationData.strings, type: self.currentLocationAndType.type, isHidden: self.emptyTextNode.alpha.isZero) + self.updateEmptyPlaceholder(theme: presentationData.theme, strings: presentationData.strings, type: self.currentLocationAndType.scope, isHidden: self.emptyTextNode.alpha.isZero) self.updateState { return $0.withUpdatedPresentationData(presentationData: ItemListPresentationData(presentationData), dateTimeFormat: presentationData.dateTimeFormat, disableAnimations: true) @@ -666,7 +651,7 @@ final class CallListControllerNode: ASDisplayNode { private let textFont = Font.regular(16.0) private let buttonFont = Font.regular(17.0) - func updateEmptyPlaceholder(theme: PresentationTheme, strings: PresentationStrings, type: CallListViewType, isHidden: Bool) { + func updateEmptyPlaceholder(theme: PresentationTheme, strings: PresentationStrings, type: EngineCallList.Scope, isHidden: Bool) { let alpha: CGFloat = isHidden ? 0.0 : 1.0 let previousAlpha = self.emptyTextNode.alpha self.emptyTextNode.alpha = alpha @@ -691,7 +676,7 @@ final class CallListControllerNode: ASDisplayNode { self.emptyButtonNode.isUserInteractionEnabled = !isHidden if !isHidden { - let type = self.currentLocationAndType.type + let type = self.currentLocationAndType.scope let emptyText: String let buttonText = strings.Calls_StartNewCall if type == .missed { @@ -730,16 +715,16 @@ final class CallListControllerNode: ASDisplayNode { } } - func updateType(_ type: CallListViewType) { - if type != self.currentLocationAndType.type { + func updateType(_ type: EngineCallList.Scope) { + if type != self.currentLocationAndType.scope { if let view = self.callListView?.originalView { - var index: MessageIndex - if !view.entries.isEmpty { - index = view.entries[view.entries.count - 1].highestIndex + var index: EngineMessage.Index + if !view.items.isEmpty { + index = view.items[view.items.count - 1].highestIndex } else { - index = MessageIndex.absoluteUpperBound() + index = EngineMessage.Index.absoluteUpperBound() } - self.currentLocationAndType = CallListNodeLocationAndType(location: .changeType(index: index), type: type) + self.currentLocationAndType = CallListNodeLocationAndType(location: .changeType(index: index), scope: type) self.emptyStatePromise.set(.single(false)) self.callListLocationAndType.set(self.currentLocationAndType) } @@ -799,11 +784,11 @@ final class CallListControllerNode: ASDisplayNode { } func scrollToLatest() { - if let view = self.callListView?.originalView, view.later == nil { + if let view = self.callListView?.originalView, !view.hasLater { self.listNode.transaction(deleteIndices: [], insertIndicesAndItems: [], updateIndicesAndItems: [], options: [.Synchronous], scrollToItem: ListViewScrollToItem(index: 0, position: .top(0.0), animated: true, curve: .Default(duration: nil), directionHint: .Up), updateSizeAndInsets: nil, stationaryItemRange: nil, updateOpaqueState: nil, completion: { _ in }) } else { - let location: CallListNodeLocation = .scroll(index: MessageIndex.absoluteUpperBound(), sourceIndex: MessageIndex.absoluteLowerBound(), scrollPosition: .top(0.0), animated: true) - self.currentLocationAndType = CallListNodeLocationAndType(location: location, type: self.currentLocationAndType.type) + let location: CallListNodeLocation = .scroll(index: EngineMessage.Index.absoluteUpperBound(), sourceIndex: EngineMessage.Index.absoluteLowerBound(), scrollPosition: .top(0.0), animated: true) + self.currentLocationAndType = CallListNodeLocationAndType(location: location, scope: self.currentLocationAndType.scope) self.callListLocationAndType.set(self.currentLocationAndType) } } diff --git a/submodules/CallListUI/Sources/CallListGroupCallItem.swift b/submodules/CallListUI/Sources/CallListGroupCallItem.swift index 8cbdd2028f..d75d37dbc2 100644 --- a/submodules/CallListUI/Sources/CallListGroupCallItem.swift +++ b/submodules/CallListUI/Sources/CallListGroupCallItem.swift @@ -1,7 +1,6 @@ import Foundation import UIKit import AsyncDisplayKit -import Postbox import Display import SwiftSignalKit import TelegramCore @@ -60,7 +59,7 @@ class CallListGroupCallItem: ListViewItem { let presentationData: ItemListPresentationData let context: AccountContext let style: ItemListStyle - let peer: Peer + let peer: EnginePeer let isActive: Bool let editing: Bool let interaction: CallListNodeInteraction @@ -69,7 +68,7 @@ class CallListGroupCallItem: ListViewItem { let headerAccessoryItem: ListViewAccessoryItem? let header: ListViewItemHeader? - init(presentationData: ItemListPresentationData, context: AccountContext, style: ItemListStyle, peer: Peer, isActive: Bool, editing: Bool, interaction: CallListNodeInteraction) { + init(presentationData: ItemListPresentationData, context: AccountContext, style: ItemListStyle, peer: EnginePeer, isActive: Bool, editing: Bool, interaction: CallListNodeInteraction) { self.presentationData = presentationData self.context = context self.style = style diff --git a/submodules/CallListUI/Sources/CallListHoleItem.swift b/submodules/CallListUI/Sources/CallListHoleItem.swift index a75785810e..1dd52fda6b 100644 --- a/submodules/CallListUI/Sources/CallListHoleItem.swift +++ b/submodules/CallListUI/Sources/CallListHoleItem.swift @@ -1,7 +1,6 @@ import Foundation import UIKit import AsyncDisplayKit -import Postbox import Display import SwiftSignalKit import TelegramPresentationData diff --git a/submodules/CallListUI/Sources/CallListNodeEntries.swift b/submodules/CallListUI/Sources/CallListNodeEntries.swift index 42e20926b1..47f83e21e0 100644 --- a/submodules/CallListUI/Sources/CallListNodeEntries.swift +++ b/submodules/CallListUI/Sources/CallListNodeEntries.swift @@ -1,18 +1,17 @@ import Foundation import UIKit -import Postbox import TelegramCore import TelegramPresentationData import MergeLists enum CallListNodeEntryId: Hashable { case setting(Int32) - case groupCall(PeerId) - case hole(MessageIndex) - case message(MessageIndex) + case groupCall(EnginePeer.Id) + case hole(EngineMessage.Index) + case message(EngineMessage.Index) } -private func areMessagesEqual(_ lhsMessage: Message, _ rhsMessage: Message) -> Bool { +private func areMessagesEqual(_ lhsMessage: EngineMessage, _ rhsMessage: EngineMessage) -> Bool { if lhsMessage.stableVersion != rhsMessage.stableVersion { return false } @@ -26,9 +25,9 @@ enum CallListNodeEntry: Comparable, Identifiable { enum SortIndex: Comparable { case displayTab case displayTabInfo - case groupCall(PeerId, String) - case message(MessageIndex) - case hole(MessageIndex) + case groupCall(EnginePeer.Id, String) + case message(EngineMessage.Index) + case hole(EngineMessage.Index) static func <(lhs: SortIndex, rhs: SortIndex) -> Bool { switch lhs { @@ -79,9 +78,9 @@ enum CallListNodeEntry: Comparable, Identifiable { case displayTab(PresentationTheme, String, Bool) case displayTabInfo(PresentationTheme, String) - case groupCall(peer: Peer, editing: Bool, isActive: Bool) - case messageEntry(topMessage: Message, messages: [Message], theme: PresentationTheme, strings: PresentationStrings, dateTimeFormat: PresentationDateTimeFormat, editing: Bool, hasActiveRevealControls: Bool, displayHeader: Bool, missed: Bool) - case holeEntry(index: MessageIndex, theme: PresentationTheme) + case groupCall(peer: EnginePeer, editing: Bool, isActive: Bool) + case messageEntry(topMessage: EngineMessage, messages: [EngineMessage], theme: PresentationTheme, strings: PresentationStrings, dateTimeFormat: PresentationDateTimeFormat, editing: Bool, hasActiveRevealControls: Bool, displayHeader: Bool, missed: Bool) + case holeEntry(index: EngineMessage.Index, theme: PresentationTheme) var sortIndex: SortIndex { switch self { @@ -133,7 +132,7 @@ enum CallListNodeEntry: Comparable, Identifiable { } case let .groupCall(lhsPeer, lhsEditing, lhsIsActive): if case let .groupCall(rhsPeer, rhsEditing, rhsIsActive) = rhs { - if !lhsPeer.isEqual(rhsPeer) { + if lhsPeer != rhsPeer { return false } if lhsEditing != rhsEditing { @@ -194,9 +193,9 @@ enum CallListNodeEntry: Comparable, Identifiable { } } -func callListNodeEntriesForView(view: CallListView, groupCalls: [Peer], state: CallListNodeState, showSettings: Bool, showCallsTab: Bool, isRecentCalls: Bool, currentGroupCallPeerId: PeerId?) -> [CallListNodeEntry] { +func callListNodeEntriesForView(view: EngineCallList, groupCalls: [EnginePeer], state: CallListNodeState, showSettings: Bool, showCallsTab: Bool, isRecentCalls: Bool, currentGroupCallPeerId: EnginePeer.Id?) -> [CallListNodeEntry] { var result: [CallListNodeEntry] = [] - for entry in view.entries { + for entry in view.items { switch entry { case let .message(topMessage, messages): result.append(.messageEntry(topMessage: topMessage, messages: messages, theme: state.presentationData.theme, strings: state.presentationData.strings, dateTimeFormat: state.dateTimeFormat, editing: state.editing, hasActiveRevealControls: state.messageIdWithRevealedOptions == topMessage.id, displayHeader: !showSettings && isRecentCalls, missed: !isRecentCalls)) @@ -205,7 +204,7 @@ func callListNodeEntriesForView(view: CallListView, groupCalls: [Peer], state: C } } - if view.later == nil { + if !view.hasLater { if !showSettings && isRecentCalls { for peer in groupCalls.sorted(by: { lhs, rhs in let lhsTitle = lhs.compactDisplayTitle diff --git a/submodules/CallListUI/Sources/CallListNodeLocation.swift b/submodules/CallListUI/Sources/CallListNodeLocation.swift index b7905b6f3c..5a9c07ddcb 100644 --- a/submodules/CallListUI/Sources/CallListNodeLocation.swift +++ b/submodules/CallListUI/Sources/CallListNodeLocation.swift @@ -1,15 +1,14 @@ import Foundation import UIKit -import Postbox import TelegramCore import SwiftSignalKit import Display enum CallListNodeLocation: Equatable { case initial(count: Int) - case changeType(index: MessageIndex) - case navigation(index: MessageIndex) - case scroll(index: MessageIndex, sourceIndex: MessageIndex, scrollPosition: ListViewScrollPosition, animated: Bool) + case changeType(index: EngineMessage.Index) + case navigation(index: EngineMessage.Index) + case scroll(index: EngineMessage.Index, sourceIndex: EngineMessage.Index, scrollPosition: ListViewScrollPosition, animated: Bool) static func ==(lhs: CallListNodeLocation, rhs: CallListNodeLocation) -> Bool { switch lhs { @@ -28,11 +27,7 @@ enum CallListNodeLocation: Equatable { struct CallListNodeLocationAndType: Equatable { let location: CallListNodeLocation - let type: CallListViewType - - static func ==(lhs: CallListNodeLocationAndType, rhs: CallListNodeLocationAndType) -> Bool { - return lhs.location == rhs.location && lhs.type == rhs.type - } + let scope: EngineCallList.Scope } enum CallListNodeViewUpdateType { @@ -44,47 +39,67 @@ enum CallListNodeViewUpdateType { } struct CallListNodeViewUpdate { - let view: CallListView + let view: EngineCallList let type: CallListNodeViewUpdateType let scrollPosition: CallListNodeViewScrollPosition? } -func callListViewForLocationAndType(locationAndType: CallListNodeLocationAndType, account: Account) -> Signal<(CallListNodeViewUpdate, CallListViewType), NoError> { +func callListViewForLocationAndType(locationAndType: CallListNodeLocationAndType, engine: TelegramEngine) -> Signal<(CallListNodeViewUpdate, EngineCallList.Scope), NoError> { switch locationAndType.location { - case let .initial(count): - return account.viewTracker.callListView(type: locationAndType.type, index: MessageIndex.absoluteUpperBound(), count: count) |> map { view -> (CallListNodeViewUpdate, CallListViewType) in - return (CallListNodeViewUpdate(view: view, type: .Generic, scrollPosition: nil), locationAndType.type) + case let .initial(count): + return engine.messages.callList( + scope: locationAndType.scope, + index: EngineMessage.Index.absoluteUpperBound(), + itemCount: count + ) + |> map { view -> (CallListNodeViewUpdate, EngineCallList.Scope) in + return (CallListNodeViewUpdate(view: view, type: .Generic, scrollPosition: nil), locationAndType.scope) + } + case let .changeType(index): + return engine.messages.callList( + scope: locationAndType.scope, + index: index, + itemCount: 120 + ) + |> map { view -> (CallListNodeViewUpdate, EngineCallList.Scope) in + return (CallListNodeViewUpdate(view: view, type: .ReloadAnimated, scrollPosition: nil), locationAndType.scope) + } + case let .navigation(index): + var first = true + return engine.messages.callList( + scope: locationAndType.scope, + index: index, + itemCount: 120 + ) + |> map { view -> (CallListNodeViewUpdate, EngineCallList.Scope) in + let genericType: CallListNodeViewUpdateType + if first { + first = false + genericType = .UpdateVisible + } else { + genericType = .Generic } - case let .changeType(index): - return account.viewTracker.callListView(type: locationAndType.type, index: index, count: 120) |> map { view -> (CallListNodeViewUpdate, CallListViewType) in - return (CallListNodeViewUpdate(view: view, type: .ReloadAnimated, scrollPosition: nil), locationAndType.type) - } - case let .navigation(index): - var first = true - return account.viewTracker.callListView(type: locationAndType.type, index: index, count: 120) |> map { view -> (CallListNodeViewUpdate, CallListViewType) in - let genericType: CallListNodeViewUpdateType - if first { - first = false - genericType = .UpdateVisible - } else { - genericType = .Generic - } - return (CallListNodeViewUpdate(view: view, type: genericType, scrollPosition: nil), locationAndType.type) - } - case let .scroll(index, sourceIndex, scrollPosition, animated): - let directionHint: ListViewScrollToItemDirectionHint = sourceIndex > index ? .Down : .Up - let callScrollPosition: CallListNodeViewScrollPosition = .index(index: index, position: scrollPosition, directionHint: directionHint, animated: animated) - var first = true - return account.viewTracker.callListView(type: locationAndType.type, index: index, count: 120) |> map { view -> (CallListNodeViewUpdate, CallListViewType) in - let genericType: CallListNodeViewUpdateType - let scrollPosition: CallListNodeViewScrollPosition? = first ? callScrollPosition : nil - if first { - first = false - genericType = .UpdateVisible - } else { - genericType = .Generic - } - return (CallListNodeViewUpdate(view: view, type: genericType, scrollPosition: scrollPosition), locationAndType.type) + return (CallListNodeViewUpdate(view: view, type: genericType, scrollPosition: nil), locationAndType.scope) + } + case let .scroll(index, sourceIndex, scrollPosition, animated): + let directionHint: ListViewScrollToItemDirectionHint = sourceIndex > index ? .Down : .Up + let callScrollPosition: CallListNodeViewScrollPosition = .index(index: index, position: scrollPosition, directionHint: directionHint, animated: animated) + var first = true + return engine.messages.callList( + scope: locationAndType.scope, + index: index, + itemCount: 120 + ) + |> map { view -> (CallListNodeViewUpdate, EngineCallList.Scope) in + let genericType: CallListNodeViewUpdateType + let scrollPosition: CallListNodeViewScrollPosition? = first ? callScrollPosition : nil + if first { + first = false + genericType = .UpdateVisible + } else { + genericType = .Generic } + return (CallListNodeViewUpdate(view: view, type: genericType, scrollPosition: scrollPosition), locationAndType.scope) + } } } diff --git a/submodules/CallListUI/Sources/CallListViewTransition.swift b/submodules/CallListUI/Sources/CallListViewTransition.swift index aa70ded605..27c8725318 100644 --- a/submodules/CallListUI/Sources/CallListViewTransition.swift +++ b/submodules/CallListUI/Sources/CallListViewTransition.swift @@ -1,14 +1,14 @@ import Foundation import UIKit -import Postbox import TelegramCore import SwiftSignalKit import Display import MergeLists import ItemListUI +import AccountContext struct CallListNodeView { - let originalView: CallListView + let originalView: EngineCallList let filteredEntries: [CallListNodeEntry] let presentationData: ItemListPresentationData } @@ -45,10 +45,10 @@ struct CallListNodeViewTransition { } enum CallListNodeViewScrollPosition { - case index(index: MessageIndex, position: ListViewScrollPosition, directionHint: ListViewScrollToItemDirectionHint, animated: Bool) + case index(index: EngineMessage.Index, position: ListViewScrollPosition, directionHint: ListViewScrollToItemDirectionHint, animated: Bool) } -func preparedCallListNodeViewTransition(from fromView: CallListNodeView?, to toView: CallListNodeView, reason: CallListNodeViewTransitionReason, disableAnimations: Bool, account: Account, scrollPosition: CallListNodeViewScrollPosition?) -> Signal { +func preparedCallListNodeViewTransition(from fromView: CallListNodeView?, to toView: CallListNodeView, reason: CallListNodeViewTransitionReason, disableAnimations: Bool, context: AccountContext, scrollPosition: CallListNodeViewScrollPosition?) -> Signal { return Signal { subscriber in let (deleteIndices, indicesAndItems, updateIndices) = mergeListsStableWithUpdates(leftList: fromView?.filteredEntries ?? [], rightList: toView.filteredEntries, allUpdated: fromView?.presentationData != toView.presentationData) @@ -68,11 +68,11 @@ func preparedCallListNodeViewTransition(from fromView: CallListNodeView?, to toV var options: ListViewDeleteAndInsertOptions = [] var maxAnimatedInsertionIndex = -1 - var stationaryItemRange: (Int, Int)? - var scrollToItem: ListViewScrollToItem? + let stationaryItemRange: (Int, Int)? = nil + var scrollToItem: ListViewScrollToItem? = nil var wasEmpty = false - if let fromView = fromView, fromView.originalView.entries.isEmpty { + if let fromView = fromView, fromView.originalView.items.isEmpty { wasEmpty = true } diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index 5659012f7f..31d12e57db 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -2228,7 +2228,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController } if canRemoveGlobally, (mainPeer is TelegramGroup || mainPeer is TelegramChannel) { - items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: mainPeer, chatPeer: chatPeer, action: .deleteAndLeave, strings: strongSelf.presentationData.strings, nameDisplayOrder: strongSelf.presentationData.nameDisplayOrder)) + items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: EnginePeer(mainPeer), chatPeer: EnginePeer(chatPeer), action: .deleteAndLeave, strings: strongSelf.presentationData.strings, nameDisplayOrder: strongSelf.presentationData.nameDisplayOrder)) items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.ChatList_DeleteForCurrentUser, color: .destructive, action: { [weak actionSheet] in actionSheet?.dismissAnimated() @@ -2266,7 +2266,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController ], parseMarkdown: true), in: .window(.root)) })) } else { - items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: mainPeer, chatPeer: chatPeer, action: .delete, strings: strongSelf.presentationData.strings, nameDisplayOrder: strongSelf.presentationData.nameDisplayOrder)) + items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: EnginePeer(mainPeer), chatPeer: EnginePeer(chatPeer), action: .delete, strings: strongSelf.presentationData.strings, nameDisplayOrder: strongSelf.presentationData.nameDisplayOrder)) if canClear { let beginClear: (InteractiveHistoryClearingType) -> Void = { type in @@ -2327,7 +2327,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] - items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: mainPeer, chatPeer: chatPeer, action: .clearHistory(canClearCache: false), strings: strongSelf.presentationData.strings, nameDisplayOrder: strongSelf.presentationData.nameDisplayOrder)) + items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: EnginePeer(mainPeer), chatPeer: EnginePeer(chatPeer), action: .clearHistory(canClearCache: false), strings: strongSelf.presentationData.strings, nameDisplayOrder: strongSelf.presentationData.nameDisplayOrder)) if joined || mainPeer.isDeleted { items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Delete, color: .destructive, action: { [weak actionSheet] in @@ -2387,7 +2387,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData) var items: [ActionSheetItem] = [] - items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: mainPeer, chatPeer: chatPeer, action: .deleteAndLeave, strings: strongSelf.presentationData.strings, nameDisplayOrder: strongSelf.presentationData.nameDisplayOrder)) + items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: EnginePeer(mainPeer), chatPeer: EnginePeer(chatPeer), action: .deleteAndLeave, strings: strongSelf.presentationData.strings, nameDisplayOrder: strongSelf.presentationData.nameDisplayOrder)) items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.ChatList_DeleteForCurrentUser, color: .destructive, action: { [weak actionSheet] in actionSheet?.dismissAnimated() @@ -2492,7 +2492,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController let actionSheet = ActionSheetController(presentationData: self.presentationData) var items: [ActionSheetItem] = [] - items.append(DeleteChatPeerActionSheetItem(context: self.context, peer: mainPeer, chatPeer: chatPeer, action: .delete, strings: self.presentationData.strings, nameDisplayOrder: self.presentationData.nameDisplayOrder)) + items.append(DeleteChatPeerActionSheetItem(context: self.context, peer: EnginePeer(mainPeer), chatPeer: EnginePeer(chatPeer), action: .delete, strings: self.presentationData.strings, nameDisplayOrder: self.presentationData.nameDisplayOrder)) if joined || mainPeer.isDeleted { items.append(ActionSheetButtonItem(title: self.presentationData.strings.Common_Delete, color: .destructive, action: { [weak self, weak actionSheet] in diff --git a/submodules/ChatListUI/Sources/Node/ChatListItem.swift b/submodules/ChatListUI/Sources/Node/ChatListItem.swift index 137bf423b7..2329c2e072 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItem.swift @@ -680,7 +680,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { UIView.transition(with: self.avatarNode.view, duration: 0.3, options: [.transitionCrossDissolve], animations: { }, completion: nil) } - self.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: peer, overrideImage: .archivedChatsIcon(hiddenByDefault: groupReference.hiddenByDefault), emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads) + self.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: peer.flatMap(EnginePeer.init), overrideImage: .archivedChatsIcon(hiddenByDefault: groupReference.hiddenByDefault), emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads) } if let peer = peer { @@ -692,7 +692,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { } else if peer.isDeleted { overrideImage = .deletedIcon } - self.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: peer, overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads, displayDimensions: CGSize(width: 60.0, height: 60.0)) + self.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(peer), overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads, displayDimensions: CGSize(width: 60.0, height: 60.0)) } self.contextContainer.isGestureEnabled = enablePreview && !item.editing diff --git a/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift b/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift index fab112e2e2..6b619c9599 100644 --- a/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift +++ b/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift @@ -825,7 +825,7 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode { } else if peer.isDeleted { overrideImage = .deletedIcon } - strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: peer, overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads) + strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(peer), overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads) } case let .deviceContact(_, contact): let letters: [String] diff --git a/submodules/DeleteChatPeerActionSheetItem/Sources/DeleteChatPeerActionSheetItem.swift b/submodules/DeleteChatPeerActionSheetItem/Sources/DeleteChatPeerActionSheetItem.swift index 43e975e098..32e6f49319 100644 --- a/submodules/DeleteChatPeerActionSheetItem/Sources/DeleteChatPeerActionSheetItem.swift +++ b/submodules/DeleteChatPeerActionSheetItem/Sources/DeleteChatPeerActionSheetItem.swift @@ -1,7 +1,6 @@ import Foundation import UIKit import Display -import Postbox import TelegramCore import TelegramPresentationData import TelegramUIPreferences @@ -22,13 +21,13 @@ private let avatarFont = avatarPlaceholderFont(size: 26.0) public final class DeleteChatPeerActionSheetItem: ActionSheetItem { let context: AccountContext - let peer: Peer - let chatPeer: Peer + let peer: EnginePeer + let chatPeer: EnginePeer let action: DeleteChatPeerAction let strings: PresentationStrings let nameDisplayOrder: PresentationPersonNameOrder - public init(context: AccountContext, peer: Peer, chatPeer: Peer, action: DeleteChatPeerAction, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder) { + public init(context: AccountContext, peer: EnginePeer, chatPeer: EnginePeer, action: DeleteChatPeerAction, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder) { self.context = context self.peer = peer self.chatPeer = chatPeer @@ -54,7 +53,7 @@ private final class DeleteChatPeerActionSheetItemNode: ActionSheetItemNode { private let accessibilityArea: AccessibilityAreaNode - init(theme: ActionSheetControllerTheme, strings: PresentationStrings, nameOrder: PresentationPersonNameOrder, context: AccountContext, peer: Peer, chatPeer: Peer, action: DeleteChatPeerAction) { + init(theme: ActionSheetControllerTheme, strings: PresentationStrings, nameOrder: PresentationPersonNameOrder, context: AccountContext, peer: EnginePeer, chatPeer: EnginePeer, action: DeleteChatPeerAction) { self.theme = theme self.strings = strings @@ -107,11 +106,11 @@ private final class DeleteChatPeerActionSheetItemNode: ActionSheetItemNode { case .delete: if chatPeer.id == context.account.peerId { text = PresentationStrings.FormattedString(string: strings.ChatList_DeleteSavedMessagesConfirmation, ranges: []) - } else if let chatPeer = chatPeer as? TelegramGroup { + } else if case let .legacyGroup(chatPeer) = chatPeer { text = strings.ChatList_LeaveGroupConfirmation(chatPeer.title) - } else if let chatPeer = chatPeer as? TelegramChannel { + } else if case let .channel(chatPeer) = chatPeer { text = strings.ChatList_LeaveGroupConfirmation(chatPeer.title) - } else if chatPeer is TelegramSecretChat { + } else if case .secretChat = chatPeer { text = strings.ChatList_DeleteSecretChatConfirmation(peer.displayTitle(strings: strings, displayOrder: nameOrder)) } else { text = strings.ChatList_DeleteChatConfirmation(peer.displayTitle(strings: strings, displayOrder: nameOrder)) @@ -119,11 +118,11 @@ private final class DeleteChatPeerActionSheetItemNode: ActionSheetItemNode { case .deleteAndLeave: if chatPeer.id == context.account.peerId { text = PresentationStrings.FormattedString(string: strings.ChatList_DeleteSavedMessagesConfirmation, ranges: []) - } else if let chatPeer = chatPeer as? TelegramGroup { + } else if case let .legacyGroup(chatPeer) = chatPeer { text = strings.ChatList_DeleteAndLeaveGroupConfirmation(chatPeer.title) - } else if let chatPeer = chatPeer as? TelegramChannel { + } else if case let .channel(chatPeer) = chatPeer { text = strings.ChatList_DeleteAndLeaveGroupConfirmation(chatPeer.title) - } else if chatPeer is TelegramSecretChat { + } else if case .secretChat = chatPeer { text = strings.ChatList_DeleteSecretChatConfirmation(peer.displayTitle(strings: strings, displayOrder: nameOrder)) } else { text = strings.ChatList_DeleteChatConfirmation(peer.displayTitle(strings: strings, displayOrder: nameOrder)) @@ -131,7 +130,7 @@ private final class DeleteChatPeerActionSheetItemNode: ActionSheetItemNode { case let .clearHistory(canClearCache): if peer.id == context.account.peerId { text = PresentationStrings.FormattedString(string: strings.ChatList_DeleteSavedMessagesConfirmation, ranges: []) - } else if peer is TelegramUser { + } else if case .user = peer { text = strings.ChatList_ClearChatConfirmation(peer.displayTitle(strings: strings, displayOrder: nameOrder)) } else { text = strings.Conversation_DeleteAllMessagesInChat(peer.displayTitle(strings: strings, displayOrder: nameOrder)) diff --git a/submodules/HorizontalPeerItem/Sources/HorizontalPeerItem.swift b/submodules/HorizontalPeerItem/Sources/HorizontalPeerItem.swift index fdb191dd2e..3d97c4e3f6 100644 --- a/submodules/HorizontalPeerItem/Sources/HorizontalPeerItem.swift +++ b/submodules/HorizontalPeerItem/Sources/HorizontalPeerItem.swift @@ -187,7 +187,7 @@ public final class HorizontalPeerItemNode: ListViewItemNode { if let strongSelf = self { strongSelf.item = item strongSelf.peerNode.theme = itemTheme - strongSelf.peerNode.setup(context: item.context, theme: item.theme, strings: item.strings, peer: RenderedPeer(peer: item.peer), numberOfLines: 1, synchronousLoad: synchronousLoads) + strongSelf.peerNode.setup(context: item.context, theme: item.theme, strings: item.strings, peer: EngineRenderedPeer(peer: EnginePeer(item.peer)), numberOfLines: 1, synchronousLoad: synchronousLoads) strongSelf.peerNode.frame = CGRect(origin: CGPoint(), size: itemLayout.size) strongSelf.peerNode.updateSelection(selected: item.isPeerSelected(item.peer.id), animated: false) diff --git a/submodules/InviteLinksUI/Sources/ItemListPermanentInviteLinkItem.swift b/submodules/InviteLinksUI/Sources/ItemListPermanentInviteLinkItem.swift index 15c89afb94..a95c3d01c0 100644 --- a/submodules/InviteLinksUI/Sources/ItemListPermanentInviteLinkItem.swift +++ b/submodules/InviteLinksUI/Sources/ItemListPermanentInviteLinkItem.swift @@ -322,7 +322,7 @@ public class ItemListPermanentInviteLinkItemNode: ListViewItemNode, ItemListItem let (invitedPeersLayout, invitedPeersApply) = makeInvitedPeersLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: subtitle, font: titleFont, textColor: subtitleColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - params.rightInset - 20.0 - leftInset - rightInset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) - let avatarsContent = avatarsContext.update(peers: item.peers, animated: false) + let avatarsContent = avatarsContext.update(peers: item.peers.map(EnginePeer.init), animated: false) let verticalInset: CGFloat = 16.0 let fieldHeight: CGFloat = 52.0 diff --git a/submodules/ItemListAvatarAndNameInfoItem/Sources/ItemListAvatarAndNameItem.swift b/submodules/ItemListAvatarAndNameInfoItem/Sources/ItemListAvatarAndNameItem.swift index 714ca9efdb..3a8c99113e 100644 --- a/submodules/ItemListAvatarAndNameInfoItem/Sources/ItemListAvatarAndNameItem.swift +++ b/submodules/ItemListAvatarAndNameInfoItem/Sources/ItemListAvatarAndNameItem.swift @@ -676,7 +676,7 @@ public class ItemListAvatarAndNameInfoItemNode: ListViewItemNode, ItemListItemNo overrideImage = .deletedIcon } - strongSelf.avatarNode.setPeer(context: item.accountContext, theme: item.presentationData.theme, peer: peer, overrideImage: overrideImage, emptyColor: ignoreEmpty ? nil : item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads) + strongSelf.avatarNode.setPeer(context: item.accountContext, theme: item.presentationData.theme, peer: EnginePeer(peer), overrideImage: overrideImage, emptyColor: ignoreEmpty ? nil : item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads) } let avatarFrame = CGRect(origin: CGPoint(x: params.leftInset + 15.0, y: floor((layout.contentSize.height - 66.0) / 2.0)), size: CGSize(width: 66.0, height: 66.0)) diff --git a/submodules/ItemListPeerItem/Sources/ItemListPeerItem.swift b/submodules/ItemListPeerItem/Sources/ItemListPeerItem.swift index 1e69a77038..477e89f4ce 100644 --- a/submodules/ItemListPeerItem/Sources/ItemListPeerItem.swift +++ b/submodules/ItemListPeerItem/Sources/ItemListPeerItem.swift @@ -1106,15 +1106,15 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo transition.updateFrame(node: strongSelf.avatarNode, frame: avatarFrame) if item.peer.id == item.context.account.peerId, case .threatSelfAsSaved = item.aliasHandling { - strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: item.peer, overrideImage: .savedMessagesIcon, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad) + strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(item.peer), overrideImage: .savedMessagesIcon, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad) } else if item.peer.id.isReplies { - strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: item.peer, overrideImage: .repliesIcon, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad) + strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(item.peer), overrideImage: .repliesIcon, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad) } else { var overrideImage: AvatarNodeImageOverride? if item.peer.isDeleted { overrideImage = .deletedIcon } - strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: item.peer, overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad) + strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(item.peer), overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad) } strongSelf.highlightedBackgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -UIScreenPixel), size: CGSize(width: params.width, height: layout.contentSize.height + UIScreenPixel + UIScreenPixel)) diff --git a/submodules/JoinLinkPreviewUI/Sources/JoinLinkPreviewPeerContentNode.swift b/submodules/JoinLinkPreviewUI/Sources/JoinLinkPreviewPeerContentNode.swift index e9d6c6cd83..ce85fc870c 100644 --- a/submodules/JoinLinkPreviewUI/Sources/JoinLinkPreviewPeerContentNode.swift +++ b/submodules/JoinLinkPreviewUI/Sources/JoinLinkPreviewPeerContentNode.swift @@ -49,7 +49,7 @@ final class JoinLinkPreviewPeerContentNode: ASDisplayNode, ShareContentContainer self.peerNodes = members.map { peer in let node = SelectablePeerNode() - node.setup(context: context, theme: theme, strings: strings, peer: RenderedPeer(peer: peer), synchronousLoad: false) + node.setup(context: context, theme: theme, strings: strings, peer: EngineRenderedPeer(peer: EnginePeer(peer)), synchronousLoad: false) node.theme = itemTheme return node } @@ -65,7 +65,7 @@ final class JoinLinkPreviewPeerContentNode: ASDisplayNode, ShareContentContainer let peer = TelegramGroup(id: PeerId(0), title: title, photo: image.flatMap { [$0] } ?? [], participantCount: Int(memberCount), role: .member, membership: .Left, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0) self.addSubnode(self.avatarNode) - self.avatarNode.setPeer(context: context, theme: theme, peer: peer, emptyColor: theme.list.mediaPlaceholderColor) + self.avatarNode.setPeer(context: context, theme: theme, peer: EnginePeer(peer), emptyColor: theme.list.mediaPlaceholderColor) self.addSubnode(self.titleNode) self.titleNode.attributedText = NSAttributedString(string: title, font: Font.semibold(16.0), textColor: theme.actionSheet.primaryTextColor) diff --git a/submodules/LiveLocationPositionNode/Sources/ChatMessageLiveLocationPositionNode.swift b/submodules/LiveLocationPositionNode/Sources/ChatMessageLiveLocationPositionNode.swift index 27c50023a5..45d7a5907b 100644 --- a/submodules/LiveLocationPositionNode/Sources/ChatMessageLiveLocationPositionNode.swift +++ b/submodules/LiveLocationPositionNode/Sources/ChatMessageLiveLocationPositionNode.swift @@ -3,7 +3,6 @@ import UIKit import Display import AsyncDisplayKit import TelegramCore -import Postbox import TelegramPresentationData import AvatarNode import LocationResources @@ -77,7 +76,7 @@ private func generateHeadingArrowImage() -> UIImage? { public final class ChatMessageLiveLocationPositionNode: ASDisplayNode { public enum Mode { - case liveLocation(peer: Peer, active: Bool, latitude: Double, longitude: Double, heading: Int32?) + case liveLocation(peer: EnginePeer, active: Bool, latitude: Double, longitude: Double, heading: Int32?) case location(TelegramMediaMap?) } diff --git a/submodules/LocationUI/Sources/LocationAnnotation.swift b/submodules/LocationUI/Sources/LocationAnnotation.swift index 24d2a7a949..e58361dab1 100644 --- a/submodules/LocationUI/Sources/LocationAnnotation.swift +++ b/submodules/LocationUI/Sources/LocationAnnotation.swift @@ -554,7 +554,7 @@ class LocationPinAnnotationView: MKAnnotationView { if self.previousPeerId != peer.id { self.previousPeerId = peer.id - avatarNode.setPeer(context: context, theme: theme, peer: peer) + avatarNode.setPeer(context: context, theme: theme, peer: EnginePeer(peer)) } } diff --git a/submodules/LocationUI/Sources/LocationLiveListItem.swift b/submodules/LocationUI/Sources/LocationLiveListItem.swift index f803c4cb66..e6ef55b5d8 100644 --- a/submodules/LocationUI/Sources/LocationLiveListItem.swift +++ b/submodules/LocationUI/Sources/LocationLiveListItem.swift @@ -228,7 +228,7 @@ final class LocationLiveListItemNode: ListViewItemNode { let avatarSize: CGFloat = 40.0 if let peer = item.message.author { - strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: peer, overrideImage: nil, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: false) + strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(peer), overrideImage: nil, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: false) } strongSelf.avatarNode.frame = CGRect(origin: CGPoint(x: params.leftInset + 15.0, y: floorToScreenPixels((contentSize.height - avatarSize) / 2.0)), size: CGSize(width: avatarSize, height: avatarSize)) diff --git a/submodules/PassportUI/Sources/SecureIdAuthHeaderNode.swift b/submodules/PassportUI/Sources/SecureIdAuthHeaderNode.swift index 471a914f72..9cd9360036 100644 --- a/submodules/PassportUI/Sources/SecureIdAuthHeaderNode.swift +++ b/submodules/PassportUI/Sources/SecureIdAuthHeaderNode.swift @@ -53,7 +53,7 @@ final class SecureIdAuthHeaderNode: ASDisplayNode { func updateState(formData: SecureIdEncryptedFormData?, verificationState: SecureIdAuthControllerVerificationState) { if let formData = formData { - self.serviceAvatarNode.setPeer(context: self.context, theme: self.theme, peer: formData.servicePeer) + self.serviceAvatarNode.setPeer(context: self.context, theme: self.theme, peer: EnginePeer(formData.servicePeer)) let titleData = self.strings.Passport_RequestHeader(formData.servicePeer.displayTitle(strings: self.strings, displayOrder: self.nameDisplayOrder)) let titleString = NSMutableAttributedString() diff --git a/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupActionSheetItem.swift b/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupActionSheetItem.swift index a485d192bd..10eb8591c4 100644 --- a/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupActionSheetItem.swift +++ b/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupActionSheetItem.swift @@ -65,8 +65,8 @@ private final class ChannelDiscussionGroupActionSheetItemNode: ActionSheetItemNo self.addSubnode(self.channelAvatarNode) self.addSubnode(self.textNode) - self.channelAvatarNode.setPeer(context: context, theme: (context.sharedContext.currentPresentationData.with { $0 }).theme, peer: channelPeer) - self.groupAvatarNode.setPeer(context: context, theme: (context.sharedContext.currentPresentationData.with { $0 }).theme, peer: groupPeer) + self.channelAvatarNode.setPeer(context: context, theme: (context.sharedContext.currentPresentationData.with { $0 }).theme, peer: EnginePeer(channelPeer)) + self.groupAvatarNode.setPeer(context: context, theme: (context.sharedContext.currentPresentationData.with { $0 }).theme, peer: EnginePeer(groupPeer)) let text: PresentationStrings.FormattedString if let channelPeer = channelPeer as? TelegramChannel, let addressName = channelPeer.addressName, !addressName.isEmpty { diff --git a/submodules/Postbox/Sources/Utils/Encoder/AdaptedPostboxKeyedEncodingContainer.swift b/submodules/Postbox/Sources/Utils/Encoder/AdaptedPostboxKeyedEncodingContainer.swift index 8d0401ceb1..8f6681d1ed 100644 --- a/submodules/Postbox/Sources/Utils/Encoder/AdaptedPostboxKeyedEncodingContainer.swift +++ b/submodules/Postbox/Sources/Utils/Encoder/AdaptedPostboxKeyedEncodingContainer.swift @@ -36,12 +36,16 @@ extension _AdaptedPostboxEncoder { extension _AdaptedPostboxEncoder.KeyedContainer: KeyedEncodingContainerProtocol { func encode(_ value: T, forKey key: Key) throws where T : Encodable { - let typeHash: Int32 = murMurHashString32("\(type(of: value))") - let innerEncoder = _AdaptedPostboxEncoder(typeHash: typeHash) - try! value.encode(to: innerEncoder) + if let value = value as? Data { + self.encoder.encodeData(value, forKey: key.stringValue) + } else { + let typeHash: Int32 = murMurHashString32("\(type(of: value))") + let innerEncoder = _AdaptedPostboxEncoder(typeHash: typeHash) + try! value.encode(to: innerEncoder) - let (data, valueType) = innerEncoder.makeData() - self.encoder.encodeInnerObjectData(data, valueType: valueType, forKey: key.stringValue) + let (data, valueType) = innerEncoder.makeData() + self.encoder.encodeInnerObjectData(data, valueType: valueType, forKey: key.stringValue) + } } func encodeNil(forKey key: Key) throws { diff --git a/submodules/SelectablePeerNode/Sources/SelectablePeerNode.swift b/submodules/SelectablePeerNode/Sources/SelectablePeerNode.swift index 95daf00db5..48643b1b3b 100644 --- a/submodules/SelectablePeerNode/Sources/SelectablePeerNode.swift +++ b/submodules/SelectablePeerNode/Sources/SelectablePeerNode.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import AsyncDisplayKit import Display -import Postbox import TelegramCore import SwiftSignalKit import TelegramPresentationData @@ -83,7 +82,7 @@ public final class SelectablePeerNode: ASDisplayNode { private var currentSelected = false - private var peer: RenderedPeer? + private var peer: EngineRenderedPeer? public var theme: SelectablePeerNodeTheme = SelectablePeerNodeTheme(textColor: .black, secretTextColor: .green, selectedTextColor: .blue, checkBackgroundColor: .white, checkFillColor: .blue, checkColor: .white, avatarPlaceholderColor: .white) { didSet { @@ -136,7 +135,7 @@ public final class SelectablePeerNode: ASDisplayNode { } } - public func setup(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, peer: RenderedPeer, online: Bool = false, numberOfLines: Int = 2, synchronousLoad: Bool) { + public func setup(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, peer: EngineRenderedPeer, online: Bool = false, numberOfLines: Int = 2, synchronousLoad: Bool) { let isFirstTime = self.peer == nil self.peer = peer guard let mainPeer = peer.chatMainPeer else { diff --git a/submodules/SettingsUI/Sources/Data and Storage/StorageUsageController.swift b/submodules/SettingsUI/Sources/Data and Storage/StorageUsageController.swift index 92dbf9794b..f3cdb336b6 100644 --- a/submodules/SettingsUI/Sources/Data and Storage/StorageUsageController.swift +++ b/submodules/SettingsUI/Sources/Data and Storage/StorageUsageController.swift @@ -715,7 +715,7 @@ public func storageUsageController(context: AccountContext, cacheUsagePromise: P } var items: [ActionSheetItem] = [] - items.append(DeleteChatPeerActionSheetItem(context: context, peer: peer, chatPeer: peer, action: .clearCache, strings: presentationData.strings, nameDisplayOrder: presentationData.nameDisplayOrder)) + items.append(DeleteChatPeerActionSheetItem(context: context, peer: EnginePeer(peer), chatPeer: EnginePeer(peer), action: .clearCache, strings: presentationData.strings, nameDisplayOrder: presentationData.nameDisplayOrder)) let validCategories: [PeerCacheUsageCategory] = [.image, .video, .audio, .file] diff --git a/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/ItemListWebsiteItem.swift b/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/ItemListWebsiteItem.swift index 1cb821a38b..6743534d02 100644 --- a/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/ItemListWebsiteItem.swift +++ b/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/ItemListWebsiteItem.swift @@ -270,7 +270,7 @@ class ItemListWebsiteItemNode: ItemListRevealOptionsItemNode { } if let peer = item.peer { - strongSelf.avatarNode.setPeer(context: item.context, theme: item.theme, peer: peer, authorOfMessage: nil, overrideImage: nil, emptyColor: nil, clipStyle: .none, synchronousLoad: false) + strongSelf.avatarNode.setPeer(context: item.context, theme: item.theme, peer: EnginePeer(peer), authorOfMessage: nil, overrideImage: nil, emptyColor: nil, clipStyle: .none, synchronousLoad: false) } let revealOffset = strongSelf.revealOffset diff --git a/submodules/SettingsUI/Sources/TabBarAccountSwitchControllerNode.swift b/submodules/SettingsUI/Sources/TabBarAccountSwitchControllerNode.swift index e5583881d4..4c12bdf00c 100644 --- a/submodules/SettingsUI/Sources/TabBarAccountSwitchControllerNode.swift +++ b/submodules/SettingsUI/Sources/TabBarAccountSwitchControllerNode.swift @@ -189,7 +189,7 @@ private final class SwitchAccountItemNode: ASDisplayNode, AbstractSwitchAccountI return (titleSize.width + leftInset + rightInset, height, { width in let avatarSize = CGSize(width: 30.0, height: 30.0) self.avatarNode.frame = CGRect(origin: CGPoint(x: floor((leftInset - avatarSize.width) / 2.0), y: floor((height - avatarSize.height) / 2.0)), size: avatarSize) - self.avatarNode.setPeer(context: self.context, theme: self.presentationData.theme, peer: self.peer) + self.avatarNode.setPeer(context: self.context, theme: self.presentationData.theme, peer: EnginePeer(self.peer)) self.titleNode.frame = CGRect(origin: CGPoint(x: leftInset, y: floor((height - titleSize.height) / 2.0)), size: titleSize) diff --git a/submodules/ShareController/Sources/ShareController.swift b/submodules/ShareController/Sources/ShareController.swift index d836ddb15c..2cbd9e67f7 100644 --- a/submodules/ShareController/Sources/ShareController.swift +++ b/submodules/ShareController/Sources/ShareController.swift @@ -803,7 +803,7 @@ public final class ShareController: ViewController { } var items: [ActionSheetItem] = [] for info in strongSelf.switchableAccounts { - items.append(ActionSheetPeerItem(context: strongSelf.sharedContext.makeTempAccountContext(account: info.account), peer: info.peer, title: info.peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), isSelected: info.account.id == strongSelf.currentAccount.id, strings: presentationData.strings, theme: presentationData.theme, action: { [weak self] in + items.append(ActionSheetPeerItem(context: strongSelf.sharedContext.makeTempAccountContext(account: info.account), peer: EnginePeer(info.peer), title: info.peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), isSelected: info.account.id == strongSelf.currentAccount.id, strings: presentationData.strings, theme: presentationData.theme, action: { [weak self] in dismissAction() self?.switchToAccount(account: info.account, animateIn: true) })) diff --git a/submodules/ShareController/Sources/ShareControllerPeerGridItem.swift b/submodules/ShareController/Sources/ShareControllerPeerGridItem.swift index 09636a9dc6..f531a0330f 100644 --- a/submodules/ShareController/Sources/ShareControllerPeerGridItem.swift +++ b/submodules/ShareController/Sources/ShareControllerPeerGridItem.swift @@ -173,7 +173,7 @@ final class ShareControllerPeerGridItemNode: GridItemNode { } self.peerNode.theme = itemTheme - self.peerNode.setup(context: context, theme: theme, strings: strings, peer: peer, online: online, synchronousLoad: synchronousLoad) + self.peerNode.setup(context: context, theme: theme, strings: strings, peer: EngineRenderedPeer(peer), online: online, synchronousLoad: synchronousLoad) self.currentState = (context, theme, strings, peer, search, presence) self.setNeedsLayout() if let presence = presence as? TelegramUserPresence { diff --git a/submodules/ShareController/Sources/SharePeersContainerNode.swift b/submodules/ShareController/Sources/SharePeersContainerNode.swift index 8811f62f31..1fefaac8f0 100644 --- a/submodules/ShareController/Sources/SharePeersContainerNode.swift +++ b/submodules/ShareController/Sources/SharePeersContainerNode.swift @@ -172,7 +172,7 @@ final class SharePeersContainerNode: ASDisplayNode, ShareContentContainerNode { var hasOtherAccounts = false if switchableAccounts.count > 1, let info = switchableAccounts.first(where: { $0.account.id == context.account.id }) { hasOtherAccounts = true - self.contentTitleAccountNode.setPeer(context: context, theme: theme, peer: info.peer, emptyColor: nil, synchronousLoad: false) + self.contentTitleAccountNode.setPeer(context: context, theme: theme, peer: EnginePeer(info.peer), emptyColor: nil, synchronousLoad: false) } else { self.contentTitleAccountNode.isHidden = true } diff --git a/submodules/TelegramBaseController/Sources/LocationBroadcastActionSheetItem.swift b/submodules/TelegramBaseController/Sources/LocationBroadcastActionSheetItem.swift index 054ab6a489..ab090a4db7 100644 --- a/submodules/TelegramBaseController/Sources/LocationBroadcastActionSheetItem.swift +++ b/submodules/TelegramBaseController/Sources/LocationBroadcastActionSheetItem.swift @@ -105,7 +105,7 @@ public class LocationBroadcastActionSheetItemNode: ActionSheetItemNode { let textColor: UIColor = self.theme.primaryTextColor self.label.attributedText = NSAttributedString(string: item.title, font: defaultFont, textColor: textColor) - self.avatarNode.setPeer(context: item.context, theme: (item.context.sharedContext.currentPresentationData.with { $0 }).theme, peer: item.peer) + self.avatarNode.setPeer(context: item.context, theme: (item.context.sharedContext.currentPresentationData.with { $0 }).theme, peer: EnginePeer(item.peer)) self.timerNode.update(backgroundColor: self.theme.controlAccentColor.withAlphaComponent(0.4), foregroundColor: self.theme.controlAccentColor, textColor: self.theme.controlAccentColor, beginTimestamp: item.beginTimestamp, timeout: item.timeout, strings: item.strings) } diff --git a/submodules/TelegramBaseController/Sources/TelegramBaseController.swift b/submodules/TelegramBaseController/Sources/TelegramBaseController.swift index a48571c327..c781285b0b 100644 --- a/submodules/TelegramBaseController/Sources/TelegramBaseController.swift +++ b/submodules/TelegramBaseController/Sources/TelegramBaseController.swift @@ -288,7 +288,7 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder { let disposable = MetaDisposable() callContextCache.impl.syncWith { impl in - let callContext = impl.get(account: context.account, engine: context.engine, peerId: peerId, call: activeCall) + let callContext = impl.get(account: context.account, engine: context.engine, peerId: peerId, call: EngineGroupCallDescription(activeCall)) disposable.set((callContext.context.panelData |> deliverOnMainQueue).start(next: { panelData in callContext.keep() @@ -405,7 +405,7 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder { strongSelf.joinGroupCall( peerId: groupCallPanelData.peerId, invite: nil, - activeCall: CachedChannelData.ActiveCall(id: groupCallPanelData.info.id, accessHash: groupCallPanelData.info.accessHash, title: groupCallPanelData.info.title, scheduleTimestamp: groupCallPanelData.info.scheduleTimestamp, subscribedToScheduled: groupCallPanelData.info.subscribedToScheduled) + activeCall: EngineGroupCallDescription(id: groupCallPanelData.info.id, accessHash: groupCallPanelData.info.accessHash, title: groupCallPanelData.info.title, scheduleTimestamp: groupCallPanelData.info.scheduleTimestamp, subscribedToScheduled: groupCallPanelData.info.subscribedToScheduled) ) }) self.navigationBar?.additionalContentNode.addSubnode(groupCallAccessoryPanel) @@ -847,7 +847,7 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder { })] } - open func joinGroupCall(peerId: PeerId, invite: String?, activeCall: CachedChannelData.ActiveCall) { + open func joinGroupCall(peerId: PeerId, invite: String?, activeCall: EngineGroupCallDescription) { let context = self.context let presentationData = self.context.sharedContext.currentPresentationData.with { $0 } diff --git a/submodules/TelegramCallsUI/Sources/GroupCallNavigationAccessoryPanel.swift b/submodules/TelegramCallsUI/Sources/GroupCallNavigationAccessoryPanel.swift index d5b992caed..91736b1655 100644 --- a/submodules/TelegramCallsUI/Sources/GroupCallNavigationAccessoryPanel.swift +++ b/submodules/TelegramCallsUI/Sources/GroupCallNavigationAccessoryPanel.swift @@ -357,7 +357,7 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode { } self.currentText = membersText - self.avatarsContent = self.avatarsContext.update(peers: data.topParticipants.map { $0.peer }, animated: false) + self.avatarsContent = self.avatarsContext.update(peers: data.topParticipants.map { EnginePeer($0.peer) }, animated: false) self.textNode.attributedText = NSAttributedString(string: membersText, font: Font.regular(13.0), textColor: self.theme.chat.inputPanel.secondaryTextColor) @@ -381,7 +381,7 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode { } strongSelf.currentText = membersText - strongSelf.avatarsContent = strongSelf.avatarsContext.update(peers: summaryState.topParticipants.map { $0.peer }, animated: false) + strongSelf.avatarsContent = strongSelf.avatarsContext.update(peers: summaryState.topParticipants.map { EnginePeer($0.peer) }, animated: false) if let (size, leftInset, rightInset) = strongSelf.validLayout { strongSelf.updateLayout(size: size, leftInset: leftInset, rightInset: rightInset, transition: .immediate) @@ -458,7 +458,7 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode { } self.currentText = membersText - self.avatarsContent = self.avatarsContext.update(peers: data.topParticipants.map { $0.peer }, animated: false) + self.avatarsContent = self.avatarsContext.update(peers: data.topParticipants.map { EnginePeer($0.peer) }, animated: false) updateAudioLevels = true } diff --git a/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift b/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift index 9f3c755c01..67753fd72e 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift @@ -728,7 +728,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager { return .success } - public func joinGroupCall(context: AccountContext, peerId: PeerId, invite: String?, requestJoinAsPeerId: ((@escaping (PeerId?) -> Void) -> Void)?, initialCall: CachedChannelData.ActiveCall, endCurrentIfAny: Bool) -> JoinGroupCallManagerResult { + public func joinGroupCall(context: AccountContext, peerId: PeerId, invite: String?, requestJoinAsPeerId: ((@escaping (PeerId?) -> Void) -> Void)?, initialCall: EngineGroupCallDescription, endCurrentIfAny: Bool) -> JoinGroupCallManagerResult { let begin: () -> Void = { [weak self] in if let requestJoinAsPeerId = requestJoinAsPeerId { requestJoinAsPeerId({ joinAsPeerId in @@ -772,7 +772,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager { peerId: PeerId, invite: String?, joinAsPeerId: PeerId?, - initialCall: CachedChannelData.ActiveCall, + initialCall: EngineGroupCallDescription, internalId: CallSessionInternalId = CallSessionInternalId() ) -> Signal { let (presentationData, present, openSettings) = self.getDeviceAccessData() diff --git a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift index 7eb23db7d5..e28ca36679 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift @@ -91,7 +91,7 @@ public final class AccountGroupCallContextImpl: AccountGroupCallContext { return self.panelDataPromise.get() } - public init(account: Account, engine: TelegramEngine, peerId: PeerId, call: CachedChannelData.ActiveCall) { + public init(account: Account, engine: TelegramEngine, peerId: PeerId, call: EngineGroupCallDescription) { self.panelDataPromise.set(.single(GroupCallPanelData( peerId: peerId, info: GroupCallInfo( @@ -183,7 +183,7 @@ public final class AccountGroupCallContextCacheImpl: AccountGroupCallContextCach self.queue = queue } - public func get(account: Account, engine: TelegramEngine, peerId: PeerId, call: CachedChannelData.ActiveCall) -> AccountGroupCallContextImpl.Proxy { + public func get(account: Account, engine: TelegramEngine, peerId: PeerId, call: EngineGroupCallDescription) -> AccountGroupCallContextImpl.Proxy { let result: Record if let current = self.contexts[call.id] { result = current @@ -382,7 +382,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { private let getDeviceAccessData: () -> (presentationData: PresentationData, present: (ViewController, Any?) -> Void, openSettings: () -> Void) - private var initialCall: CachedChannelData.ActiveCall? + private var initialCall: EngineGroupCallDescription? public let internalId: CallSessionInternalId public let peerId: PeerId private var invite: String? @@ -621,7 +621,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { audioSession: ManagedAudioSession, callKitIntegration: CallKitIntegration?, getDeviceAccessData: @escaping () -> (presentationData: PresentationData, present: (ViewController, Any?) -> Void, openSettings: () -> Void), - initialCall: CachedChannelData.ActiveCall?, + initialCall: EngineGroupCallDescription?, internalId: CallSessionInternalId, peerId: PeerId, invite: String?, @@ -822,7 +822,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { }) if let initialCall = initialCall, let temporaryParticipantsContext = (self.accountContext.cachedGroupCallContexts as? AccountGroupCallContextCacheImpl)?.impl.syncWith({ impl in - impl.get(account: accountContext.account, engine: accountContext.engine, peerId: peerId, call: CachedChannelData.ActiveCall(id: initialCall.id, accessHash: initialCall.accessHash, title: initialCall.title, scheduleTimestamp: initialCall.scheduleTimestamp, subscribedToScheduled: initialCall.subscribedToScheduled)) + impl.get(account: accountContext.account, engine: accountContext.engine, peerId: peerId, call: EngineGroupCallDescription(id: initialCall.id, accessHash: initialCall.accessHash, title: initialCall.title, scheduleTimestamp: initialCall.scheduleTimestamp, subscribedToScheduled: initialCall.subscribedToScheduled)) }) { self.switchToTemporaryParticipantsContext(sourceContext: temporaryParticipantsContext.context.participantsContext, oldMyPeerId: self.joinAsPeerId) } else { @@ -2937,7 +2937,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { } if let value = value { - strongSelf.initialCall = CachedChannelData.ActiveCall(id: value.id, accessHash: value.accessHash, title: value.title, scheduleTimestamp: nil, subscribedToScheduled: false) + strongSelf.initialCall = EngineGroupCallDescription(id: value.id, accessHash: value.accessHash, title: value.title, scheduleTimestamp: nil, subscribedToScheduled: false) strongSelf.updateSessionState(internalState: .active(value), audioSessionControl: strongSelf.audioSessionControl) } else { diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift index c8cd1f27a2..a999734b3a 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift @@ -1684,7 +1684,7 @@ public final class VoiceChatController: ViewController { let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData.withUpdated(theme: strongSelf.darkTheme)) var items: [ActionSheetItem] = [] - items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: peer, chatPeer: chatPeer, action: .removeFromGroup, strings: strongSelf.presentationData.strings, nameDisplayOrder: strongSelf.presentationData.nameDisplayOrder)) + items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: EnginePeer(peer), chatPeer: EnginePeer(chatPeer), action: .removeFromGroup, strings: strongSelf.presentationData.strings, nameDisplayOrder: strongSelf.presentationData.nameDisplayOrder)) items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.VoiceChat_RemovePeerRemove, color: .destructive, action: { [weak actionSheet] in actionSheet?.dismissAnimated() diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatFullscreenParticipantItem.swift b/submodules/TelegramCallsUI/Sources/VoiceChatFullscreenParticipantItem.swift index f2660a3469..b96df15fc4 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatFullscreenParticipantItem.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatFullscreenParticipantItem.swift @@ -752,7 +752,7 @@ class VoiceChatFullscreenParticipantItemNode: ItemListRevealOptionsItemNode { if item.peer.isDeleted { overrideImage = .deletedIcon } - strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: item.peer, overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad, storeUnrounded: true) + strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(item.peer), overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad, storeUnrounded: true) var hadMicrophoneNode = false var hadRaiseHandNode = false diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatHeaderButton.swift b/submodules/TelegramCallsUI/Sources/VoiceChatHeaderButton.swift index 92b9af8cb2..0e3b0a0126 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatHeaderButton.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatHeaderButton.swift @@ -3,6 +3,7 @@ import UIKit import AsyncDisplayKit import Display import Postbox +import TelegramCore import AccountContext import TelegramPresentationData import AvatarNode @@ -156,7 +157,7 @@ final class VoiceChatHeaderButton: HighlightableButtonNode { self.iconNode.isHidden = false self.avatarNode.isHidden = true case let .avatar(peer): - self.avatarNode.setPeer(context: self.context, theme: self.theme, peer: peer) + self.avatarNode.setPeer(context: self.context, theme: self.theme, peer: EnginePeer(peer)) self.iconNode.isHidden = true self.avatarNode.isHidden = false self.animationNode?.isHidden = true @@ -174,7 +175,7 @@ final class VoiceChatHeaderButton: HighlightableButtonNode { self.iconNode.isHidden = false self.avatarNode.isHidden = true case let .avatar(peer): - self.avatarNode.setPeer(context: self.context, theme: self.theme, peer: peer) + self.avatarNode.setPeer(context: self.context, theme: self.theme, peer: EnginePeer(peer)) self.iconNode.isHidden = true self.avatarNode.isHidden = false self.animationNode?.isHidden = true diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatJoinScreen.swift b/submodules/TelegramCallsUI/Sources/VoiceChatJoinScreen.swift index 19adc39f85..81195fa8fa 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatJoinScreen.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatJoinScreen.swift @@ -669,7 +669,7 @@ final class VoiceChatPreviewContentNode: ASDisplayNode, ShareContentContainerNod super.init() self.addSubnode(self.avatarNode) - self.avatarNode.setPeer(context: context, theme: theme, peer: peer, emptyColor: theme.list.mediaPlaceholderColor) + self.avatarNode.setPeer(context: context, theme: theme, peer: EnginePeer(peer), emptyColor: theme.list.mediaPlaceholderColor) self.addSubnode(self.titleNode) self.titleNode.attributedText = NSAttributedString(string: title ?? peer.displayTitle(strings: strings, displayOrder: displayOrder), font: Font.semibold(16.0), textColor: theme.actionSheet.primaryTextColor) diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatMainStageNode.swift b/submodules/TelegramCallsUI/Sources/VoiceChatMainStageNode.swift index 034b309ccd..2997398e51 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatMainStageNode.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatMainStageNode.swift @@ -637,7 +637,7 @@ final class VoiceChatMainStageNode: ASDisplayNode { } let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 } - strongSelf.speakingAvatarNode.setPeer(context: strongSelf.context, theme: presentationData.theme, peer: peer) + strongSelf.speakingAvatarNode.setPeer(context: strongSelf.context, theme: presentationData.theme, peer: EnginePeer(peer)) let bodyAttributes = MarkdownAttributeSet(font: Font.regular(15.0), textColor: .white, additionalAttributes: [:]) let boldAttributes = MarkdownAttributeSet(font: Font.semibold(15.0), textColor: .white, additionalAttributes: [:]) diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatParticipantItem.swift b/submodules/TelegramCallsUI/Sources/VoiceChatParticipantItem.swift index 9bf559bcea..49c138b9d2 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatParticipantItem.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatParticipantItem.swift @@ -1105,7 +1105,7 @@ class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode { if item.peer.isDeleted { overrideImage = .deletedIcon } - strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: item.peer, overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad, storeUnrounded: true) + strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(item.peer), overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad, storeUnrounded: true) strongSelf.highlightContainerNode.frame = CGRect(origin: CGPoint(x: params.leftInset, y: -UIScreenPixel), size: CGSize(width: params.width - params.leftInset - params.rightInset, height: layout.contentSize.height + UIScreenPixel + UIScreenPixel + 11.0)) diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatPeerActionSheetItem.swift b/submodules/TelegramCallsUI/Sources/VoiceChatPeerActionSheetItem.swift index 12419fd9fa..bd1eb8bb1f 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatPeerActionSheetItem.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatPeerActionSheetItem.swift @@ -120,7 +120,7 @@ public class VoiceChatPeerActionSheetItemNode: ActionSheetItemNode { self.subtitleNode.attributedText = NSAttributedString(string: item.subtitle, font: subtitleFont, textColor: self.theme.secondaryTextColor) let theme = item.context.sharedContext.currentPresentationData.with { $0 }.theme - self.avatarNode.setPeer(context: item.context, theme: theme, peer: item.peer) + self.avatarNode.setPeer(context: item.context, theme: theme, peer: EnginePeer(item.peer)) self.accessibilityArea.accessibilityTraits = [.button] self.accessibilityArea.accessibilityLabel = item.title diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Calls/TelegramEngineCalls.swift b/submodules/TelegramCore/Sources/TelegramEngine/Calls/TelegramEngineCalls.swift index 21be454285..7e734808ab 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Calls/TelegramEngineCalls.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Calls/TelegramEngineCalls.swift @@ -89,8 +89,11 @@ public extension TelegramEngine { return _internal_cachedGroupCallDisplayAsAvailablePeers(account: self.account, peerId: peerId) } - public func updatedCurrentPeerGroupCall(peerId: PeerId) -> Signal { + public func updatedCurrentPeerGroupCall(peerId: PeerId) -> Signal { return _internal_updatedCurrentPeerGroupCall(account: self.account, peerId: peerId) + |> map { activeCall -> EngineGroupCallDescription? in + return activeCall.flatMap(EngineGroupCallDescription.init) + } } public func getAudioBroadcastDataSource(callId: Int64, accessHash: Int64) -> Signal { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Data/PeerSummary.swift b/submodules/TelegramCore/Sources/TelegramEngine/Data/PeerSummary.swift index c8135eb9c5..57efef204b 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Data/PeerSummary.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Data/PeerSummary.swift @@ -57,5 +57,36 @@ public extension TelegramEngine.EngineData.Item { } } } + + public struct GroupCallDescription: TelegramEngineDataItem, PostboxViewDataItem { + public typealias Result = Optional + + fileprivate var id: EnginePeer.Id + + public init(id: EnginePeer.Id) { + self.id = id + } + + var key: PostboxViewKey { + return .cachedPeerData(peerId: self.id) + } + + func extract(view: PostboxView) -> Result { + guard let view = view as? CachedPeerDataView else { + preconditionFailure() + } + guard let cachedPeerData = view.cachedPeerData else { + return nil + } + switch cachedPeerData { + case let channel as CachedChannelData: + return channel.activeCall.flatMap(EngineGroupCallDescription.init) + case let group as CachedGroupData: + return group.activeCall.flatMap(EngineGroupCallDescription.init) + default: + return nil + } + } + } } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Data/TelegramEngineData.swift b/submodules/TelegramCore/Sources/TelegramEngine/Data/TelegramEngineData.swift index 25c8e66626..f28ae11346 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Data/TelegramEngineData.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Data/TelegramEngineData.swift @@ -33,7 +33,7 @@ public extension TelegramEngine { } private func _subscribe(items: [AnyPostboxViewDataItem]) -> Signal<[Any], NoError> { - return self.account.postbox.combinedView(keys: items.map(\.key)) + return self.account.postbox.combinedView(keys: Array(Set(items.map(\.key)))) |> map { views -> [Any] in var results: [Any] = [] diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/CallList.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/CallList.swift new file mode 100644 index 0000000000..21c66527e5 --- /dev/null +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/CallList.swift @@ -0,0 +1,27 @@ +import Postbox + +public final class EngineCallList { + public enum Scope { + case all + case missed + } + + public enum Item { + case message(message: EngineMessage, group: [EngineMessage]) + case hole(EngineMessage.Index) + } + + public let items: [Item] + public let hasEarlier: Bool + public let hasLater: Bool + + init( + items: [Item], + hasEarlier: Bool, + hasLater: Bool + ) { + self.items = items + self.hasEarlier = hasEarlier + self.hasLater = hasLater + } +} diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/ChatList.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/ChatList.swift new file mode 100644 index 0000000000..bf2a88a5e6 --- /dev/null +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/ChatList.swift @@ -0,0 +1,163 @@ +import Postbox + +public final class EngineChatList { + public enum Group { + case root + case archive + } + + public final class Item { + public typealias Index = ChatListIndex + + public let index: Index + public let messages: [EngineMessage] + public let readState: EngineReadState? + public let isMuted: Bool + public let draftText: String? + public let renderedPeer: EngineRenderedPeer + public let presence: EnginePeer.Presence? + public let hasUnseenMentions: Bool + public let hasFailed: Bool + public let isContact: Bool + + public init( + index: Index, + messages: [EngineMessage], + readState: EngineReadState?, + isMuted: Bool, + draftText: String?, + renderedPeer: EngineRenderedPeer, + presence: EnginePeer.Presence?, + hasUnseenMentions: Bool, + hasFailed: Bool, + isContact: Bool + ) { + self.index = index + self.messages = messages + self.readState = readState + self.isMuted = isMuted + self.draftText = draftText + self.renderedPeer = renderedPeer + self.presence = presence + self.hasUnseenMentions = hasUnseenMentions + self.hasFailed = hasFailed + self.isContact = isContact + } + } + + public final class GroupItem { + public final class Item { + public let peer: EngineRenderedPeer + public let isUnread: Bool + + public init(peer: EngineRenderedPeer, isUnread: Bool) { + self.peer = peer + self.isUnread = isUnread + } + } + + public let id: Group + public let topMessage: EngineMessage? + public let items: [Item] + public let unreadCount: Int + + public init( + id: Group, + topMessage: EngineMessage?, + items: [Item], + unreadCount: Int + ) { + self.id = id + self.topMessage = topMessage + self.items = items + self.unreadCount = unreadCount + } + } + + public let items: [Item] + public let groupItems: [GroupItem] + public let hasEarlier: Bool + public let hasLater: Bool + + init( + items: [Item], + groupItems: [GroupItem], + hasEarlier: Bool, + hasLater: Bool + ) { + self.items = items + self.groupItems = groupItems + self.hasEarlier = hasEarlier + self.hasLater = hasLater + } +} + +public extension EngineChatList.Group { + init(_ group: PeerGroupId) { + switch group { + case .root: + self = .root + case let .group(value): + assert(value == Namespaces.PeerGroup.archive.rawValue) + self = .archive + } + } + + func _asGroup() -> PeerGroupId { + switch self { + case .root: + return .root + case .archive: + return Namespaces.PeerGroup.archive + } + } +} + +extension EngineChatList.Item { + convenience init?(_ entry: ChatListEntry) { + switch entry { + case let .MessageEntry(index, messages, readState, isRemovedFromTotalUnreadCount, embeddedInterfaceState, renderedPeer, presence, summaryInfo, hasFailed, isContact): + self.init( + index: index, + messages: messages.map(EngineMessage.init), + readState: readState.flatMap(EngineReadState.init), + isMuted: isRemovedFromTotalUnreadCount, + draftText: nil, + renderedPeer: EngineRenderedPeer(renderedPeer), + presence: presence.flatMap(EnginePeer.Presence.init), + hasUnseenMentions: (summaryInfo.tagSummaryCount ?? 0) > (summaryInfo.actionsSummaryCount ?? 0), + hasFailed: hasFailed, + isContact: isContact + ) + case .HoleEntry: + return nil + } + } +} + +extension EngineChatList.GroupItem { + convenience init(_ entry: ChatListGroupReferenceEntry) { + self.init( + id: EngineChatList.Group(entry.groupId), + topMessage: entry.message.flatMap(EngineMessage.init), + items: entry.renderedPeers.map { peer in + return EngineChatList.GroupItem.Item( + peer: EngineRenderedPeer(peer.peer), + isUnread: peer.isUnread + ) + }, + unreadCount: Int(entry.unreadState.count(countingCategory: .chats, mutedCategory: .all)) + ) + } +} + +extension EngineChatList { + convenience init(_ view: ChatListView) { + self.init( + items: view.entries.compactMap(EngineChatList.Item.init), + groupItems: view.groupEntries.map(EngineChatList.GroupItem.init), + hasEarlier: view.earlierIndex != nil, + hasLater: view.laterIndex != nil + ) + } +} diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/EngineGroupCallDescription.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/EngineGroupCallDescription.swift new file mode 100644 index 0000000000..a4685f9193 --- /dev/null +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/EngineGroupCallDescription.swift @@ -0,0 +1,35 @@ +import Postbox + +public final class EngineGroupCallDescription { + public let id: Int64 + public let accessHash: Int64 + public let title: String? + public let scheduleTimestamp: Int32? + public let subscribedToScheduled: Bool + + public init( + id: Int64, + accessHash: Int64, + title: String?, + scheduleTimestamp: Int32?, + subscribedToScheduled: Bool + ) { + self.id = id + self.accessHash = accessHash + self.title = title + self.scheduleTimestamp = scheduleTimestamp + self.subscribedToScheduled = subscribedToScheduled + } +} + +public extension EngineGroupCallDescription { + convenience init(_ activeCall: CachedChannelData.ActiveCall) { + self.init( + id: activeCall.id, + accessHash: activeCall.accessHash, + title: activeCall.title, + scheduleTimestamp: activeCall.scheduleTimestamp, + subscribedToScheduled: activeCall.subscribedToScheduled + ) + } +} diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/ReadState.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/ReadState.swift new file mode 100644 index 0000000000..d499b6071b --- /dev/null +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/ReadState.swift @@ -0,0 +1,23 @@ +import Postbox + +public struct EngineReadState: Equatable { + public var unreadCount: Int + public var isMarkedAsUnread: Bool + + public init(unreadCount: Int, isMarkedAsUnread: Bool) { + self.unreadCount = unreadCount + self.isMarkedAsUnread = isMarkedAsUnread + } +} + +public extension EngineReadState { + var isUnread: Bool { + return self.unreadCount != 0 || self.isMarkedAsUnread + } +} + +public extension EngineReadState { + init(_ readState: CombinedPeerReadState) { + self.init(unreadCount: Int(readState.count), isMarkedAsUnread: readState.markedUnread) + } +} diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift index db4844b206..6cda567415 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift @@ -170,5 +170,34 @@ public extension TelegramEngine { public func topPeerActiveLiveLocationMessages(peerId: PeerId) -> Signal<(Peer?, [Message]), NoError> { return _internal_topPeerActiveLiveLocationMessages(viewTracker: self.account.viewTracker, accountPeerId: self.account.peerId, peerId: peerId) } + + public func chatList(group: EngineChatList.Group, count: Int) -> Signal { + return self.account.postbox.tailChatListView(groupId: group._asGroup(), count: count, summaryComponents: ChatListEntrySummaryComponents()) + |> map { view -> EngineChatList in + return EngineChatList(view.0) + } + } + + public func callList(scope: EngineCallList.Scope, index: EngineMessage.Index, itemCount: Int) -> Signal { + return self.account.viewTracker.callListView( + type: scope == .all ? .all : .missed, + index: index, + count: itemCount + ) + |> map { view -> EngineCallList in + return EngineCallList( + items: view.entries.map { entry -> EngineCallList.Item in + switch entry { + case let .message(message, group): + return .message(message: EngineMessage(message), group: group.map(EngineMessage.init)) + case let .hole(index): + return .hole(index) + } + }, + hasEarlier: view.earlier != nil, + hasLater: view.later != nil + ) + } + } } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift index 359e5c1c64..155f60a7bd 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift @@ -3,6 +3,24 @@ import Postbox public enum EnginePeer: Equatable { public typealias Id = PeerId + public struct Presence: Equatable { + public enum Status: Equatable { + case present(until: Int32) + case recently + case lastWeek + case lastMonth + case longTimeAgo + } + + public var status: Status + public var lastActivity: Int32 + + public init(status: Status, lastActivity: Int32) { + self.status = status + self.lastActivity = lastActivity + } + } + case user(TelegramUser) case legacyGroup(TelegramGroup) case channel(TelegramChannel) @@ -38,6 +56,30 @@ public enum EnginePeer: Equatable { } } +public extension EnginePeer.Presence { + init(_ presence: PeerPresence) { + if let presence = presence as? TelegramUserPresence { + let mappedStatus: Status + switch presence.status { + case .none: + mappedStatus = .longTimeAgo + case let .present(until): + mappedStatus = .present(until: until) + case .recently: + mappedStatus = .recently + case .lastWeek: + mappedStatus = .lastWeek + case .lastMonth: + mappedStatus = .lastMonth + } + + self.init(status: mappedStatus, lastActivity: presence.lastActivity) + } else { + preconditionFailure() + } + } +} + public extension EnginePeer { var id: Id { return self._asPeer().id @@ -50,6 +92,46 @@ public extension EnginePeer { var indexName: PeerIndexNameRepresentation { return self._asPeer().indexName } + + var debugDisplayTitle: String { + return self._asPeer().debugDisplayTitle + } + + func restrictionText(platform: String, contentSettings: ContentSettings) -> String? { + return self._asPeer().restrictionText(platform: platform, contentSettings: contentSettings) + } + + var displayLetters: [String] { + return self._asPeer().displayLetters + } + + var profileImageRepresentations: [TelegramMediaImageRepresentation] { + return self._asPeer().profileImageRepresentations + } + + var smallProfileImage: TelegramMediaImageRepresentation? { + return self._asPeer().smallProfileImage + } + + var largeProfileImage: TelegramMediaImageRepresentation? { + return self._asPeer().largeProfileImage + } + + var isDeleted: Bool { + return self._asPeer().isDeleted + } + + var isScam: Bool { + return self._asPeer().isScam + } + + var isFake: Bool { + return self._asPeer().isFake + } + + var isVerified: Bool { + return self._asPeer().isVerified + } } public extension EnginePeer { @@ -81,3 +163,54 @@ public extension EnginePeer { } } } + +public final class EngineRenderedPeer { + public let peerId: EnginePeer.Id + public let peers: [EnginePeer.Id: EnginePeer] + + public init(peerId: EnginePeer.Id, peers: [EnginePeer.Id: EnginePeer]) { + self.peerId = peerId + self.peers = peers + } + + public init(peer: EnginePeer) { + self.peerId = peer.id + self.peers = [peer.id: peer] + } + + public static func ==(lhs: EngineRenderedPeer, rhs: EngineRenderedPeer) -> Bool { + if lhs.peerId != rhs.peerId { + return false + } + if lhs.peers != rhs.peers { + return false + } + return true + } + + public var peer: EnginePeer? { + return self.peers[self.peerId] + } + + public var chatMainPeer: EnginePeer? { + if let peer = self.peers[self.peerId] { + if case let .secretChat(secretChat) = peer { + return self.peers[secretChat.regularPeerId] + } else { + return peer + } + } else { + return nil + } + } +} + +public extension EngineRenderedPeer { + convenience init(_ renderedPeer: RenderedPeer) { + var mappedPeers: [EnginePeer.Id: EnginePeer] = [:] + for (id, peer) in renderedPeer.peers { + mappedPeers[id] = EnginePeer(peer) + } + self.init(peerId: renderedPeer.peerId, peers: mappedPeers) + } +} diff --git a/submodules/TelegramUI/Sources/AccountContext.swift b/submodules/TelegramUI/Sources/AccountContext.swift index b2d11f4816..30015f24d7 100644 --- a/submodules/TelegramUI/Sources/AccountContext.swift +++ b/submodules/TelegramUI/Sources/AccountContext.swift @@ -305,7 +305,7 @@ public final class AccountContextImpl: AccountContext { let _ = self.sharedContext.callManager?.scheduleGroupCall(context: self, peerId: peerId, endCurrentIfAny: true) } - public func joinGroupCall(peerId: PeerId, invite: String?, requestJoinAsPeerId: ((@escaping (PeerId?) -> Void) -> Void)?, activeCall: CachedChannelData.ActiveCall) { + public func joinGroupCall(peerId: PeerId, invite: String?, requestJoinAsPeerId: ((@escaping (PeerId?) -> Void) -> Void)?, activeCall: EngineGroupCallDescription) { let callResult = self.sharedContext.callManager?.joinGroupCall(context: self, peerId: peerId, invite: invite, requestJoinAsPeerId: requestJoinAsPeerId, initialCall: activeCall, endCurrentIfAny: false) if let callResult = callResult, case let .alreadyInProgress(currentPeerId) = callResult { if currentPeerId == peerId { diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index ba20f43c1c..dc6a8a3c33 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -593,7 +593,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } case .groupPhoneCall, .inviteToGroupPhoneCall: if let activeCall = strongSelf.presentationInterfaceState.activeGroupCallInfo?.activeCall { - strongSelf.joinGroupCall(peerId: message.id.peerId, invite: nil, activeCall: CachedChannelData.ActiveCall(id: activeCall.id, accessHash: activeCall.accessHash, title: activeCall.title, scheduleTimestamp: activeCall.scheduleTimestamp, subscribedToScheduled: activeCall.subscribedToScheduled)) + strongSelf.joinGroupCall(peerId: message.id.peerId, invite: nil, activeCall: EngineGroupCallDescription(id: activeCall.id, accessHash: activeCall.accessHash, title: activeCall.title, scheduleTimestamp: activeCall.scheduleTimestamp, subscribedToScheduled: activeCall.subscribedToScheduled)) } else { var canManageGroupCalls = false if let channel = strongSelf.presentationInterfaceState.renderedPeer?.chatMainPeer as? TelegramChannel { @@ -627,7 +627,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G guard let strongSelf = self else { return } - strongSelf.joinGroupCall(peerId: message.id.peerId, invite: nil, activeCall: CachedChannelData.ActiveCall(id: info.id, accessHash: info.accessHash, title: info.title, scheduleTimestamp: info.scheduleTimestamp, subscribedToScheduled: info.subscribedToScheduled)) + strongSelf.joinGroupCall(peerId: message.id.peerId, invite: nil, activeCall: EngineGroupCallDescription(id: info.id, accessHash: info.accessHash, title: info.title, scheduleTimestamp: info.scheduleTimestamp, subscribedToScheduled: info.subscribedToScheduled)) }, error: { [weak self] error in dismissStatus?() @@ -3062,7 +3062,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } else { imageOverride = nil } - (strongSelf.chatInfoNavigationButton?.buttonItem.customDisplayNode as? ChatAvatarNavigationNode)?.avatarNode.setPeer(context: strongSelf.context, theme: strongSelf.presentationData.theme, peer: peer, overrideImage: imageOverride) + (strongSelf.chatInfoNavigationButton?.buttonItem.customDisplayNode as? ChatAvatarNavigationNode)?.avatarNode.setPeer(context: strongSelf.context, theme: strongSelf.presentationData.theme, peer: EnginePeer(peer), overrideImage: imageOverride) (strongSelf.chatInfoNavigationButton?.buttonItem.customDisplayNode as? ChatAvatarNavigationNode)?.contextActionIsEnabled = peer.restrictionText(platform: "ios", contentSettings: strongSelf.context.currentContentSettings.with { $0 }) == nil strongSelf.chatInfoNavigationButton?.buttonItem.accessibilityLabel = presentationInterfaceState.strings.Conversation_ContextMenuOpenProfile } @@ -6750,7 +6750,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G guard let strongSelf = self, let peer = strongSelf.presentationInterfaceState.renderedPeer?.peer else { return } - strongSelf.joinGroupCall(peerId: peer.id, invite: nil, activeCall: activeCall) + strongSelf.joinGroupCall(peerId: peer.id, invite: nil, activeCall: EngineGroupCallDescription(activeCall)) }, presentInviteMembers: { [weak self] in guard let strongSelf = self, let peer = strongSelf.presentationInterfaceState.renderedPeer?.peer else { return @@ -8257,7 +8257,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G })) } else { if let _ = canClearForMyself ?? canClearForEveryone { - items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: mainPeer, chatPeer: chatPeer, action: .clearHistory(canClearCache: canClearCache), strings: strongSelf.presentationData.strings, nameDisplayOrder: strongSelf.presentationData.nameDisplayOrder)) + items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: EnginePeer(mainPeer), chatPeer: EnginePeer(chatPeer), action: .clearHistory(canClearCache: canClearCache), strings: strongSelf.presentationData.strings, nameDisplayOrder: strongSelf.presentationData.nameDisplayOrder)) if let canClearForEveryone = canClearForEveryone { let text: String @@ -8446,7 +8446,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } var items: [ActionSheetItem] = [] - items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: peer, chatPeer: peer, action: .clearCache, strings: presentationData.strings, nameDisplayOrder: presentationData.nameDisplayOrder)) + items.append(DeleteChatPeerActionSheetItem(context: strongSelf.context, peer: EnginePeer(peer), chatPeer: EnginePeer(peer), action: .clearCache, strings: presentationData.strings, nameDisplayOrder: presentationData.nameDisplayOrder)) let validCategories: [PeerCacheUsageCategory] = [.image, .video, .audio, .file] @@ -11733,7 +11733,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G self?.controllerInteraction?.requestMessageActionUrlAuth(url, subject) } }, joinVoiceChat: { [weak self] peerId, invite, call in - self?.joinGroupCall(peerId: peerId, invite: invite, activeCall: call) + self?.joinGroupCall(peerId: peerId, invite: invite, activeCall: EngineGroupCallDescription(call)) }, present: { [weak self] c, a in self?.present(c, in: .window(.root), with: a) }, dismissInput: { [weak self] in @@ -12105,7 +12105,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G let actionSheet = ActionSheetController(presentationData: self.presentationData) var items: [ActionSheetItem] = [] - items.append(DeleteChatPeerActionSheetItem(context: self.context, peer: peer, chatPeer: peer, action: .clearCacheSuggestion, strings: self.presentationData.strings, nameDisplayOrder: self.presentationData.nameDisplayOrder)) + items.append(DeleteChatPeerActionSheetItem(context: self.context, peer: EnginePeer(peer), chatPeer: EnginePeer(peer), action: .clearCacheSuggestion, strings: self.presentationData.strings, nameDisplayOrder: self.presentationData.nameDisplayOrder)) var presented = false items.append(ActionSheetButtonItem(title: self.presentationData.strings.ClearCache_FreeSpace, color: .accent, action: { [weak self, weak actionSheet] in @@ -12442,7 +12442,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return inputShortcuts + otherShortcuts } - public override func joinGroupCall(peerId: PeerId, invite: String?, activeCall: CachedChannelData.ActiveCall) { + public override func joinGroupCall(peerId: PeerId, invite: String?, activeCall: EngineGroupCallDescription) { let proceed = { super.joinGroupCall(peerId: peerId, invite: invite, activeCall: activeCall) } diff --git a/submodules/TelegramUI/Sources/ChatMediaInputPeerSpecificItem.swift b/submodules/TelegramUI/Sources/ChatMediaInputPeerSpecificItem.swift index 1e588c200b..37b192bbfa 100644 --- a/submodules/TelegramUI/Sources/ChatMediaInputPeerSpecificItem.swift +++ b/submodules/TelegramUI/Sources/ChatMediaInputPeerSpecificItem.swift @@ -150,7 +150,7 @@ final class ChatMediaInputPeerSpecificItemNode: ListViewItemNode { self.avatarNode.frame = self.avatarNode.frame expandTransition.updateFrame(node: self.highlightNode, frame: expanded ? titleFrame.insetBy(dx: -7.0, dy: -2.0) : CGRect(origin: CGPoint(x: self.avatarNode.position.x - highlightSize.width / 2.0, y: self.avatarNode.position.y - highlightSize.height / 2.0), size: highlightSize)) - self.avatarNode.setPeer(context: context, theme: theme, peer: peer) + self.avatarNode.setPeer(context: context, theme: theme, peer: EnginePeer(peer)) } func updateIsHighlighted() { diff --git a/submodules/TelegramUI/Sources/ChatMessageAvatarAccessoryItem.swift b/submodules/TelegramUI/Sources/ChatMessageAvatarAccessoryItem.swift index 010ad7b8df..bf81f9ace3 100644 --- a/submodules/TelegramUI/Sources/ChatMessageAvatarAccessoryItem.swift +++ b/submodules/TelegramUI/Sources/ChatMessageAvatarAccessoryItem.swift @@ -178,6 +178,6 @@ final class ChatMessageAvatarAccessoryItemNode: ListViewAccessoryItemNode { if peer.isDeleted { overrideImage = .deletedIcon } - self.avatarNode.setPeer(context: context, theme: theme, peer: peer, authorOfMessage: authorOfMessage, overrideImage: overrideImage, emptyColor: emptyColor, synchronousLoad: synchronousLoad, displayDimensions: CGSize(width: 38.0, height: 38.0)) + self.avatarNode.setPeer(context: context, theme: theme, peer: EnginePeer(peer), authorOfMessage: authorOfMessage, overrideImage: overrideImage, emptyColor: emptyColor, synchronousLoad: synchronousLoad, displayDimensions: CGSize(width: 38.0, height: 38.0)) } } diff --git a/submodules/TelegramUI/Sources/ChatMessageCommentFooterContentNode.swift b/submodules/TelegramUI/Sources/ChatMessageCommentFooterContentNode.swift index 973dbf4a56..d14942f98c 100644 --- a/submodules/TelegramUI/Sources/ChatMessageCommentFooterContentNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageCommentFooterContentNode.swift @@ -353,7 +353,7 @@ final class ChatMessageCommentFooterContentNode: ChatMessageBubbleContentNode { } } - let avatarContent = strongSelf.avatarsContext.update(peers: replyPeers, animated: animation.isAnimated) + let avatarContent = strongSelf.avatarsContext.update(peers: replyPeers.map(EnginePeer.init), animated: animation.isAnimated) let avatarsSize = strongSelf.avatarsNode.update(context: item.context, content: avatarContent, animated: animation.isAnimated, synchronousLoad: synchronousLoad) let iconAlpha: CGFloat = avatarsSize.width.isZero ? 1.0 : 0.0 diff --git a/submodules/TelegramUI/Sources/ChatMessageContactBubbleContentNode.swift b/submodules/TelegramUI/Sources/ChatMessageContactBubbleContentNode.swift index 2b8b6c441f..f9cc25ac81 100644 --- a/submodules/TelegramUI/Sources/ChatMessageContactBubbleContentNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageContactBubbleContentNode.swift @@ -322,7 +322,7 @@ class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode { } if let peerId = selectedContact?.peerId, let peer = item.message.peers[peerId] { - strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme.theme, peer: peer, emptyColor: avatarPlaceholderColor, synchronousLoad: synchronousLoads) + strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme.theme, peer: EnginePeer(peer), emptyColor: avatarPlaceholderColor, synchronousLoad: synchronousLoads) } else { strongSelf.avatarNode.setCustomLetters(customLetters) } diff --git a/submodules/TelegramUI/Sources/ChatMessageDateHeader.swift b/submodules/TelegramUI/Sources/ChatMessageDateHeader.swift index afd4e1a69b..ec201e8fa3 100644 --- a/submodules/TelegramUI/Sources/ChatMessageDateHeader.swift +++ b/submodules/TelegramUI/Sources/ChatMessageDateHeader.swift @@ -437,7 +437,7 @@ final class ChatMessageAvatarHeaderNode: ListViewItemHeaderNode { if peer.isDeleted { overrideImage = .deletedIcon } - self.avatarNode.setPeer(context: context, theme: theme, peer: peer, authorOfMessage: authorOfMessage, overrideImage: overrideImage, emptyColor: emptyColor, synchronousLoad: synchronousLoad, displayDimensions: CGSize(width: 38.0, height: 38.0)) + self.avatarNode.setPeer(context: context, theme: theme, peer: EnginePeer(peer), authorOfMessage: authorOfMessage, overrideImage: overrideImage, emptyColor: emptyColor, synchronousLoad: synchronousLoad, displayDimensions: CGSize(width: 38.0, height: 38.0)) } override func didLoad() { diff --git a/submodules/TelegramUI/Sources/ChatMessageMapBubbleContentNode.swift b/submodules/TelegramUI/Sources/ChatMessageMapBubbleContentNode.swift index fc60e62bdf..74c1f9cd4d 100644 --- a/submodules/TelegramUI/Sources/ChatMessageMapBubbleContentNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageMapBubbleContentNode.swift @@ -151,7 +151,7 @@ class ChatMessageMapBubbleContentNode: ChatMessageBubbleContentNode { var mode: ChatMessageLiveLocationPositionNode.Mode = .location(selectedMedia) if let selectedMedia = selectedMedia, let peer = item.message.author { if selectedMedia.liveBroadcastingTimeout != nil { - mode = .liveLocation(peer: peer, active: activeLiveBroadcastingTimeout != nil, latitude: selectedMedia.latitude, longitude: selectedMedia.longitude, heading: selectedMedia.heading) + mode = .liveLocation(peer: EnginePeer(peer), active: activeLiveBroadcastingTimeout != nil, latitude: selectedMedia.latitude, longitude: selectedMedia.longitude, heading: selectedMedia.heading) } } let (pinSize, pinApply) = makePinLayout(item.context, item.presentationData.theme.theme, mode) diff --git a/submodules/TelegramUI/Sources/ChatMessageNotificationItem.swift b/submodules/TelegramUI/Sources/ChatMessageNotificationItem.swift index f02214c67d..5a4117b696 100644 --- a/submodules/TelegramUI/Sources/ChatMessageNotificationItem.swift +++ b/submodules/TelegramUI/Sources/ChatMessageNotificationItem.swift @@ -150,7 +150,7 @@ final class ChatMessageNotificationItemNode: NotificationItemNode { if firstMessage.id.peerId.isReplies, let author = firstMessage.forwardInfo?.author { avatarPeer = author } - self.avatarNode.setPeer(context: item.context, theme: presentationData.theme, peer: avatarPeer, overrideImage: peer.id == item.context.account.peerId ? .savedMessagesIcon : nil, emptyColor: presentationData.theme.list.mediaPlaceholderColor) + self.avatarNode.setPeer(context: item.context, theme: presentationData.theme, peer: EnginePeer(avatarPeer), overrideImage: peer.id == item.context.account.peerId ? .savedMessagesIcon : nil, emptyColor: presentationData.theme.list.mediaPlaceholderColor) } var updatedMedia: Media? diff --git a/submodules/TelegramUI/Sources/ChatOverscrollControl.swift b/submodules/TelegramUI/Sources/ChatOverscrollControl.swift index fdadbfec2d..11ad2f9e29 100644 --- a/submodules/TelegramUI/Sources/ChatOverscrollControl.swift +++ b/submodules/TelegramUI/Sources/ChatOverscrollControl.swift @@ -320,7 +320,7 @@ final class AvatarComponent: Component { func update(component: AvatarComponent, availableSize: CGSize, transition: Transition) -> CGSize { self.avatarNode.frame = CGRect(origin: CGPoint(), size: availableSize) - self.avatarNode.setPeer(context: component.context, theme: component.context.sharedContext.currentPresentationData.with({ $0 }).theme, peer: component.peer._asPeer(), synchronousLoad: true) + self.avatarNode.setPeer(context: component.context, theme: component.context.sharedContext.currentPresentationData.with({ $0 }).theme, peer: component.peer, synchronousLoad: true) return availableSize } diff --git a/submodules/TelegramUI/Sources/CommandChatInputPanelItem.swift b/submodules/TelegramUI/Sources/CommandChatInputPanelItem.swift index bd800e6984..4339046032 100644 --- a/submodules/TelegramUI/Sources/CommandChatInputPanelItem.swift +++ b/submodules/TelegramUI/Sources/CommandChatInputPanelItem.swift @@ -164,7 +164,7 @@ final class CommandChatInputPanelItemNode: ListViewItemNode { strongSelf.arrowNode.setImage(iconImage, for: []) - strongSelf.avatarNode.setPeer(context: item.context, theme: item.theme, peer: item.command.peer, emptyColor: item.theme.list.mediaPlaceholderColor) + strongSelf.avatarNode.setPeer(context: item.context, theme: item.theme, peer: EnginePeer(item.command.peer), emptyColor: item.theme.list.mediaPlaceholderColor) let _ = textApply() diff --git a/submodules/TelegramUI/Sources/MentionChatInputPanelItem.swift b/submodules/TelegramUI/Sources/MentionChatInputPanelItem.swift index 1605756d1f..3c3373f2fa 100644 --- a/submodules/TelegramUI/Sources/MentionChatInputPanelItem.swift +++ b/submodules/TelegramUI/Sources/MentionChatInputPanelItem.swift @@ -200,7 +200,7 @@ final class MentionChatInputPanelItemNode: ListViewItemNode { strongSelf.backgroundColor = item.presentationData.theme.list.plainBackgroundColor strongSelf.highlightedBackgroundNode.backgroundColor = item.presentationData.theme.list.itemHighlightedBackgroundColor - strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: item.peer, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor) + strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(item.peer), emptyColor: item.presentationData.theme.list.mediaPlaceholderColor) let _ = textApply() diff --git a/submodules/TelegramUI/Sources/OpenResolvedUrl.swift b/submodules/TelegramUI/Sources/OpenResolvedUrl.swift index 0f2dd98798..c0d08dee99 100644 --- a/submodules/TelegramUI/Sources/OpenResolvedUrl.swift +++ b/submodules/TelegramUI/Sources/OpenResolvedUrl.swift @@ -471,7 +471,7 @@ func openResolvedUrlImpl(_ resolvedUrl: ResolvedUrl, context: AccountContext, ur return } navigationController.currentWindow?.present(VoiceChatJoinScreen(context: context, peerId: peerId, invite: invite, join: { [weak chatController] call in - chatController?.joinGroupCall(peerId: peerId, invite: invite, activeCall: call) + chatController?.joinGroupCall(peerId: peerId, invite: invite, activeCall: EngineGroupCallDescription(call)) }), on: .root, blockInteraction: false, completion: {}) })) } diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift index c45236ee00..e7d06100a9 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift @@ -392,7 +392,7 @@ final class PeerInfoAvatarTransformContainerNode: ASDisplayNode { self.containerNode.isGestureEnabled = false } - self.avatarNode.setPeer(context: self.context, theme: theme, peer: peer, overrideImage: overrideImage, synchronousLoad: self.isFirstAvatarLoading, displayDimensions: CGSize(width: avatarSize, height: avatarSize), storeUnrounded: true) + self.avatarNode.setPeer(context: self.context, theme: theme, peer: EnginePeer(peer), overrideImage: overrideImage, synchronousLoad: self.isFirstAvatarLoading, displayDimensions: CGSize(width: avatarSize, height: avatarSize), storeUnrounded: true) self.isFirstAvatarLoading = false self.containerNode.frame = CGRect(origin: CGPoint(x: -avatarSize / 2.0, y: -avatarSize / 2.0), size: CGSize(width: avatarSize, height: avatarSize)) @@ -691,7 +691,7 @@ final class PeerInfoEditingAvatarNode: ASDisplayNode { overrideImage = nil } self.avatarNode.font = avatarPlaceholderFont(size: floor(avatarSize * 16.0 / 37.0)) - self.avatarNode.setPeer(context: self.context, theme: theme, peer: peer, overrideImage: overrideImage, synchronousLoad: false, displayDimensions: CGSize(width: avatarSize, height: avatarSize)) + self.avatarNode.setPeer(context: self.context, theme: theme, peer: EnginePeer(peer), overrideImage: overrideImage, synchronousLoad: false, displayDimensions: CGSize(width: avatarSize, height: avatarSize)) self.avatarNode.frame = CGRect(origin: CGPoint(x: -avatarSize / 2.0, y: -avatarSize / 2.0), size: CGSize(width: avatarSize, height: avatarSize)) if let item = item { diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index abce9e6d90..26de979e7a 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -3945,7 +3945,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD private func requestCall(isVideo: Bool, gesture: ContextGesture? = nil, contextController: ContextControllerProtocol? = nil, result: ((ContextMenuActionResult) -> Void)? = nil, backAction: ((ContextControllerProtocol) -> Void)? = nil) { let peerId = self.peerId - let requestCall: (PeerId?, CachedChannelData.ActiveCall?) -> Void = { [weak self] defaultJoinAsPeerId, activeCall in + let requestCall: (PeerId?, EngineGroupCallDescription?) -> Void = { [weak self] defaultJoinAsPeerId, activeCall in if let activeCall = activeCall { self?.context.joinGroupCall(peerId: peerId, invite: nil, requestJoinAsPeerId: { completion in if let defaultJoinAsPeerId = defaultJoinAsPeerId { @@ -3963,10 +3963,10 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD } if let cachedChannelData = self.data?.cachedData as? CachedChannelData { - requestCall(cachedChannelData.callJoinPeerId, cachedChannelData.activeCall) + requestCall(cachedChannelData.callJoinPeerId, cachedChannelData.activeCall.flatMap(EngineGroupCallDescription.init)) return } else if let cachedGroupData = self.data?.cachedData as? CachedGroupData { - requestCall(cachedGroupData.callJoinPeerId, cachedGroupData.activeCall) + requestCall(cachedGroupData.callJoinPeerId, cachedGroupData.activeCall.flatMap(EngineGroupCallDescription.init)) return } @@ -4024,7 +4024,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD } strongSelf.context.joinGroupCall(peerId: peerId, invite: nil, requestJoinAsPeerId: { result in result(joinAsPeerId) - }, activeCall: CachedChannelData.ActiveCall(id: info.id, accessHash: info.accessHash, title: info.title, scheduleTimestamp: nil, subscribedToScheduled: false)) + }, activeCall: EngineGroupCallDescription(id: info.id, accessHash: info.accessHash, title: info.title, scheduleTimestamp: nil, subscribedToScheduled: false)) }, error: { [weak self] error in guard let strongSelf = self else { return diff --git a/submodules/UndoUI/Sources/UndoOverlayControllerNode.swift b/submodules/UndoUI/Sources/UndoOverlayControllerNode.swift index 5c0e1d6143..f22d8dc8a3 100644 --- a/submodules/UndoUI/Sources/UndoOverlayControllerNode.swift +++ b/submodules/UndoUI/Sources/UndoOverlayControllerNode.swift @@ -504,7 +504,7 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode { let attributedText = parseMarkdownIntoAttributedString(text, attributes: MarkdownAttributes(body: body, bold: bold, link: link, linkAttribute: { _ in return nil }), textAlignment: .natural) self.textNode.attributedText = attributedText - self.avatarNode?.setPeer(context: context, theme: presentationData.theme, peer: peer, overrideImage: nil, emptyColor: presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: true) + self.avatarNode?.setPeer(context: context, theme: presentationData.theme, peer: EnginePeer(peer), overrideImage: nil, emptyColor: presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: true) displayUndo = false self.originalRemainingSeconds = 3