mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Postbox refactor waves 358-426
Squashed range bf01b4c..a66739c (70 commits) covering 69 waves of the Postbox -> TelegramEngine consumer migration plus a few BUILD-dep followups. Notable additions to TelegramCore in this range: - Engine typealiases: EngineRawPeerPresence, EngineRawValueBoxKey, EngineSimpleDictionary, EngineRawPeerView, EngineRawPostboxViewKey, EngineRawPreferencesView, EngineRawMessageHistoryView (+ entry/attrs/ read-state), EngineMessageIdNamespaces, EngineHistoryViewInputAnchor, EngineRawUnreadMessageCountsItem, EngineRawMessageHistorySavedMessages IndexView, EngineRawChatInterfaceStateView, EngineRawOrderedItemList View, EngineRawMessageHistoryThreadIndexView, EngineRawCombinedRead StateView, EngineRawMessageHistoryThreadInfoView, EngineRawBasicPeer View, EngineRawCachedPeerDataView, EngineMessageHistoryThreadData, EngineViewUpdateType, EngineInitialMessageHistoryData, EnginePeerGroupId, EngineChatLocationInput, EngineHistoryViewInputTag. - Engine data items: Peer.CachedData, ItemCollections.InstalledPackInfos, ItemCollections.InstalledPackIds. - Engine facade: TelegramEngine.ItemCollections.allItems(namespace:). - Free function: engineAreMediaArraysEqual forwarder. Net effect: 65+ consumer modules drop "import Postbox"; 131 files changed (+1386 / -1493). Build green at HEAD.
This commit is contained in:
parent
bf01b4c858
commit
4107263747
131 changed files with 1387 additions and 1494 deletions
|
|
@ -1,7 +1,6 @@
|
|||
import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
|
|
@ -51,7 +50,7 @@ public final class TelegramApplicationBindings {
|
|||
public let displayNotification: (String) -> Void
|
||||
public let applicationInForeground: Signal<Bool, NoError>
|
||||
public let applicationIsActive: Signal<Bool, NoError>
|
||||
public let clearMessageNotifications: ([MessageId]) -> Void
|
||||
public let clearMessageNotifications: ([EngineMessage.Id]) -> Void
|
||||
public let pushIdleTimerExtension: () -> Disposable
|
||||
public let openSettings: () -> Void
|
||||
public let openAppStorePage: () -> Void
|
||||
|
|
@ -67,7 +66,7 @@ public final class TelegramApplicationBindings {
|
|||
public let requestSetAlternateIconName: (String?, @escaping (Bool) -> Void) -> Void
|
||||
public let forceOrientation: (UIInterfaceOrientation) -> Void
|
||||
|
||||
public init(isMainApp: Bool, appBundleId: String, appBuildType: TelegramAppBuildType, containerPath: String, appSpecificScheme: String, openUrl: @escaping (String) -> Void, openUniversalUrl: @escaping (String, TelegramApplicationOpenUrlCompletion) -> Void, canOpenUrl: @escaping (String) -> Bool, getTopWindow: @escaping () -> UIWindow?, displayNotification: @escaping (String) -> Void, applicationInForeground: Signal<Bool, NoError>, applicationIsActive: Signal<Bool, NoError>, clearMessageNotifications: @escaping ([MessageId]) -> Void, pushIdleTimerExtension: @escaping () -> Disposable, openSettings: @escaping () -> Void, openAppStorePage: @escaping () -> Void, openSubscriptions: @escaping () -> Void, registerForNotifications: @escaping (@escaping (Bool) -> Void) -> Void, requestSiriAuthorization: @escaping (@escaping (Bool) -> Void) -> Void, siriAuthorization: @escaping () -> AccessType, getWindowHost: @escaping () -> WindowHost?, presentNativeController: @escaping (UIViewController) -> Void, dismissNativeController: @escaping () -> Void, getAvailableAlternateIcons: @escaping () -> [PresentationAppIcon], getAlternateIconName: @escaping () -> String?, requestSetAlternateIconName: @escaping (String?, @escaping (Bool) -> Void) -> Void, forceOrientation: @escaping (UIInterfaceOrientation) -> Void) {
|
||||
public init(isMainApp: Bool, appBundleId: String, appBuildType: TelegramAppBuildType, containerPath: String, appSpecificScheme: String, openUrl: @escaping (String) -> Void, openUniversalUrl: @escaping (String, TelegramApplicationOpenUrlCompletion) -> Void, canOpenUrl: @escaping (String) -> Bool, getTopWindow: @escaping () -> UIWindow?, displayNotification: @escaping (String) -> Void, applicationInForeground: Signal<Bool, NoError>, applicationIsActive: Signal<Bool, NoError>, clearMessageNotifications: @escaping ([EngineMessage.Id]) -> Void, pushIdleTimerExtension: @escaping () -> Disposable, openSettings: @escaping () -> Void, openAppStorePage: @escaping () -> Void, openSubscriptions: @escaping () -> Void, registerForNotifications: @escaping (@escaping (Bool) -> Void) -> Void, requestSiriAuthorization: @escaping (@escaping (Bool) -> Void) -> Void, siriAuthorization: @escaping () -> AccessType, getWindowHost: @escaping () -> WindowHost?, presentNativeController: @escaping (UIViewController) -> Void, dismissNativeController: @escaping () -> Void, getAvailableAlternateIcons: @escaping () -> [PresentationAppIcon], getAlternateIconName: @escaping () -> String?, requestSetAlternateIconName: @escaping (String?, @escaping (Bool) -> Void) -> Void, forceOrientation: @escaping (UIInterfaceOrientation) -> Void) {
|
||||
self.isMainApp = isMainApp
|
||||
self.appBundleId = appBundleId
|
||||
self.appBuildType = appBuildType
|
||||
|
|
@ -131,7 +130,7 @@ public final class AccountWithInfo: Equatable {
|
|||
|
||||
public enum OpenURLContext {
|
||||
case generic
|
||||
case chat(peerId: PeerId, message: Message?, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?)
|
||||
case chat(peerId: EnginePeer.Id, message: EngineRawMessage?, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?)
|
||||
case external
|
||||
}
|
||||
|
||||
|
|
@ -291,14 +290,14 @@ public enum ResolvedBotStartPeerType {
|
|||
public enum ResolvedUrl {
|
||||
case externalUrl(String)
|
||||
case urlAuth(String)
|
||||
case peer(Peer?, ChatControllerInteractionNavigateToPeer)
|
||||
case peer(EngineRawPeer?, ChatControllerInteractionNavigateToPeer)
|
||||
case inaccessiblePeer
|
||||
case botStart(peer: Peer, payload: String)
|
||||
case groupBotStart(peerId: PeerId, payload: String, adminRights: ResolvedBotAdminRights?, peerType: ResolvedBotStartPeerType?)
|
||||
case gameStart(peerId: PeerId, game: String)
|
||||
case channelMessage(peer: Peer, messageId: MessageId, timecode: Double?)
|
||||
case replyThreadMessage(replyThreadMessage: ChatReplyThreadMessage, messageId: MessageId)
|
||||
case replyThread(messageId: MessageId)
|
||||
case botStart(peer: EngineRawPeer, payload: String)
|
||||
case groupBotStart(peerId: EnginePeer.Id, payload: String, adminRights: ResolvedBotAdminRights?, peerType: ResolvedBotStartPeerType?)
|
||||
case gameStart(peerId: EnginePeer.Id, game: String)
|
||||
case channelMessage(peer: EngineRawPeer, messageId: EngineMessage.Id, timecode: Double?)
|
||||
case replyThreadMessage(replyThreadMessage: ChatReplyThreadMessage, messageId: EngineMessage.Id)
|
||||
case replyThread(messageId: EngineMessage.Id)
|
||||
case stickerPack(name: String, type: StickerPackUrlType)
|
||||
case instantView(TelegramMediaWebpage, String?)
|
||||
case proxy(host: String, port: Int32, username: String?, password: String?, secret: Data?)
|
||||
|
|
@ -310,15 +309,15 @@ public enum ResolvedUrl {
|
|||
case share(url: String?, text: String?, to: String?)
|
||||
case wallpaper(WallpaperUrlParameter)
|
||||
case theme(String)
|
||||
case joinVoiceChat(PeerId, String?)
|
||||
case joinVoiceChat(EnginePeer.Id, String?)
|
||||
case importStickers
|
||||
case startAttach(peerId: PeerId, payload: String?, choose: ResolvedBotChoosePeerTypes?)
|
||||
case startAttach(peerId: EnginePeer.Id, payload: String?, choose: ResolvedBotChoosePeerTypes?)
|
||||
case invoice(slug: String, invoice: TelegramMediaInvoice?)
|
||||
case premiumOffer(reference: String?)
|
||||
case starsTopup(amount: Int64?, purpose: String?)
|
||||
case chatFolder(slug: String)
|
||||
case story(peerId: PeerId, id: Int32)
|
||||
case boost(peerId: PeerId?, status: ChannelBoostStatus?, myBoostStatus: MyBoostStatus?)
|
||||
case story(peerId: EnginePeer.Id, id: Int32)
|
||||
case boost(peerId: EnginePeer.Id?, status: ChannelBoostStatus?, myBoostStatus: MyBoostStatus?)
|
||||
case premiumGiftCode(slug: String)
|
||||
case premiumMultiGift(reference: String?)
|
||||
case auction(auction: GiftAuctionContext?)
|
||||
|
|
@ -326,12 +325,12 @@ public enum ResolvedUrl {
|
|||
case stars
|
||||
case ton
|
||||
case shareStory(Int64)
|
||||
case storyFolder(peerId: PeerId, id: Int64)
|
||||
case giftCollection(peerId: PeerId, id: Int64)
|
||||
case sendGift(peerId: PeerId?)
|
||||
case storyFolder(peerId: EnginePeer.Id, id: Int64)
|
||||
case giftCollection(peerId: EnginePeer.Id, id: Int64)
|
||||
case sendGift(peerId: EnginePeer.Id?)
|
||||
case unknownDeepLink(path: String)
|
||||
case oauth(url: String)
|
||||
case createBot(parentBot: PeerId, username: String?, title: String?)
|
||||
case createBot(parentBot: EnginePeer.Id, username: String?, title: String?)
|
||||
case textStyle(style: TelegramComposeAIMessageMode.CloudStyle.Custom, initialPreview: AIMessageStylePreview?)
|
||||
|
||||
public enum ResolvedCollectible {
|
||||
|
|
@ -425,7 +424,7 @@ public final class ChatGreetingData: Equatable {
|
|||
public enum ChatSearchDomain: Equatable {
|
||||
case everything
|
||||
case members
|
||||
case member(Peer)
|
||||
case member(EngineRawPeer)
|
||||
case tag(MessageReaction.Reaction)
|
||||
|
||||
public static func ==(lhs: ChatSearchDomain, rhs: ChatSearchDomain) -> Bool {
|
||||
|
|
@ -459,7 +458,7 @@ public enum ChatSearchDomain: Equatable {
|
|||
}
|
||||
|
||||
public enum ChatLocation: Equatable {
|
||||
case peer(id: PeerId)
|
||||
case peer(id: EnginePeer.Id)
|
||||
case replyThread(message: ChatReplyThreadMessage)
|
||||
case customChatContents
|
||||
}
|
||||
|
|
@ -474,7 +473,7 @@ public extension ChatLocation {
|
|||
}
|
||||
}
|
||||
|
||||
var peerId: PeerId? {
|
||||
var peerId: EnginePeer.Id? {
|
||||
switch self {
|
||||
case let .peer(peerId):
|
||||
return peerId
|
||||
|
|
@ -579,7 +578,7 @@ public final class NavigateToChatControllerParams {
|
|||
public let animated: Bool
|
||||
public let forceAnimatedScroll: Bool
|
||||
public let options: NavigationAnimationOptions
|
||||
public let parentGroupId: PeerGroupId?
|
||||
public let parentGroupId: EnginePeerGroupId?
|
||||
public let chatListFilter: Int32?
|
||||
public let chatNavigationStack: [ChatNavigationStackItem]
|
||||
public let changeColors: Bool
|
||||
|
|
@ -614,7 +613,7 @@ public final class NavigateToChatControllerParams {
|
|||
animated: Bool = true,
|
||||
forceAnimatedScroll: Bool = false,
|
||||
options: NavigationAnimationOptions = [],
|
||||
parentGroupId: PeerGroupId? = nil,
|
||||
parentGroupId: EnginePeerGroupId? = nil,
|
||||
chatListFilter: Int32? = nil,
|
||||
chatNavigationStack: [ChatNavigationStackItem] = [],
|
||||
changeColors: Bool = false,
|
||||
|
|
@ -737,8 +736,8 @@ public enum PeerInfoControllerMode {
|
|||
case generic
|
||||
case calls(messages: [EngineMessage])
|
||||
case nearbyPeer(distance: Int32)
|
||||
case group(sourceMessageId: MessageId)
|
||||
case reaction(MessageId)
|
||||
case group(sourceMessageId: EngineMessage.Id)
|
||||
case reaction(EngineMessage.Id)
|
||||
case forumTopic(thread: ChatReplyThreadMessage)
|
||||
case recommendedChannels
|
||||
case myProfile
|
||||
|
|
@ -810,7 +809,7 @@ public enum ChatListSearchFilter: Equatable {
|
|||
case music
|
||||
case voice
|
||||
case instantVideo
|
||||
case peer(PeerId, Bool, String, String)
|
||||
case peer(EnginePeer.Id, Bool, String, String)
|
||||
case date(Int32?, Int32, String)
|
||||
case publicPosts
|
||||
|
||||
|
|
@ -1361,15 +1360,15 @@ public protocol SharedAccountContext: AnyObject {
|
|||
|
||||
func updateNotificationTokensRegistration()
|
||||
func setAccountUserInterfaceInUse(_ id: AccountRecordId) -> Disposable
|
||||
func handleTextLinkAction(context: AccountContext, peerId: PeerId?, navigateDisposable: MetaDisposable, controller: ViewController, action: TextLinkItemActionType, itemLink: TextLinkItem)
|
||||
func handleTextLinkAction(context: AccountContext, peerId: EnginePeer.Id?, navigateDisposable: MetaDisposable, controller: ViewController, action: TextLinkItemActionType, itemLink: TextLinkItem)
|
||||
func openSearch(filter: ChatListSearchFilter, query: String?)
|
||||
func navigateToChat(accountId: AccountRecordId, peerId: PeerId, messageId: MessageId?)
|
||||
func navigateToChat(accountId: AccountRecordId, peerId: EnginePeer.Id, messageId: EngineMessage.Id?)
|
||||
func openChatMessage(_ params: OpenChatMessageParams) -> Bool
|
||||
func messageFromPreloadedChatHistoryViewForLocation(id: MessageId, location: ChatHistoryLocationInput, context: AccountContext, chatLocation: ChatLocation, subject: ChatControllerSubject?, chatLocationContextHolder: Atomic<ChatLocationContextHolder?>, tag: HistoryViewInputTag?) -> Signal<(MessageIndex?, Bool), NoError>
|
||||
func messageFromPreloadedChatHistoryViewForLocation(id: EngineMessage.Id, location: ChatHistoryLocationInput, context: AccountContext, chatLocation: ChatLocation, subject: ChatControllerSubject?, chatLocationContextHolder: Atomic<ChatLocationContextHolder?>, tag: EngineHistoryViewInputTag?) -> Signal<(EngineMessage.Index?, Bool), NoError>
|
||||
|
||||
func makeOverlayAudioPlayerController(context: AccountContext, chatLocation: ChatLocation, type: MediaManagerPlayerType, initialMessageId: MessageId, initialOrder: MusicPlaybackSettingsOrder, playlistLocation: SharedMediaPlaylistLocation?, parentNavigationController: NavigationController?) -> ViewController & OverlayAudioPlayerController
|
||||
func makeOverlayAudioPlayerController(context: AccountContext, chatLocation: ChatLocation, type: MediaManagerPlayerType, initialMessageId: EngineMessage.Id, initialOrder: MusicPlaybackSettingsOrder, playlistLocation: SharedMediaPlaylistLocation?, parentNavigationController: NavigationController?) -> ViewController & OverlayAudioPlayerController
|
||||
func makePeerInfoController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?, peer: EnginePeer, mode: PeerInfoControllerMode, avatarInitiallyExpanded: Bool, fromChat: Bool, requestsContext: PeerInvitationImportersContext?) -> ViewController?
|
||||
func makeChannelAdminController(context: AccountContext, peerId: PeerId, adminId: PeerId, initialParticipant: ChannelParticipant) -> ViewController?
|
||||
func makeChannelAdminController(context: AccountContext, peerId: EnginePeer.Id, adminId: EnginePeer.Id, initialParticipant: ChannelParticipant) -> ViewController?
|
||||
func makeDeviceContactInfoController(context: ShareControllerAccountContext, environment: ShareControllerEnvironment, subject: DeviceContactInfoSubject, completed: (() -> Void)?, cancelled: (() -> Void)?) -> ViewController
|
||||
func makePeersNearbyController(context: AccountContext) -> ViewController
|
||||
func makeComposeController(context: AccountContext) -> ViewController
|
||||
|
|
@ -1380,25 +1379,25 @@ public protocol SharedAccountContext: AnyObject {
|
|||
updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>),
|
||||
chatLocation: ChatLocation,
|
||||
chatLocationContextHolder: Atomic<ChatLocationContextHolder?>,
|
||||
tag: HistoryViewInputTag?,
|
||||
tag: EngineHistoryViewInputTag?,
|
||||
source: ChatHistoryListSource,
|
||||
subject: ChatControllerSubject?,
|
||||
controllerInteraction: ChatControllerInteractionProtocol,
|
||||
selectedMessages: Signal<Set<MessageId>?, NoError>,
|
||||
selectedMessages: Signal<Set<EngineMessage.Id>?, NoError>,
|
||||
mode: ChatHistoryListMode
|
||||
) -> ChatHistoryListNode
|
||||
func subscribeChatListData(context: AccountContext, location: ChatListControllerLocation) -> Signal<EngineChatList, NoError>
|
||||
func makeChatMessagePreviewItem(context: AccountContext, messages: [Message], theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, fontSize: PresentationFontSize, chatBubbleCorners: PresentationChatBubbleCorners, dateTimeFormat: PresentationDateTimeFormat, nameOrder: PresentationPersonNameOrder, forcedResourceStatus: FileMediaResourceStatus?, tapMessage: ((Message) -> Void)?, clickThroughMessage: ((UIView?, CGPoint?) -> Void)?, backgroundNode: ASDisplayNode?, availableReactions: AvailableReactions?, accountPeer: Peer?, isCentered: Bool, isPreview: Bool, isStandalone: Bool, rank: String?, rankRole: ChatRankInfoScreenRole?) -> ListViewItem
|
||||
func makeChatMessagePreviewItem(context: AccountContext, messages: [EngineRawMessage], theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, fontSize: PresentationFontSize, chatBubbleCorners: PresentationChatBubbleCorners, dateTimeFormat: PresentationDateTimeFormat, nameOrder: PresentationPersonNameOrder, forcedResourceStatus: FileMediaResourceStatus?, tapMessage: ((EngineRawMessage) -> Void)?, clickThroughMessage: ((UIView?, CGPoint?) -> Void)?, backgroundNode: ASDisplayNode?, availableReactions: AvailableReactions?, accountPeer: EngineRawPeer?, isCentered: Bool, isPreview: Bool, isStandalone: Bool, rank: String?, rankRole: ChatRankInfoScreenRole?) -> ListViewItem
|
||||
func makeChatMessageDateHeaderItem(context: AccountContext, timestamp: Int32, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, fontSize: PresentationFontSize, chatBubbleCorners: PresentationChatBubbleCorners, dateTimeFormat: PresentationDateTimeFormat, nameOrder: PresentationPersonNameOrder) -> ListViewItemHeader
|
||||
func makeChatMessageAvatarHeaderItem(context: AccountContext, timestamp: Int32, peer: Peer, message: Message, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, fontSize: PresentationFontSize, chatBubbleCorners: PresentationChatBubbleCorners, dateTimeFormat: PresentationDateTimeFormat, nameOrder: PresentationPersonNameOrder) -> ListViewItemHeader
|
||||
func makePeerSharedMediaController(context: AccountContext, peerId: PeerId) -> ViewController?
|
||||
func makeChatMessageAvatarHeaderItem(context: AccountContext, timestamp: Int32, peer: EngineRawPeer, message: EngineRawMessage, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, fontSize: PresentationFontSize, chatBubbleCorners: PresentationChatBubbleCorners, dateTimeFormat: PresentationDateTimeFormat, nameOrder: PresentationPersonNameOrder) -> ListViewItemHeader
|
||||
func makePeerSharedMediaController(context: AccountContext, peerId: EnginePeer.Id) -> ViewController?
|
||||
func makeContactSelectionController(_ params: ContactSelectionControllerParams) -> ContactSelectionController
|
||||
func makeContactMultiselectionController(_ params: ContactMultiselectionControllerParams) -> ContactMultiselectionController
|
||||
func makePeerSelectionController(_ params: PeerSelectionControllerParams) -> PeerSelectionController
|
||||
func makeProxySettingsController(context: AccountContext) -> ViewController
|
||||
func makeLocalizationListController(context: AccountContext) -> ViewController
|
||||
func makeCreateGroupController(context: AccountContext, peerIds: [PeerId], initialTitle: String?, mode: CreateGroupMode, completion: ((PeerId, @escaping () -> Void) -> Void)?) -> ViewController
|
||||
func makeChatRecentActionsController(context: AccountContext, peer: EnginePeer, adminPeerId: PeerId?, starsState: StarsRevenueStats?) -> ViewController
|
||||
func makeCreateGroupController(context: AccountContext, peerIds: [EnginePeer.Id], initialTitle: String?, mode: CreateGroupMode, completion: ((EnginePeer.Id, @escaping () -> Void) -> Void)?) -> ViewController
|
||||
func makeChatRecentActionsController(context: AccountContext, peer: EnginePeer, adminPeerId: EnginePeer.Id?, starsState: StarsRevenueStats?) -> ViewController
|
||||
func makePrivacyAndSecurityController(context: AccountContext) -> ViewController
|
||||
func makeBioPrivacyController(context: AccountContext, settings: Promise<AccountPrivacySettings?>, present: @escaping (ViewController) -> Void)
|
||||
func makeBirthdayPrivacyController(context: AccountContext, settings: Promise<AccountPrivacySettings?>, openedFromBirthdayScreen: Bool, present: @escaping (ViewController) -> Void)
|
||||
|
|
@ -1435,15 +1434,15 @@ public protocol SharedAccountContext: AnyObject {
|
|||
func navigateToForumThread(context: AccountContext, peerId: EnginePeer.Id, threadId: Int64, messageId: EngineMessage.Id?, navigationController: NavigationController, activateInput: ChatControllerActivateInput?, scrollToEndIfExists: Bool, keepStack: NavigateToChatKeepStack, animated: Bool) -> Signal<Never, NoError>
|
||||
func chatControllerForForumThread(context: AccountContext, peerId: EnginePeer.Id, threadId: Int64) -> Signal<ChatController, NoError>
|
||||
func openStorageUsage(context: AccountContext)
|
||||
func openLocationScreen(context: AccountContext, messageId: MessageId, navigationController: NavigationController)
|
||||
func openLocationScreen(context: AccountContext, messageId: EngineMessage.Id, navigationController: NavigationController)
|
||||
func openExternalUrl(context: AccountContext, urlContext: OpenURLContext, url: String, forceExternal: Bool, presentationData: PresentationData, navigationController: NavigationController?, dismissInput: @escaping () -> Void)
|
||||
func chatAvailableMessageActions(engine: TelegramEngine, accountPeerId: EnginePeer.Id, messageIds: Set<EngineMessage.Id>, keepUpdated: Bool) -> Signal<ChatAvailableMessageActions, NoError>
|
||||
func chatAvailableMessageActions(engine: TelegramEngine, accountPeerId: EnginePeer.Id, messageIds: Set<EngineMessage.Id>, messages: [EngineMessage.Id: EngineMessage], peers: [EnginePeer.Id: EnginePeer]) -> Signal<ChatAvailableMessageActions, NoError>
|
||||
func resolveUrl(context: AccountContext, peerId: PeerId?, url: String, skipUrlAuth: Bool) -> Signal<ResolvedUrl, NoError>
|
||||
func resolveUrlWithProgress(context: AccountContext, peerId: PeerId?, url: String, skipUrlAuth: Bool) -> Signal<ResolveUrlResult, NoError>
|
||||
func openResolvedUrl(_ resolvedUrl: ResolvedUrl, context: AccountContext, urlContext: OpenURLContext, navigationController: NavigationController?, forceExternal: Bool, forceUpdate: Bool, openPeer: @escaping (EnginePeer, ChatControllerInteractionNavigateToPeer) -> Void, sendFile: ((FileMediaReference) -> Void)?, sendSticker: ((FileMediaReference, UIView?, CGRect?) -> Bool)?, sendEmoji: ((String, ChatTextInputTextCustomEmojiAttribute) -> Void)?, requestMessageActionUrlAuth: ((MessageActionUrlSubject) -> Void)?, joinVoiceChat: ((PeerId, String?, CachedChannelData.ActiveCall) -> Void)?, present: @escaping (ViewController, Any?) -> Void, dismissInput: @escaping () -> Void, contentContext: Any?, progress: Promise<Bool>?, completion: (() -> Void)?)
|
||||
func resolveUrl(context: AccountContext, peerId: EnginePeer.Id?, url: String, skipUrlAuth: Bool) -> Signal<ResolvedUrl, NoError>
|
||||
func resolveUrlWithProgress(context: AccountContext, peerId: EnginePeer.Id?, url: String, skipUrlAuth: Bool) -> Signal<ResolveUrlResult, NoError>
|
||||
func openResolvedUrl(_ resolvedUrl: ResolvedUrl, context: AccountContext, urlContext: OpenURLContext, navigationController: NavigationController?, forceExternal: Bool, forceUpdate: Bool, openPeer: @escaping (EnginePeer, ChatControllerInteractionNavigateToPeer) -> Void, sendFile: ((FileMediaReference) -> Void)?, sendSticker: ((FileMediaReference, UIView?, CGRect?) -> Bool)?, sendEmoji: ((String, ChatTextInputTextCustomEmojiAttribute) -> Void)?, requestMessageActionUrlAuth: ((MessageActionUrlSubject) -> Void)?, joinVoiceChat: ((EnginePeer.Id, String?, CachedChannelData.ActiveCall) -> Void)?, present: @escaping (ViewController, Any?) -> Void, dismissInput: @escaping () -> Void, contentContext: Any?, progress: Promise<Bool>?, completion: (() -> Void)?)
|
||||
func openAddContact(context: AccountContext, peer: EnginePeer?, firstName: String, lastName: String, phoneNumber: String, label: String, present: @escaping (ViewController, Any?) -> Void, pushController: @escaping (ViewController) -> Void, completed: @escaping () -> Void)
|
||||
func openAddPersonContact(context: AccountContext, peerId: PeerId, pushController: @escaping (ViewController) -> Void, present: @escaping (ViewController, Any?) -> Void)
|
||||
func openAddPersonContact(context: AccountContext, peerId: EnginePeer.Id, pushController: @escaping (ViewController) -> Void, present: @escaping (ViewController, Any?) -> Void)
|
||||
func presentContactsWarningSuppression(context: AccountContext, present: (ViewController, Any?) -> Void)
|
||||
func openImagePicker(context: AccountContext, completion: @escaping (UIImage) -> Void, present: @escaping (ViewController) -> Void)
|
||||
func displaySetPhoto(
|
||||
|
|
@ -1454,9 +1453,9 @@ public protocol SharedAccountContext: AnyObject {
|
|||
completedWithUploadingImage: @escaping (UIImage, Signal<PeerInfoAvatarUploadStatus, NoError>) -> UIView?
|
||||
)
|
||||
func openAddPeerMembers(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?, parentController: ViewController, groupPeer: EnginePeer, selectAddMemberDisposable: MetaDisposable, addMemberDisposable: MetaDisposable)
|
||||
func makeInstantPageController(context: AccountContext, message: Message, sourcePeerType: MediaAutoDownloadPeerType?) -> ViewController?
|
||||
func makeInstantPageController(context: AccountContext, message: EngineRawMessage, sourcePeerType: MediaAutoDownloadPeerType?) -> ViewController?
|
||||
func makeInstantPageController(context: AccountContext, webPage: TelegramMediaWebpage, anchor: String?, sourceLocation: InstantPageSourceLocation) -> ViewController
|
||||
func openChatWallpaper(context: AccountContext, message: Message, present: @escaping (ViewController, Any?) -> Void)
|
||||
func openChatWallpaper(context: AccountContext, message: EngineRawMessage, present: @escaping (ViewController, Any?) -> Void)
|
||||
func makeRecentSessionsController(context: AccountContext, activeSessionsContext: ActiveSessionsContext) -> ViewController & RecentSessionsController
|
||||
func makeChatQrCodeScreen(context: AccountContext, peer: EnginePeer, threadId: Int64?, temporary: Bool) -> ViewController
|
||||
func makePremiumIntroController(context: AccountContext, source: PremiumIntroSource, forceDark: Bool, dismissed: (() -> Void)?) -> ViewController
|
||||
|
|
@ -1680,15 +1679,15 @@ public protocol AccountContext: AnyObject {
|
|||
func storeSecureIdPassword(password: String)
|
||||
func getStoredSecureIdPassword() -> String?
|
||||
|
||||
func chatLocationInput(for location: ChatLocation, contextHolder: Atomic<ChatLocationContextHolder?>) -> ChatLocationInput
|
||||
func chatLocationOutgoingReadState(for location: ChatLocation, contextHolder: Atomic<ChatLocationContextHolder?>) -> Signal<MessageId?, NoError>
|
||||
func chatLocationInput(for location: ChatLocation, contextHolder: Atomic<ChatLocationContextHolder?>) -> EngineChatLocationInput
|
||||
func chatLocationOutgoingReadState(for location: ChatLocation, contextHolder: Atomic<ChatLocationContextHolder?>) -> Signal<EngineMessage.Id?, NoError>
|
||||
func chatLocationUnreadCount(for location: ChatLocation, contextHolder: Atomic<ChatLocationContextHolder?>) -> Signal<Int, NoError>
|
||||
func applyMaxReadIndex(for location: ChatLocation, contextHolder: Atomic<ChatLocationContextHolder?>, messageIndex: MessageIndex)
|
||||
|
||||
func scheduleGroupCall(peerId: PeerId, parentController: ViewController)
|
||||
func joinGroupCall(peerId: PeerId, invite: String?, requestJoinAsPeerId: ((@escaping (PeerId?) -> Void) -> Void)?, activeCall: EngineGroupCallDescription)
|
||||
func applyMaxReadIndex(for location: ChatLocation, contextHolder: Atomic<ChatLocationContextHolder?>, messageIndex: EngineMessage.Index)
|
||||
|
||||
func scheduleGroupCall(peerId: EnginePeer.Id, parentController: ViewController)
|
||||
func joinGroupCall(peerId: EnginePeer.Id, invite: String?, requestJoinAsPeerId: ((@escaping (EnginePeer.Id?) -> Void) -> Void)?, activeCall: EngineGroupCallDescription)
|
||||
func joinConferenceCall(call: JoinCallLinkInformation, isVideo: Bool, unmuteByDefault: Bool)
|
||||
func requestCall(peerId: PeerId, isVideo: Bool, completion: @escaping () -> Void)
|
||||
func requestCall(peerId: EnginePeer.Id, isVideo: Bool, completion: @escaping () -> Void)
|
||||
}
|
||||
|
||||
public struct AntiSpamBotConfiguration {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import Foundation
|
||||
import UIKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import TextFormat
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
|
|
@ -817,7 +816,7 @@ public enum ChatControllerSubject: Equatable {
|
|||
}
|
||||
}
|
||||
|
||||
case tag(MessageTags)
|
||||
case tag(EngineMessage.Tags)
|
||||
case message(id: MessageSubject, highlight: MessageHighlight?, timecode: Double?, setupReply: Bool)
|
||||
case scheduledMessages
|
||||
case pinnedMessages(id: EngineMessage.Id?)
|
||||
|
|
@ -1003,7 +1002,7 @@ public enum PeerInfoAvatarUploadStatus {
|
|||
}
|
||||
|
||||
public protocol PeerInfoScreen: ViewController {
|
||||
var peerId: PeerId { get }
|
||||
var peerId: EnginePeer.Id { get }
|
||||
var privacySettings: Promise<AccountPrivacySettings?> { get }
|
||||
var twoStepAuthData: Promise<TwoStepAuthData?> { get }
|
||||
var notificationExceptions: Promise<NotificationExceptionsList?> { get }
|
||||
|
|
@ -1021,7 +1020,7 @@ public protocol PeerInfoScreen: ViewController {
|
|||
func updateProfileVideo(_ image: UIImage, video: Any?, values: Any?, markup: UploadPeerPhotoMarkup?)
|
||||
}
|
||||
|
||||
public extension Peer {
|
||||
public extension EngineRawPeer {
|
||||
func canSetupAutoremoveTimeout(accountPeerId: EnginePeer.Id) -> Bool {
|
||||
if let _ = self as? TelegramSecretChat {
|
||||
return false
|
||||
|
|
@ -1157,19 +1156,19 @@ public enum FileMediaResourceMediaStatus: Equatable {
|
|||
public protocol ChatMessageItemNodeProtocol: ListViewItemNode {
|
||||
func makeProgress() -> Promise<Bool>?
|
||||
func targetReactionView(value: MessageReaction.Reaction) -> UIView?
|
||||
func targetForStoryTransition(id: StoryId) -> UIView?
|
||||
func targetForStoryTransition(id: EngineStoryId) -> UIView?
|
||||
func contentFrame() -> CGRect
|
||||
func matchesMessage(id: MessageId) -> Bool
|
||||
func matchesMessage(id: EngineMessage.Id) -> Bool
|
||||
func cancelInsertionAnimations()
|
||||
func messages() -> [Message]
|
||||
func messages() -> [EngineRawMessage]
|
||||
func updateHiddenMedia()
|
||||
}
|
||||
|
||||
public final class ChatControllerNavigationData: CustomViewControllerNavigationData {
|
||||
public let peerId: PeerId
|
||||
public let peerId: EnginePeer.Id
|
||||
public let threadId: Int64?
|
||||
|
||||
public init(peerId: PeerId, threadId: Int64?) {
|
||||
|
||||
public init(peerId: EnginePeer.Id, threadId: Int64?) {
|
||||
self.peerId = peerId
|
||||
self.threadId = threadId
|
||||
}
|
||||
|
|
@ -1212,8 +1211,8 @@ public enum ChatHistoryListSource {
|
|||
}
|
||||
|
||||
case `default`
|
||||
case custom(messages: Signal<([Message], Int32, Bool), NoError>, messageId: MessageId?, quote: Quote?, isSavedMusic: Bool, canReorder: Bool, loadMore: (() -> Void)?)
|
||||
case customView(historyView: Signal<(MessageHistoryView, ViewUpdateType), NoError>)
|
||||
case custom(messages: Signal<([EngineRawMessage], Int32, Bool), NoError>, messageId: EngineMessage.Id?, quote: Quote?, isSavedMusic: Bool, canReorder: Bool, loadMore: (() -> Void)?)
|
||||
case customView(historyView: Signal<(EngineRawMessageHistoryView, EngineViewUpdateType), NoError>)
|
||||
}
|
||||
|
||||
public enum ChatQuickReplyShortcutType {
|
||||
|
|
@ -1230,7 +1229,7 @@ public enum ChatCustomContentsKind: Equatable {
|
|||
|
||||
public protocol ChatCustomContentsProtocol: AnyObject {
|
||||
var kind: ChatCustomContentsKind { get }
|
||||
var historyView: Signal<(MessageHistoryView, ViewUpdateType), NoError> { get }
|
||||
var historyView: Signal<(EngineRawMessageHistoryView, EngineViewUpdateType), NoError> { get }
|
||||
var messageLimit: Int? { get }
|
||||
|
||||
func enqueueMessages(messages: [EnqueueMessage])
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import Foundation
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import UIKit
|
||||
|
|
@ -9,10 +8,10 @@ import UniversalMediaPlayer
|
|||
import RangeSet
|
||||
|
||||
public enum PeerMessagesMediaPlaylistId: Equatable, SharedMediaPlaylistId {
|
||||
case peer(PeerId)
|
||||
case recentActions(PeerId)
|
||||
case peer(EnginePeer.Id)
|
||||
case recentActions(EnginePeer.Id)
|
||||
case feed(Int32)
|
||||
case savedMusic(PeerId)
|
||||
case savedMusic(EnginePeer.Id)
|
||||
case custom
|
||||
|
||||
public func isEqual(to: SharedMediaPlaylistId) -> Bool {
|
||||
|
|
@ -24,11 +23,11 @@ public enum PeerMessagesMediaPlaylistId: Equatable, SharedMediaPlaylistId {
|
|||
}
|
||||
|
||||
public enum PeerMessagesPlaylistLocation: Equatable, SharedMediaPlaylistLocation {
|
||||
case messages(chatLocation: ChatLocation, tagMask: MessageTags, at: MessageId)
|
||||
case singleMessage(MessageId)
|
||||
case recentActions(Message)
|
||||
case messages(chatLocation: ChatLocation, tagMask: EngineMessage.Tags, at: EngineMessage.Id)
|
||||
case singleMessage(EngineMessage.Id)
|
||||
case recentActions(EngineRawMessage)
|
||||
case savedMusic(context: ProfileSavedMusicContext, at: Int32, canReorder: Bool)
|
||||
case custom(messages: Signal<([Message], Int32, Bool), NoError>, canReorder: Bool, at: MessageId, loadMore: (() -> Void)?, hidePanel: Bool)
|
||||
case custom(messages: Signal<([EngineRawMessage], Int32, Bool), NoError>, canReorder: Bool, at: EngineMessage.Id, loadMore: (() -> Void)?, hidePanel: Bool)
|
||||
|
||||
public var playlistId: PeerMessagesMediaPlaylistId {
|
||||
switch self {
|
||||
|
|
@ -62,14 +61,14 @@ public enum PeerMessagesPlaylistLocation: Equatable, SharedMediaPlaylistLocation
|
|||
context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: savedMusicContext.peerId))
|
||||
)
|
||||
|> map { state, peer in
|
||||
var messages: [Message] = []
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
var messages: [EngineRawMessage] = []
|
||||
var peers = EngineSimpleDictionary<EnginePeer.Id, EngineRawPeer>()
|
||||
if let peer {
|
||||
peers[peerId] = peer._asPeer()
|
||||
}
|
||||
for file in state.files {
|
||||
let stableId = UInt32(clamping: file.fileId.id % Int64(Int32.max))
|
||||
messages.append(Message(stableId: stableId, stableVersion: 0, id: MessageId(peerId: peerId, namespace: Namespaces.Message.Local, id: Int32(stableId)), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [], tags: [.music], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: nil, text: "", attributes: [], media: [file], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:]))
|
||||
messages.append(EngineRawMessage(stableId: stableId, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: Namespaces.Message.Local, id: Int32(stableId)), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [], tags: [.music], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: nil, text: "", attributes: [], media: [file], peers: peers, associatedMessages: EngineSimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:]))
|
||||
}
|
||||
var canLoadMore = false
|
||||
if case let .ready(canLoadMoreValue) = state.dataState {
|
||||
|
|
@ -78,7 +77,7 @@ public enum PeerMessagesPlaylistLocation: Equatable, SharedMediaPlaylistLocation
|
|||
return (messages, Int32(messages.count), canLoadMore)
|
||||
},
|
||||
canReorder: canReorder,
|
||||
at: MessageId(peerId: peerId, namespace: Namespaces.Message.Local, id: at),
|
||||
at: EngineMessage.Id(peerId: peerId, namespace: Namespaces.Message.Local, id: at),
|
||||
loadMore: { [weak savedMusicContext] in
|
||||
guard let savedMusicContext else {
|
||||
return
|
||||
|
|
@ -92,7 +91,7 @@ public enum PeerMessagesPlaylistLocation: Equatable, SharedMediaPlaylistLocation
|
|||
}
|
||||
}
|
||||
|
||||
public var messageId: MessageId? {
|
||||
public var messageId: EngineMessage.Id? {
|
||||
switch self {
|
||||
case let .messages(_, _, messageId), let .singleMessage(messageId), let .custom(_, _, messageId, _, _):
|
||||
return messageId
|
||||
|
|
@ -231,7 +230,7 @@ public protocol MediaManager: AnyObject {
|
|||
}
|
||||
|
||||
public enum GalleryHiddenMediaId: Hashable {
|
||||
case chat(AccountRecordId, MessageId, Media)
|
||||
case chat(AccountRecordId, EngineMessage.Id, EngineRawMedia)
|
||||
|
||||
public static func ==(lhs: GalleryHiddenMediaId, rhs: GalleryHiddenMediaId) -> Bool {
|
||||
switch lhs {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import AsyncDisplayKit
|
|||
import Display
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import MergeLists
|
||||
import HorizontalPeerItem
|
||||
|
|
@ -254,16 +253,16 @@ public final class ChatListSearchRecentPeersNode: ASDisplayNode {
|
|||
}
|
||||
)
|
||||
|> mapToSignal { peerViews -> Signal<([EnginePeer], [EnginePeer.Id: (Int32, Bool)], [EnginePeer.Id: EnginePeer.Presence]), NoError> in
|
||||
return stateManager.postbox.combinedView(keys: peerViews.map { item -> PostboxViewKey in
|
||||
let key = PostboxViewKey.unreadCounts(items: [UnreadMessageCountsItem.peer(id: item.peerId, handleThreads: true)])
|
||||
return stateManager.postbox.combinedView(keys: peerViews.map { item -> EngineRawPostboxViewKey in
|
||||
let key = EngineRawPostboxViewKey.unreadCounts(items: [EngineRawUnreadMessageCountsItem.peer(id: item.peerId, handleThreads: true)])
|
||||
return key
|
||||
})
|
||||
|> map { views -> [EnginePeer.Id: Int] in
|
||||
var result: [EnginePeer.Id: Int] = [:]
|
||||
for item in peerViews {
|
||||
let key = PostboxViewKey.unreadCounts(items: [UnreadMessageCountsItem.peer(id: item.peerId, handleThreads: true)])
|
||||
|
||||
if let view = views.views[key] as? UnreadMessageCountsView {
|
||||
let key = EngineRawPostboxViewKey.unreadCounts(items: [EngineRawUnreadMessageCountsItem.peer(id: item.peerId, handleThreads: true)])
|
||||
|
||||
if let view = views.views[key] as? EngineRawUnreadMessageCountsView {
|
||||
result[item.peerId] = Int(view.count(for: .peer(id: item.peerId, handleThreads: true)) ?? 0)
|
||||
} else {
|
||||
result[item.peerId] = 0
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import UIKit
|
|||
import SwiftSignalKit
|
||||
import ContextUI
|
||||
import AccountContext
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import Display
|
||||
import TelegramUIPreferences
|
||||
|
|
@ -17,11 +16,11 @@ import TelegramStringFormatting
|
|||
import ChatTimerScreen
|
||||
import NotificationPeerExceptionController
|
||||
|
||||
func archiveContextMenuItems(context: AccountContext, groupId: PeerGroupId, chatListController: ChatListControllerImpl?) -> Signal<[ContextMenuItem], NoError> {
|
||||
func archiveContextMenuItems(context: AccountContext, group: EngineChatList.Group, chatListController: ChatListControllerImpl?) -> Signal<[ContextMenuItem], NoError> {
|
||||
let presentationData = context.sharedContext.currentPresentationData.with({ $0 })
|
||||
let strings = presentationData.strings
|
||||
return combineLatest(
|
||||
context.engine.messages.unreadChatListPeerIds(groupId: EngineChatList.Group(groupId), filterPredicate: nil),
|
||||
context.engine.messages.unreadChatListPeerIds(groupId: group, filterPredicate: nil),
|
||||
context.engine.data.get(
|
||||
TelegramEngine.EngineData.Item.Configuration.ApplicationSpecificPreference(key: ApplicationSpecificPreferencesKeys.chatArchiveSettings)
|
||||
)
|
||||
|
|
@ -31,7 +30,7 @@ func archiveContextMenuItems(context: AccountContext, groupId: PeerGroupId, chat
|
|||
|
||||
if !unreadChatListPeerIds.isEmpty {
|
||||
items.append(.action(ContextMenuActionItem(text: strings.ChatList_Context_MarkAllAsRead, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/MarkAsRead"), color: theme.contextMenu.primaryColor) }, action: { _, f in
|
||||
let _ = (context.engine.messages.markAllChatsAsReadInteractively(items: [(groupId: EngineChatList.Group(groupId), filterPredicate: nil)])
|
||||
let _ = (context.engine.messages.markAllChatsAsReadInteractively(items: [(groupId: group, filterPredicate: nil)])
|
||||
|> deliverOnMainQueue).startStandalone(completed: {
|
||||
f(.default)
|
||||
})
|
||||
|
|
@ -54,7 +53,7 @@ enum ChatContextMenuSource {
|
|||
case search(ChatListSearchContextActionSource)
|
||||
}
|
||||
|
||||
func chatContextMenuItems(context: AccountContext, peerId: PeerId, promoInfo: ChatListNodeEntryPromoInfo?, source: ChatContextMenuSource, chatListController: ChatListControllerImpl?, joined: Bool) -> Signal<[ContextMenuItem], NoError> {
|
||||
func chatContextMenuItems(context: AccountContext, peerId: EnginePeer.Id, promoInfo: ChatListNodeEntryPromoInfo?, source: ChatContextMenuSource, chatListController: ChatListControllerImpl?, joined: Bool) -> Signal<[ContextMenuItem], NoError> {
|
||||
let presentationData = context.sharedContext.currentPresentationData.with({ $0 })
|
||||
let strings = presentationData.strings
|
||||
|
||||
|
|
@ -363,7 +362,7 @@ func chatContextMenuItems(context: AccountContext, peerId: PeerId, promoInfo: Ch
|
|||
}
|
||||
}
|
||||
|
||||
let archiveEnabled = !isSavedMessages && peerId != PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(777000)) && peerId == context.account.peerId
|
||||
let archiveEnabled = !isSavedMessages && peerId != EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(777000)) && peerId == context.account.peerId
|
||||
if let group = peerGroup {
|
||||
if archiveEnabled {
|
||||
let isArchived = group == .archive
|
||||
|
|
@ -587,7 +586,7 @@ func chatContextMenuItems(context: AccountContext, peerId: PeerId, promoInfo: Ch
|
|||
}
|
||||
}
|
||||
|
||||
public func chatForumTopicMenuItems(context: AccountContext, peerId: PeerId, threadId: Int64, isPinned: Bool?, isClosed: Bool?, chatListController: ViewController?, joined: Bool, canSelect: Bool, customEdit: ((ContextController) -> Void)? = nil, customPinUnpin: ((ContextController) -> Void)? = nil, reorder: (() -> Void)? = nil, onDeleted: (() -> Void)? = nil) -> Signal<[ContextMenuItem], NoError> {
|
||||
public func chatForumTopicMenuItems(context: AccountContext, peerId: EnginePeer.Id, threadId: Int64, isPinned: Bool?, isClosed: Bool?, chatListController: ViewController?, joined: Bool, canSelect: Bool, customEdit: ((ContextController) -> Void)? = nil, customPinUnpin: ((ContextController) -> Void)? = nil, reorder: (() -> Void)? = nil, onDeleted: (() -> Void)? = nil) -> Signal<[ContextMenuItem], NoError> {
|
||||
let presentationData = context.sharedContext.currentPresentationData.with({ $0 })
|
||||
let strings = presentationData.strings
|
||||
|
||||
|
|
@ -822,30 +821,30 @@ public func chatForumTopicMenuItems(context: AccountContext, peerId: PeerId, thr
|
|||
TelegramEngine.EngineData.Item.NotificationSettings.Global()
|
||||
)
|
||||
|> deliverOnMainQueue).startStandalone(next: { globalSettings in
|
||||
let updatePeerSound: (PeerId, PeerMessageSound) -> Signal<Void, NoError> = { peerId, sound in
|
||||
let updatePeerSound: (EnginePeer.Id, PeerMessageSound) -> Signal<Void, NoError> = { peerId, sound in
|
||||
return context.engine.peers.updatePeerNotificationSoundInteractive(peerId: peerId, threadId: threadId, sound: sound) |> deliverOnMainQueue
|
||||
}
|
||||
|
||||
let updatePeerNotificationInterval: (PeerId, Int32?) -> Signal<Void, NoError> = { peerId, muteInterval in
|
||||
let updatePeerNotificationInterval: (EnginePeer.Id, Int32?) -> Signal<Void, NoError> = { peerId, muteInterval in
|
||||
return context.engine.peers.updatePeerMuteSetting(peerId: peerId, threadId: threadId, muteInterval: muteInterval) |> deliverOnMainQueue
|
||||
}
|
||||
|
||||
let updatePeerDisplayPreviews: (PeerId, PeerNotificationDisplayPreviews) -> Signal<Void, NoError> = {
|
||||
let updatePeerDisplayPreviews: (EnginePeer.Id, PeerNotificationDisplayPreviews) -> Signal<Void, NoError> = {
|
||||
peerId, displayPreviews in
|
||||
return context.engine.peers.updatePeerDisplayPreviewsSetting(peerId: peerId, threadId: threadId, displayPreviews: displayPreviews) |> deliverOnMainQueue
|
||||
}
|
||||
|
||||
let updatePeerStoriesMuted: (PeerId, PeerStoryNotificationSettings.Mute) -> Signal<Void, NoError> = {
|
||||
let updatePeerStoriesMuted: (EnginePeer.Id, PeerStoryNotificationSettings.Mute) -> Signal<Void, NoError> = {
|
||||
peerId, mute in
|
||||
return context.engine.peers.updatePeerStoriesMutedSetting(peerId: peerId, mute: mute) |> deliverOnMainQueue
|
||||
}
|
||||
|
||||
let updatePeerStoriesHideSender: (PeerId, PeerStoryNotificationSettings.HideSender) -> Signal<Void, NoError> = {
|
||||
let updatePeerStoriesHideSender: (EnginePeer.Id, PeerStoryNotificationSettings.HideSender) -> Signal<Void, NoError> = {
|
||||
peerId, hideSender in
|
||||
return context.engine.peers.updatePeerStoriesHideSenderSetting(peerId: peerId, hideSender: hideSender) |> deliverOnMainQueue
|
||||
}
|
||||
|
||||
let updatePeerStorySound: (PeerId, PeerMessageSound) -> Signal<Void, NoError> = { peerId, sound in
|
||||
let updatePeerStorySound: (EnginePeer.Id, PeerMessageSound) -> Signal<Void, NoError> = { peerId, sound in
|
||||
return context.engine.peers.updatePeerStorySoundInteractive(peerId: peerId, sound: sound) |> deliverOnMainQueue
|
||||
}
|
||||
|
||||
|
|
@ -979,11 +978,9 @@ public func savedMessagesPeerMenuItems(context: AccountContext, threadId: Int64,
|
|||
|
||||
return combineLatest(
|
||||
context.engine.data.get(
|
||||
TelegramEngine.EngineData.Item.Peer.Peer(id: PeerId(threadId))
|
||||
TelegramEngine.EngineData.Item.Peer.Peer(id: EnginePeer.Id(threadId))
|
||||
),
|
||||
context.account.postbox.transaction { transaction -> [Int64] in
|
||||
return transaction.getPeerPinnedThreads(peerId: context.account.peerId)
|
||||
}
|
||||
context.engine.peers.getForumChannelPinnedTopics(id: context.account.peerId)
|
||||
)
|
||||
|> mapToSignal { [weak parentController] peer, pinnedThreadIds -> Signal<[ContextMenuItem], NoError> in
|
||||
var items: [ContextMenuItem] = []
|
||||
|
|
@ -1014,7 +1011,7 @@ public func savedMessagesPeerMenuItems(context: AccountContext, threadId: Int64,
|
|||
})))
|
||||
|
||||
items.append(.action(ContextMenuActionItem(text: strings.ChatList_Context_Delete, textColor: .destructive, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Delete"), color: theme.contextMenu.destructiveColor) }, action: { _, f in
|
||||
deletePeerChat(PeerId(threadId))
|
||||
deletePeerChat(EnginePeer.Id(threadId))
|
||||
f(.default)
|
||||
})))
|
||||
|
||||
|
|
|
|||
|
|
@ -1883,7 +1883,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||
case let .groupReference(groupReference):
|
||||
let chatListController = ChatListControllerImpl(context: strongSelf.context, location: .chatList(groupId: groupReference.groupId), controlsHistoryPreload: false, hideNetworkActivityStatus: true, previewing: true, enableDebugActions: false)
|
||||
chatListController.navigationPresentation = .master
|
||||
let contextController = makeContextController(presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatListController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: archiveContextMenuItems(context: strongSelf.context, groupId: groupReference.groupId._asGroup(), chatListController: strongSelf) |> map { ContextController.Items(content: .list($0)) }, gesture: gesture)
|
||||
let contextController = makeContextController(presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatListController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: archiveContextMenuItems(context: strongSelf.context, group: groupReference.groupId, chatListController: strongSelf) |> map { ContextController.Items(content: .list($0)) }, gesture: gesture)
|
||||
strongSelf.presentInGlobalOverlay(contextController)
|
||||
case let .peer(peerData):
|
||||
let peer = peerData.peer
|
||||
|
|
@ -6833,7 +6833,7 @@ private final class ChatListLocationContext {
|
|||
return (nil, value)
|
||||
}
|
||||
} else {
|
||||
return context.peerChannelMemberCategoriesContextsManager.recentOnlineSmall(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId)
|
||||
return context.peerChannelMemberCategoriesContextsManager.recentOnlineSmall(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId)
|
||||
|> map { value -> (total: Int32?, recent: Int32?) in
|
||||
return (value.total, value.recent)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import UIKit
|
|||
import Display
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import AccountContext
|
||||
import ContextUI
|
||||
|
|
@ -20,17 +19,17 @@ private let mediaBadgeBackgroundColor = UIColor(white: 0.0, alpha: 0.6)
|
|||
private let mediaBadgeTextColor = UIColor.white
|
||||
|
||||
private final class VisualMediaItemInteraction {
|
||||
let openMessage: (Message) -> Void
|
||||
let openMessageContextActions: (Message, ASDisplayNode, CGRect, ContextGesture?) -> Void
|
||||
let toggleSelection: (MessageId, Bool) -> Void
|
||||
|
||||
var hiddenMedia: [MessageId: [Media]] = [:]
|
||||
var selectedMessageIds: Set<MessageId>?
|
||||
|
||||
let openMessage: (EngineRawMessage) -> Void
|
||||
let openMessageContextActions: (EngineRawMessage, ASDisplayNode, CGRect, ContextGesture?) -> Void
|
||||
let toggleSelection: (EngineMessage.Id, Bool) -> Void
|
||||
|
||||
var hiddenMedia: [EngineMessage.Id: [EngineRawMedia]] = [:]
|
||||
var selectedMessageIds: Set<EngineMessage.Id>?
|
||||
|
||||
init(
|
||||
openMessage: @escaping (Message) -> Void,
|
||||
openMessageContextActions: @escaping (Message, ASDisplayNode, CGRect, ContextGesture?) -> Void,
|
||||
toggleSelection: @escaping (MessageId, Bool) -> Void
|
||||
openMessage: @escaping (EngineRawMessage) -> Void,
|
||||
openMessageContextActions: @escaping (EngineRawMessage, ASDisplayNode, CGRect, ContextGesture?) -> Void,
|
||||
toggleSelection: @escaping (EngineMessage.Id, Bool) -> Void
|
||||
) {
|
||||
self.openMessage = openMessage
|
||||
self.openMessageContextActions = openMessageContextActions
|
||||
|
|
@ -53,9 +52,9 @@ private final class VisualMediaItemNode: ASDisplayNode {
|
|||
|
||||
private let fetchStatusDisposable = MetaDisposable()
|
||||
private let fetchDisposable = MetaDisposable()
|
||||
private var resourceStatus: MediaResourceStatus?
|
||||
private var resourceStatus: EngineMediaResourceStatus?
|
||||
|
||||
private var item: (VisualMediaItem, Media?, CGSize, CGSize?)?
|
||||
private var item: (VisualMediaItem, EngineRawMedia?, CGSize, CGSize?)?
|
||||
private var theme: PresentationTheme?
|
||||
|
||||
private var hasVisibility: Bool = false
|
||||
|
|
@ -117,7 +116,7 @@ private final class VisualMediaItemNode: ASDisplayNode {
|
|||
if let (gesture, _) = recognizer.lastRecognizedGestureAndLocation {
|
||||
if case .tap = gesture {
|
||||
if let _ = self.item {
|
||||
var media: Media?
|
||||
var media: EngineRawMedia?
|
||||
for value in message.media {
|
||||
if let image = value as? TelegramMediaImage {
|
||||
media = image
|
||||
|
|
@ -150,7 +149,7 @@ private final class VisualMediaItemNode: ASDisplayNode {
|
|||
return
|
||||
}
|
||||
|
||||
var media: Media?
|
||||
var media: EngineRawMedia?
|
||||
for value in message.media {
|
||||
if let image = value as? TelegramMediaImage {
|
||||
media = image
|
||||
|
|
@ -185,7 +184,7 @@ private final class VisualMediaItemNode: ASDisplayNode {
|
|||
return
|
||||
}
|
||||
self.theme = theme
|
||||
var media: Media?
|
||||
var media: EngineRawMedia?
|
||||
if let message = item.message {
|
||||
for value in message.media {
|
||||
if let image = value as? TelegramMediaImage {
|
||||
|
|
@ -404,11 +403,11 @@ private final class VisualMediaItemNode: ASDisplayNode {
|
|||
|
||||
private final class VisualMediaItem {
|
||||
let index: UInt32?
|
||||
let message: Message?
|
||||
let message: EngineRawMessage?
|
||||
let dimensions: CGSize
|
||||
let aspectRatio: CGFloat
|
||||
|
||||
init(message: Message, index: UInt32?) {
|
||||
|
||||
init(message: EngineRawMessage, index: UInt32?) {
|
||||
self.index = index
|
||||
self.message = message
|
||||
|
||||
|
|
@ -637,7 +636,7 @@ final class ChatListSearchMediaNode: ASDisplayNode, ASScrollViewDelegate {
|
|||
public var beganInteractiveDragging: (() -> Void)?
|
||||
public var loadMore: (() -> Void)?
|
||||
|
||||
init(context: AccountContext, contentType: ContentType, openMessage: @escaping (Message, ChatControllerInteractionOpenMessageMode) -> Void, messageContextAction: @escaping (Message, ASDisplayNode?, CGRect?, UIGestureRecognizer?) -> Void, toggleMessageSelection: @escaping (MessageId, Bool) -> Void) {
|
||||
init(context: AccountContext, contentType: ContentType, openMessage: @escaping (EngineRawMessage, ChatControllerInteractionOpenMessageMode) -> Void, messageContextAction: @escaping (EngineRawMessage, ASDisplayNode?, CGRect?, UIGestureRecognizer?) -> Void, toggleMessageSelection: @escaping (EngineMessage.Id, Bool) -> Void) {
|
||||
self.context = context
|
||||
self.contentType = contentType
|
||||
|
||||
|
|
@ -675,7 +674,7 @@ final class ChatListSearchMediaNode: ASDisplayNode, ASScrollViewDelegate {
|
|||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
var hiddenMedia: [MessageId: [Media]] = [:]
|
||||
var hiddenMedia: [EngineMessage.Id: [EngineRawMedia]] = [:]
|
||||
for id in ids {
|
||||
if case let .chat(accountId, messageId, media) = id, accountId == strongSelf.context.account.id {
|
||||
hiddenMedia[messageId] = [media]
|
||||
|
|
@ -694,7 +693,7 @@ final class ChatListSearchMediaNode: ASDisplayNode, ASScrollViewDelegate {
|
|||
self.animationTimer?.invalidate()
|
||||
}
|
||||
|
||||
func updateHistory(entries: [ChatListSearchEntry]?, totalCount: Int32, updateType: ViewUpdateType) {
|
||||
func updateHistory(entries: [ChatListSearchEntry]?, totalCount: Int32, updateType: EngineViewUpdateType) {
|
||||
switch updateType {
|
||||
case .FillHole:
|
||||
break
|
||||
|
|
@ -733,7 +732,7 @@ final class ChatListSearchMediaNode: ASDisplayNode, ASScrollViewDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
func findLoadedMessage(id: MessageId) -> Message? {
|
||||
func findLoadedMessage(id: EngineMessage.Id) -> EngineRawMessage? {
|
||||
for item in self.mediaItems {
|
||||
if item.message?.id == id {
|
||||
return item.message
|
||||
|
|
@ -754,7 +753,7 @@ final class ChatListSearchMediaNode: ASDisplayNode, ASScrollViewDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
func transitionNodeForGallery(messageId: MessageId, media: Media) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
func transitionNodeForGallery(messageId: EngineMessage.Id, media: EngineRawMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
for item in self.mediaItems {
|
||||
if let message = item.message, message.id == messageId {
|
||||
if let itemNode = self.visibleMediaItems[message.stableId] {
|
||||
|
|
@ -770,7 +769,7 @@ final class ChatListSearchMediaNode: ASDisplayNode, ASScrollViewDelegate {
|
|||
self.scrollNode.view.addSubview(view)
|
||||
}
|
||||
|
||||
var selectedMessageIds: Set<MessageId>? {
|
||||
var selectedMessageIds: Set<EngineMessage.Id>? {
|
||||
didSet {
|
||||
self.itemInteraction.selectedMessageIds = self.selectedMessageIds
|
||||
}
|
||||
|
|
@ -865,7 +864,7 @@ final class ChatListSearchMediaNode: ASDisplayNode, ASScrollViewDelegate {
|
|||
|
||||
let (minVisibleIndex, maxVisibleIndex) = itemsLayout.visibleRange(rect: visibleRect)
|
||||
|
||||
var headerItem: Message?
|
||||
var headerItem: EngineRawMessage?
|
||||
|
||||
var validIds = Set<UInt32>()
|
||||
if minVisibleIndex <= maxVisibleIndex {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import SwiftSignalKit
|
|||
import AsyncDisplayKit
|
||||
import TelegramPresentationData
|
||||
import AccountContext
|
||||
import Postbox
|
||||
import TelegramUIPreferences
|
||||
import TelegramCore
|
||||
|
||||
|
|
@ -13,10 +12,10 @@ public func chatListFilterItems(context: AccountContext) -> Signal<(Int, [(ChatL
|
|||
return context.engine.peers.updatedChatListFilters()
|
||||
|> distinctUntilChanged
|
||||
|> mapToSignal { filters -> Signal<(Int, [(ChatListFilter, Int, Bool)]), NoError> in
|
||||
var unreadCountItems: [UnreadMessageCountsItem] = []
|
||||
var unreadCountItems: [EngineRawUnreadMessageCountsItem] = []
|
||||
unreadCountItems.append(.totalInGroup(.root))
|
||||
var additionalPeerIds = Set<PeerId>()
|
||||
var additionalGroupIds = Set<PeerGroupId>()
|
||||
var additionalPeerIds = Set<EnginePeer.Id>()
|
||||
var additionalGroupIds = Set<EnginePeerGroupId>()
|
||||
for case let .filter(_, _, _, data) in filters {
|
||||
additionalPeerIds.formUnion(data.includePeers.peers)
|
||||
additionalPeerIds.formUnion(data.excludePeers)
|
||||
|
|
@ -33,9 +32,9 @@ public func chatListFilterItems(context: AccountContext) -> Signal<(Int, [(ChatL
|
|||
unreadCountItems.append(.totalInGroup(groupId))
|
||||
}
|
||||
|
||||
let globalNotificationsKey: PostboxViewKey = .preferences(keys: Set([PreferencesKeys.globalNotifications]))
|
||||
let unreadKey: PostboxViewKey = .unreadCounts(items: unreadCountItems)
|
||||
var keys: [PostboxViewKey] = []
|
||||
let globalNotificationsKey: EngineRawPostboxViewKey = .preferences(keys: Set([PreferencesKeys.globalNotifications]))
|
||||
let unreadKey: EngineRawPostboxViewKey = .unreadCounts(items: unreadCountItems)
|
||||
var keys: [EngineRawPostboxViewKey] = []
|
||||
keys.append(globalNotificationsKey)
|
||||
keys.append(unreadKey)
|
||||
for peerId in additionalPeerIds {
|
||||
|
|
@ -44,12 +43,12 @@ public func chatListFilterItems(context: AccountContext) -> Signal<(Int, [(ChatL
|
|||
|
||||
return context.account.postbox.combinedView(keys: keys)
|
||||
|> map { view -> (Int, [(ChatListFilter, Int, Bool)]) in
|
||||
guard let unreadCounts = view.views[unreadKey] as? UnreadMessageCountsView else {
|
||||
guard let unreadCounts = view.views[unreadKey] as? EngineRawUnreadMessageCountsView else {
|
||||
return (0, [])
|
||||
}
|
||||
|
||||
var globalNotificationSettings: GlobalNotificationSettingsSet
|
||||
if let settingsView = view.views[globalNotificationsKey] as? PreferencesView, let settings = settingsView.values[PreferencesKeys.globalNotifications]?.get(GlobalNotificationSettings.self) {
|
||||
if let settingsView = view.views[globalNotificationsKey] as? EngineRawPreferencesView, let settings = settingsView.values[PreferencesKeys.globalNotifications]?.get(GlobalNotificationSettings.self) {
|
||||
globalNotificationSettings = settings.effective
|
||||
} else {
|
||||
globalNotificationSettings = GlobalNotificationSettings.defaultSettings.effective
|
||||
|
|
@ -57,9 +56,9 @@ public func chatListFilterItems(context: AccountContext) -> Signal<(Int, [(ChatL
|
|||
|
||||
var result: [(ChatListFilter, Int, Bool)] = []
|
||||
|
||||
var peerTagAndCount: [PeerId: (PeerSummaryCounterTags, Int, Bool, PeerGroupId?, Bool)] = [:]
|
||||
var peerTagAndCount: [EnginePeer.Id: (EnginePeerSummaryCounterTags, Int, Bool, EnginePeerGroupId?, Bool)] = [:]
|
||||
|
||||
var totalStates: [PeerGroupId: ChatListTotalUnreadState] = [:]
|
||||
var totalStates: [EnginePeerGroupId: EngineChatListTotalUnreadState] = [:]
|
||||
for entry in unreadCounts.entries {
|
||||
switch entry {
|
||||
case let .total(_, state):
|
||||
|
|
@ -68,7 +67,7 @@ public func chatListFilterItems(context: AccountContext) -> Signal<(Int, [(ChatL
|
|||
totalStates[groupId] = state
|
||||
case let .peer(peerId, state):
|
||||
if let state = state, state.isUnread {
|
||||
if let peerView = view.views[.basicPeer(peerId)] as? BasicPeerView, let peer = peerView.peer {
|
||||
if let peerView = view.views[.basicPeer(peerId)] as? EngineRawBasicPeerView, let peer = peerView.peer {
|
||||
let tag = context.account.postbox.seedConfiguration.peerSummaryCounterTags(peer, peerView.isContact)
|
||||
|
||||
var peerCount = Int(state.count)
|
||||
|
|
@ -113,7 +112,7 @@ public func chatListFilterItems(context: AccountContext) -> Signal<(Int, [(ChatL
|
|||
var count = 0
|
||||
var unmutedUnreadCount = 0
|
||||
if case let .filter(_, _, _, data) = filter {
|
||||
var tags: [PeerSummaryCounterTags] = []
|
||||
var tags: [EnginePeerSummaryCounterTags] = []
|
||||
if data.categories.contains(.contacts) {
|
||||
tags.append(.contact)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
|
|
@ -14,13 +13,13 @@ import UndoUI
|
|||
import StickerResources
|
||||
|
||||
public final class TrendingPaneInteraction {
|
||||
public let installPack: (ItemCollectionInfo) -> Void
|
||||
public let openPack: (ItemCollectionInfo) -> Void
|
||||
public let installPack: (EngineRawItemCollectionInfo) -> Void
|
||||
public let openPack: (EngineRawItemCollectionInfo) -> Void
|
||||
public let getItemIsPreviewed: (StickerPackItem) -> Bool
|
||||
public let openSearch: () -> Void
|
||||
public let itemContext = StickerPaneSearchGlobalItemContext()
|
||||
|
||||
public init(installPack: @escaping (ItemCollectionInfo) -> Void, openPack: @escaping (ItemCollectionInfo) -> Void, getItemIsPreviewed: @escaping (StickerPackItem) -> Bool, openSearch: @escaping () -> Void) {
|
||||
|
||||
public init(installPack: @escaping (EngineRawItemCollectionInfo) -> Void, openPack: @escaping (EngineRawItemCollectionInfo) -> Void, getItemIsPreviewed: @escaping (StickerPackItem) -> Bool, openSearch: @escaping () -> Void) {
|
||||
self.installPack = installPack
|
||||
self.openPack = openPack
|
||||
self.getItemIsPreviewed = getItemIsPreviewed
|
||||
|
|
@ -49,7 +48,7 @@ public final class TrendingPanePackEntry: Identifiable, Comparable {
|
|||
self.topSeparator = topSeparator
|
||||
}
|
||||
|
||||
public var stableId: ItemCollectionId {
|
||||
public var stableId: EngineItemCollectionId {
|
||||
return self.info.id
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +98,7 @@ public final class TrendingPanePackEntry: Identifiable, Comparable {
|
|||
|
||||
private enum TrendingPaneEntryId: Hashable {
|
||||
case search
|
||||
case pack(ItemCollectionId)
|
||||
case pack(EngineItemCollectionId)
|
||||
}
|
||||
|
||||
private enum TrendingPaneEntry: Identifiable, Comparable {
|
||||
|
|
@ -175,7 +174,7 @@ private func preparedTransition(from fromEntries: [TrendingPaneEntry], to toEntr
|
|||
return TrendingPaneTransition(deletions: deletions, insertions: insertions, updates: updates, initial: initial)
|
||||
}
|
||||
|
||||
private func trendingPaneEntries(trendingEntries: [FeaturedStickerPackItem], installedPacks: Set<ItemCollectionId>, theme: PresentationTheme, strings: PresentationStrings, isPane: Bool) -> [TrendingPaneEntry] {
|
||||
private func trendingPaneEntries(trendingEntries: [FeaturedStickerPackItem], installedPacks: Set<EngineItemCollectionId>, theme: PresentationTheme, strings: PresentationStrings, isPane: Bool) -> [TrendingPaneEntry] {
|
||||
var result: [TrendingPaneEntry] = []
|
||||
var index = 0
|
||||
if isPane {
|
||||
|
|
@ -192,12 +191,12 @@ private func trendingPaneEntries(trendingEntries: [FeaturedStickerPackItem], ins
|
|||
|
||||
public final class ChatMediaInputTrendingPane: ChatMediaInputPane {
|
||||
public final class Interaction {
|
||||
let sendSticker: (FileMediaReference, Bool, Bool, String?, Bool, UIView?, CGRect?, CALayer?, [ItemCollectionId]) -> Bool
|
||||
let sendSticker: (FileMediaReference, Bool, Bool, String?, Bool, UIView?, CGRect?, CALayer?, [EngineItemCollectionId]) -> Bool
|
||||
let presentController: (ViewController, Any?) -> Void
|
||||
let getNavigationController: () -> NavigationController?
|
||||
|
||||
|
||||
public init(
|
||||
sendSticker: @escaping (FileMediaReference, Bool, Bool, String?, Bool, UIView?, CGRect?, CALayer?, [ItemCollectionId]) -> Bool,
|
||||
sendSticker: @escaping (FileMediaReference, Bool, Bool, String?, Bool, UIView?, CGRect?, CALayer?, [EngineItemCollectionId]) -> Bool,
|
||||
presentController: @escaping (ViewController, Any?) -> Void,
|
||||
getNavigationController: @escaping () -> NavigationController?
|
||||
) {
|
||||
|
|
@ -388,19 +387,15 @@ public final class ChatMediaInputTrendingPane: ChatMediaInputPane {
|
|||
let previousEntries = Atomic<[TrendingPaneEntry]?>(value: nil)
|
||||
let context = self.context
|
||||
let forceTheme = self.forceTheme
|
||||
self.disposable = (combineLatest(context.account.viewTracker.featuredStickerPacks(), context.account.postbox.combinedView(keys: [.itemCollectionInfos(namespaces: [Namespaces.ItemCollection.CloudStickerPacks])]), context.sharedContext.presentationData)
|
||||
|> map { trendingEntries, view, presentationData -> TrendingPaneTransition in
|
||||
self.disposable = (combineLatest(context.account.viewTracker.featuredStickerPacks(), context.engine.data.subscribe(TelegramEngine.EngineData.Item.ItemCollections.InstalledPackInfos(namespace: Namespaces.ItemCollection.CloudStickerPacks)), context.sharedContext.presentationData)
|
||||
|> map { trendingEntries, packsEntries, presentationData -> TrendingPaneTransition in
|
||||
var presentationData = presentationData
|
||||
if let forceTheme {
|
||||
presentationData = presentationData.withUpdated(theme: forceTheme)
|
||||
}
|
||||
var installedPacks = Set<ItemCollectionId>()
|
||||
if let stickerPacksView = view.views[.itemCollectionInfos(namespaces: [Namespaces.ItemCollection.CloudStickerPacks])] as? ItemCollectionInfosView {
|
||||
if let packsEntries = stickerPacksView.entriesByNamespace[Namespaces.ItemCollection.CloudStickerPacks] {
|
||||
for entry in packsEntries {
|
||||
installedPacks.insert(entry.id)
|
||||
}
|
||||
}
|
||||
var installedPacks = Set<EngineItemCollectionId>()
|
||||
for entry in packsEntries {
|
||||
installedPacks.insert(entry.id)
|
||||
}
|
||||
let entries = trendingPaneEntries(trendingEntries: trendingEntries, installedPacks: installedPacks, theme: presentationData.theme, strings: presentationData.strings, isPane: isPane)
|
||||
let previous = previousEntries.swap(entries)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import Photos
|
||||
|
|
@ -49,7 +48,7 @@ private let cloudFetchIcon = generateTintedImage(image: UIImage(bundleImageName:
|
|||
|
||||
enum ChatItemGalleryFooterContent: Equatable {
|
||||
case info
|
||||
case fetch(status: MediaResourceStatus, seekable: Bool)
|
||||
case fetch(status: EngineMediaResource.FetchStatus, seekable: Bool)
|
||||
case playback(paused: Bool, seekable: Bool)
|
||||
|
||||
static func ==(lhs: ChatItemGalleryFooterContent, rhs: ChatItemGalleryFooterContent) -> Bool {
|
||||
|
|
@ -80,11 +79,11 @@ enum ChatItemGalleryFooterContentTapAction {
|
|||
case none
|
||||
case url(url: String, concealed: Bool)
|
||||
case textMention(String)
|
||||
case peerMention(PeerId, String)
|
||||
case peerMention(EnginePeer.Id, String)
|
||||
case botCommand(String)
|
||||
case hashtag(String?, String)
|
||||
case instantPage
|
||||
case call(PeerId)
|
||||
case call(EnginePeer.Id)
|
||||
case openMessage
|
||||
case ignore
|
||||
}
|
||||
|
|
@ -169,8 +168,8 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScroll
|
|||
|
||||
private var currentMessageText: NSAttributedString?
|
||||
|
||||
private var currentMessage: Message?
|
||||
private var currentWebPageAndMedia: (TelegramMediaWebpage, Media)?
|
||||
private var currentMessage: EngineRawMessage?
|
||||
private var currentWebPageAndMedia: (TelegramMediaWebpage, EngineRawMedia)?
|
||||
private var mediaSubject: GalleryMediaSubject?
|
||||
private let messageContextDisposable = MetaDisposable()
|
||||
|
||||
|
|
@ -208,7 +207,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScroll
|
|||
private var currentSpeechHolder: SpeechSynthesizerHolder?
|
||||
|
||||
var performAction: ((GalleryControllerInteractionTapAction) -> Void)?
|
||||
var openActionOptions: ((GalleryControllerInteractionTapAction, Message) -> Void)?
|
||||
var openActionOptions: ((GalleryControllerInteractionTapAction, EngineRawMessage) -> Void)?
|
||||
|
||||
private var isAd: Bool {
|
||||
if self.currentMessage?.adAttribute != nil {
|
||||
|
|
@ -846,7 +845,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScroll
|
|||
}
|
||||
}
|
||||
|
||||
func setMessage(_ message: Message, mediaSubject: GalleryMediaSubject? = nil, displayInfo: Bool = true, translateToLanguage: String? = nil, peerIsCopyProtected: Bool = false, displayPictureInPictureButton: Bool = false, settingsButtonState: SettingsButtonState? = nil, displayTextRecognitionButton: Bool = false, displayStickersButton: Bool = false, animated: Bool = false) {
|
||||
func setMessage(_ message: EngineRawMessage, mediaSubject: GalleryMediaSubject? = nil, displayInfo: Bool = true, translateToLanguage: String? = nil, peerIsCopyProtected: Bool = false, displayPictureInPictureButton: Bool = false, settingsButtonState: SettingsButtonState? = nil, displayTextRecognitionButton: Bool = false, displayStickersButton: Bool = false, animated: Bool = false) {
|
||||
self.currentMessage = message
|
||||
self.mediaSubject = mediaSubject
|
||||
|
||||
|
|
@ -1141,7 +1140,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScroll
|
|||
}
|
||||
}
|
||||
|
||||
func setWebPage(_ webPage: TelegramMediaWebpage, media: Media) {
|
||||
func setWebPage(_ webPage: TelegramMediaWebpage, media: EngineRawMedia) {
|
||||
self.currentWebPageAndMedia = (webPage, media)
|
||||
}
|
||||
|
||||
|
|
@ -1665,7 +1664,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScroll
|
|||
var items: [ActionSheetItem] = []
|
||||
var personalPeerName: String?
|
||||
var isChannel = false
|
||||
let peerId: PeerId = messages[0].id.peerId
|
||||
let peerId: EnginePeer.Id = messages[0].id.peerId
|
||||
if let user = messages[0].peers[messages[0].id.peerId] as? TelegramUser {
|
||||
personalPeerName = EnginePeer(user).compactDisplayTitle
|
||||
} else if let channel = messages[0].peers[messages[0].id.peerId] as? TelegramChannel, case .broadcast = channel.info {
|
||||
|
|
@ -1743,7 +1742,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScroll
|
|||
for message in messages {
|
||||
var currentKind = messageContentKind(contentSettings: strongSelf.context.currentContentSettings.with { $0 }, message: message, strings: presentationData.strings, nameDisplayOrder: presentationData.nameDisplayOrder, dateTimeFormat: presentationData.dateTimeFormat, accountPeerId: strongSelf.context.account.peerId)
|
||||
if case .poll = currentKind, let poll = message.media.first(where: { $0 is TelegramMediaPoll }) as? TelegramMediaPoll {
|
||||
var media: Media?
|
||||
var media: EngineRawMedia?
|
||||
switch strongSelf.mediaSubject {
|
||||
case .pollDescription:
|
||||
media = poll.attachedMedia
|
||||
|
|
@ -1993,7 +1992,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScroll
|
|||
}
|
||||
}
|
||||
|
||||
let shareAction: ([Message]) -> Void = { messages in
|
||||
let shareAction: ([EngineRawMessage]) -> Void = { messages in
|
||||
if let strongSelf = self {
|
||||
let shareController = strongSelf.context.sharedContext.makeShareController(context: strongSelf.context, params: ShareControllerParams(subject: .messages(messages), preferredAction: preferredAction, forceTheme: forceTheme, actionCompleted: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
|
|
|
|||
|
|
@ -1860,7 +1860,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
if item.content is HLSVideoContent {
|
||||
footerContent = .playback(paused: true, seekable: seekable)
|
||||
} else {
|
||||
footerContent = .fetch(status: fetchStatus, seekable: seekable)
|
||||
footerContent = .fetch(status: EngineMediaResource.FetchStatus(fetchStatus), seekable: seekable)
|
||||
}
|
||||
} else {
|
||||
footerContent = .info
|
||||
|
|
@ -3016,7 +3016,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||
let baseNavigationController = self.baseNavigationController()
|
||||
let mediaManager = self.context.sharedContext.mediaManager
|
||||
var expandImpl: (() -> Void)?
|
||||
let overlayNode = OverlayUniversalVideoNode(context: self.context, postbox: self.context.account.postbox, audioSession: context.sharedContext.mediaManager.audioSession, manager: context.sharedContext.mediaManager.universalVideoManager, content: item.content, expand: {
|
||||
let overlayNode = OverlayUniversalVideoNode(context: self.context, audioSession: context.sharedContext.mediaManager.audioSession, manager: context.sharedContext.mediaManager.universalVideoManager, content: item.content, expand: {
|
||||
expandImpl?()
|
||||
}, close: { [weak mediaManager] in
|
||||
mediaManager?.setOverlayVideoNode(nil)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import Foundation
|
||||
import UIKit
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import AccountContext
|
||||
|
||||
|
|
@ -20,11 +19,11 @@ final class HashtagSearchGlobalChatContents: ChatCustomContentsProtocol {
|
|||
private let publicPosts: Bool
|
||||
private var currentSearchState: SearchMessagesState?
|
||||
|
||||
private(set) var mergedHistoryView: MessageHistoryView?
|
||||
private var sourceHistoryView: MessageHistoryView?
|
||||
|
||||
private(set) var mergedHistoryView: EngineRawMessageHistoryView?
|
||||
private var sourceHistoryView: EngineRawMessageHistoryView?
|
||||
|
||||
private var historyViewDisposable: Disposable?
|
||||
let historyViewStream = ValuePipe<(MessageHistoryView, ViewUpdateType)>()
|
||||
let historyViewStream = ValuePipe<(EngineRawMessageHistoryView, EngineViewUpdateType)>()
|
||||
private var nextUpdateIsHoleFill: Bool = false
|
||||
|
||||
var hashtagSearchResultsUpdate: ((SearchMessagesResult, SearchMessagesState)) -> Void = { _ in }
|
||||
|
|
@ -64,9 +63,9 @@ final class HashtagSearchGlobalChatContents: ChatCustomContentsProtocol {
|
|||
return
|
||||
}
|
||||
|
||||
let updateType: ViewUpdateType = .Initial
|
||||
|
||||
let historyView = MessageHistoryView(tag: nil, namespaces: .just(Set([Namespaces.Message.Cloud])), entries: result.0.messages.reversed().map { MessageHistoryEntry(message: $0, isRead: false, location: nil, monthLocation: nil, attributes: MutableMessageHistoryEntryAttributes(authorIsContact: false)) }, holeEarlier: !result.0.completed, holeLater: false, isLoading: false)
|
||||
let updateType: EngineViewUpdateType = .Initial
|
||||
|
||||
let historyView = EngineRawMessageHistoryView(tag: nil, namespaces: .just(Set([Namespaces.Message.Cloud])), entries: result.0.messages.reversed().map { EngineRawMessageHistoryEntry(message: $0, isRead: false, location: nil, monthLocation: nil, attributes: EngineRawMutableMessageHistoryEntryAttributes(authorIsContact: false)) }, holeEarlier: !result.0.completed, holeLater: false, isLoading: false)
|
||||
self.sourceHistoryView = historyView
|
||||
self.updateHistoryView(updateType: updateType)
|
||||
|
||||
|
|
@ -83,11 +82,11 @@ final class HashtagSearchGlobalChatContents: ChatCustomContentsProtocol {
|
|||
})
|
||||
}
|
||||
|
||||
private func updateHistoryView(updateType: ViewUpdateType) {
|
||||
private func updateHistoryView(updateType: EngineViewUpdateType) {
|
||||
var entries = self.sourceHistoryView?.entries ?? []
|
||||
entries.sort(by: { $0.message.index < $1.message.index })
|
||||
|
||||
let mergedHistoryView = MessageHistoryView(tag: nil, namespaces: .just(Set([Namespaces.Message.Cloud])), entries: entries, holeEarlier: self.sourceHistoryView?.holeEarlier ?? false, holeLater: false, isLoading: false)
|
||||
|
||||
let mergedHistoryView = EngineRawMessageHistoryView(tag: nil, namespaces: .just(Set([Namespaces.Message.Cloud])), entries: entries, holeEarlier: self.sourceHistoryView?.holeEarlier ?? false, holeLater: false, isLoading: false)
|
||||
self.mergedHistoryView = mergedHistoryView
|
||||
|
||||
self.historyViewStream.putNext((mergedHistoryView, updateType))
|
||||
|
|
@ -112,9 +111,9 @@ final class HashtagSearchGlobalChatContents: ChatCustomContentsProtocol {
|
|||
return
|
||||
}
|
||||
|
||||
let updateType: ViewUpdateType = .FillHole
|
||||
|
||||
let historyView = MessageHistoryView(tag: nil, namespaces: .just(Set([Namespaces.Message.Cloud])), entries: result.0.messages.reversed().map { MessageHistoryEntry(message: $0, isRead: false, location: nil, monthLocation: nil, attributes: MutableMessageHistoryEntryAttributes(authorIsContact: false)) }, holeEarlier: !result.0.completed, holeLater: false, isLoading: false)
|
||||
let updateType: EngineViewUpdateType = .FillHole
|
||||
|
||||
let historyView = EngineRawMessageHistoryView(tag: nil, namespaces: .just(Set([Namespaces.Message.Cloud])), entries: result.0.messages.reversed().map { EngineRawMessageHistoryEntry(message: $0, isRead: false, location: nil, monthLocation: nil, attributes: EngineRawMutableMessageHistoryEntryAttributes(authorIsContact: false)) }, holeEarlier: !result.0.completed, holeLater: false, isLoading: false)
|
||||
self.sourceHistoryView = historyView
|
||||
|
||||
self.updateHistoryView(updateType: updateType)
|
||||
|
|
@ -143,7 +142,7 @@ final class HashtagSearchGlobalChatContents: ChatCustomContentsProtocol {
|
|||
|
||||
var kind: ChatCustomContentsKind
|
||||
|
||||
var historyView: Signal<(MessageHistoryView, ViewUpdateType), NoError> {
|
||||
var historyView: Signal<(EngineRawMessageHistoryView, EngineViewUpdateType), NoError> {
|
||||
return self.impl.signalWith({ impl, subscriber in
|
||||
if let mergedHistoryView = impl.mergedHistoryView {
|
||||
subscriber.putNext((mergedHistoryView, .Initial))
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import UIKit
|
|||
import LegacyComponents
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import SSignalKit
|
||||
import Display
|
||||
import TelegramPresentationData
|
||||
|
|
@ -20,7 +19,7 @@ public func guessMimeTypeByFileExtension(_ ext: String) -> String {
|
|||
return TGMimeTypeMap.mimeType(forExtension: ext) ?? "application/binary"
|
||||
}
|
||||
|
||||
public func configureLegacyAssetPicker(_ controller: TGMediaAssetsController, context: AccountContext, peer: Peer, chatLocation: ChatLocation, captionsEnabled: Bool = true, storeCreatedAssets: Bool = true, showFileTooltip: Bool = false, initialCaption: NSAttributedString, hasSchedule: Bool, presentWebSearch: (() -> Void)?, presentSelectionLimitExceeded: @escaping () -> Void, presentSchedulePicker: @escaping (Bool, @escaping (Int32, Bool) -> Void) -> Void, presentTimerPicker: @escaping (@escaping (Int32) -> Void) -> Void, getCaptionPanelView: @escaping () -> TGCaptionPanelView?) {
|
||||
public func configureLegacyAssetPicker(_ controller: TGMediaAssetsController, context: AccountContext, peer: EngineRawPeer, chatLocation: ChatLocation, captionsEnabled: Bool = true, storeCreatedAssets: Bool = true, showFileTooltip: Bool = false, initialCaption: NSAttributedString, hasSchedule: Bool, presentWebSearch: (() -> Void)?, presentSelectionLimitExceeded: @escaping () -> Void, presentSchedulePicker: @escaping (Bool, @escaping (Int32, Bool) -> Void) -> Void, presentTimerPicker: @escaping (@escaping (Int32) -> Void) -> Void, getCaptionPanelView: @escaping () -> TGCaptionPanelView?) {
|
||||
let paintStickersContext = LegacyPaintStickersContext(context: context)
|
||||
paintStickersContext.captionPanelView = {
|
||||
return getCaptionPanelView()
|
||||
|
|
@ -65,7 +64,7 @@ public func configureLegacyAssetPicker(_ controller: TGMediaAssetsController, co
|
|||
}
|
||||
}
|
||||
|
||||
public func legacyAssetPicker(context: AccountContext, presentationData: PresentationData, editingMedia: Bool, fileMode: Bool, peer: Peer?, threadTitle: String?, saveEditedPhotos: Bool, allowGrouping: Bool, selectionLimit: Int) -> Signal<(LegacyComponentsContext) -> TGMediaAssetsController, Void> {
|
||||
public func legacyAssetPicker(context: AccountContext, presentationData: PresentationData, editingMedia: Bool, fileMode: Bool, peer: EngineRawPeer?, threadTitle: String?, saveEditedPhotos: Bool, allowGrouping: Bool, selectionLimit: Int) -> Signal<(LegacyComponentsContext) -> TGMediaAssetsController, Void> {
|
||||
let isSecretChat = (peer?.id.namespace._internalGetInt32Value() ?? 0) == Namespaces.Peer.SecretChat._internalGetInt32Value()
|
||||
|
||||
let recipientName: String?
|
||||
|
|
@ -162,7 +161,7 @@ public func legacyAssetPickerItemGenerator() -> ((Any?, NSAttributedString?, Str
|
|||
return { anyDict, caption, hash, uniqueId in
|
||||
let dict = anyDict as! NSDictionary
|
||||
let stickers = (dict["stickers"] as? [Data])?.compactMap { data -> FileMediaReference? in
|
||||
let decoder = PostboxDecoder(buffer: MemoryBuffer(data: data))
|
||||
let decoder = EnginePostboxDecoder(buffer: EngineMemoryBuffer(data: data))
|
||||
if let file = decoder.decodeRootObject() as? TelegramMediaFile {
|
||||
return FileMediaReference.standalone(media: file)
|
||||
} else {
|
||||
|
|
@ -350,7 +349,7 @@ public func legacyEnqueueGifMessage(account: Account, data: Data, correlationId:
|
|||
fileAttributes.append(.FileName(fileName: fileName))
|
||||
fileAttributes.append(.Animated)
|
||||
|
||||
let media = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: Int64.random(in: Int64.min ... Int64.max)), partialReference: nil, resource: resource, previewRepresentations: previewRepresentations, videoThumbnails: [], immediateThumbnailData: nil, mimeType: "video/mp4", size: nil, attributes: fileAttributes, alternativeRepresentations: [])
|
||||
let media = TelegramMediaFile(fileId: EngineMedia.Id(namespace: Namespaces.Media.LocalFile, id: Int64.random(in: Int64.min ... Int64.max)), partialReference: nil, resource: resource, previewRepresentations: previewRepresentations, videoThumbnails: [], immediateThumbnailData: nil, mimeType: "video/mp4", size: nil, attributes: fileAttributes, alternativeRepresentations: [])
|
||||
subscriber.putNext(.message(text: "", attributes: [], inlineStickers: [:], mediaReference: .standalone(media: media), threadId: nil, replyToMessageId: nil, replyToStoryId: nil, localGroupingKey: nil, correlationId: correlationId, bubbleUpEmojiOrStickersets: []))
|
||||
subscriber.putCompletion()
|
||||
} else {
|
||||
|
|
@ -381,7 +380,7 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
var price: Int64
|
||||
var text: String
|
||||
var entities: [MessageTextEntity]
|
||||
var media: [Media]
|
||||
var media: [EngineRawMedia]
|
||||
}
|
||||
|
||||
var paidMessage: EnqueuePaidMessage?
|
||||
|
|
@ -409,9 +408,9 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
let scaledSize = image.size.aspectFittedOrSmaller(maxSize)
|
||||
|
||||
if let scaledImage = TGScaleImageToPixelSize(image, scaledSize) {
|
||||
let tempFile = TempBox.shared.tempFile(fileName: "file")
|
||||
let tempFile = EngineTempBox.shared.tempFile(fileName: "file")
|
||||
defer {
|
||||
TempBox.shared.dispose(tempFile)
|
||||
EngineTempBox.shared.dispose(tempFile)
|
||||
}
|
||||
if let scaledImageData = compressImageToJPEG(scaledImage, quality: 0.6, tempFilePath: tempFile.path) {
|
||||
let _ = try? scaledImageData.write(to: URL(fileURLWithPath: tempFilePath))
|
||||
|
|
@ -421,7 +420,7 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
|
||||
var imageFlags: TelegramMediaImageFlags = []
|
||||
|
||||
var attributes: [MessageAttribute] = []
|
||||
var attributes: [EngineMessage.Attribute] = []
|
||||
|
||||
var stickerFiles: [TelegramMediaFile] = []
|
||||
if !stickers.isEmpty {
|
||||
|
|
@ -449,8 +448,8 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
}
|
||||
|
||||
if let dict = adjustments.dictionary(), let data = try? NSKeyedArchiver.archivedData(withRootObject: dict, requiringSecureCoding: false) {
|
||||
let adjustmentsData = MemoryBuffer(data: data)
|
||||
let digest = MemoryBuffer(data: adjustmentsData.md5Digest())
|
||||
let adjustmentsData = EngineMemoryBuffer(data: data)
|
||||
let digest = EngineMemoryBuffer(data: adjustmentsData.md5Digest())
|
||||
resourceAdjustments = VideoMediaResourceAdjustments(data: adjustmentsData, digest: digest, isStory: false)
|
||||
}
|
||||
}
|
||||
|
|
@ -463,11 +462,11 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
if estimatedSize > 10 * 1024 * 1024 {
|
||||
fileAttributes.append(.hintFileIsLarge)
|
||||
}
|
||||
videoFile = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: Int64.random(in: Int64.min ... Int64.max)), partialReference: nil, resource: resource, previewRepresentations: [], videoThumbnails: [], videoCover: nil, immediateThumbnailData: nil, mimeType: "video/mp4", size: nil, attributes: fileAttributes, alternativeRepresentations: [])
|
||||
videoFile = TelegramMediaFile(fileId: EngineMedia.Id(namespace: Namespaces.Media.LocalFile, id: Int64.random(in: Int64.min ... Int64.max)), partialReference: nil, resource: resource, previewRepresentations: [], videoThumbnails: [], videoCover: nil, immediateThumbnailData: nil, mimeType: "video/mp4", size: nil, attributes: fileAttributes, alternativeRepresentations: [])
|
||||
imageFlags.insert(.isLivePhoto)
|
||||
}
|
||||
|
||||
let media = TelegramMediaImage(imageId: MediaId(namespace: Namespaces.Media.LocalImage, id: randomId), representations: representations, immediateThumbnailData: nil, reference: nil, partialReference: nil, flags: imageFlags, video: videoFile)
|
||||
let media = TelegramMediaImage(imageId: EngineMedia.Id(namespace: Namespaces.Media.LocalImage, id: randomId), representations: representations, immediateThumbnailData: nil, reference: nil, partialReference: nil, flags: imageFlags, video: videoFile)
|
||||
if let timer = item.timer, timer > 0 && (timer <= 60 || timer == viewOnceTimeout) {
|
||||
attributes.append(AutoremoveTimeoutMessageAttribute(timeout: Int32(timer), countdownBeginTime: nil))
|
||||
}
|
||||
|
|
@ -480,7 +479,7 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
if !entities.isEmpty {
|
||||
attributes.append(TextEntitiesMessageAttribute(entities: entities))
|
||||
}
|
||||
var bubbleUpEmojiOrStickersetsById: [Int64: ItemCollectionId] = [:]
|
||||
var bubbleUpEmojiOrStickersetsById: [Int64: EngineItemCollectionId] = [:]
|
||||
text.enumerateAttribute(ChatTextInputAttributes.customEmoji, in: NSRange(location: 0, length: text.length), using: { value, _, _ in
|
||||
if let value = value as? ChatTextInputTextCustomEmojiAttribute {
|
||||
if let file = value.file {
|
||||
|
|
@ -490,7 +489,7 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
}
|
||||
}
|
||||
})
|
||||
var bubbleUpEmojiOrStickersets: [ItemCollectionId] = []
|
||||
var bubbleUpEmojiOrStickersets: [EngineItemCollectionId] = []
|
||||
for entity in entities {
|
||||
if case let .CustomEmoji(_, fileId) = entity.type {
|
||||
if let packId = bubbleUpEmojiOrStickersetsById[fileId] {
|
||||
|
|
@ -552,13 +551,13 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
let size = CGSize(width: CGFloat(asset.pixelWidth), height: CGFloat(asset.pixelHeight))
|
||||
let scaledSize = size.aspectFittedOrSmaller(CGSize(width: CGFloat(sizeSide), height: CGFloat(sizeSide)))
|
||||
|
||||
let media: Media
|
||||
media = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: Int64.random(in: Int64.min ... Int64.max)), partialReference: nil, resource: resource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: format == .jxl ? "image/jxl" : "image/jpeg", size: nil, attributes: [
|
||||
let media: EngineRawMedia
|
||||
media = TelegramMediaFile(fileId: EngineMedia.Id(namespace: Namespaces.Media.LocalFile, id: Int64.random(in: Int64.min ... Int64.max)), partialReference: nil, resource: resource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: format == .jxl ? "image/jxl" : "image/jpeg", size: nil, attributes: [
|
||||
.FileName(fileName: format == .jxl ? "image\(sizeSide)-q\(quality).jxl" : "image\(sizeSide)-q\(quality).jpg"),
|
||||
.ImageSize(size: PixelDimensions(scaledSize))
|
||||
], alternativeRepresentations: [])
|
||||
|
||||
var attributes: [MessageAttribute] = []
|
||||
var attributes: [EngineMessage.Attribute] = []
|
||||
if let timer = item.timer, timer > 0 && (timer <= 60 || timer == viewOnceTimeout) {
|
||||
attributes.append(AutoremoveTimeoutMessageAttribute(timeout: Int32(timer), countdownBeginTime: nil))
|
||||
}
|
||||
|
|
@ -572,7 +571,7 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
attributes.append(TextEntitiesMessageAttribute(entities: entities))
|
||||
}
|
||||
|
||||
var bubbleUpEmojiOrStickersetsById: [Int64: ItemCollectionId] = [:]
|
||||
var bubbleUpEmojiOrStickersetsById: [Int64: EngineItemCollectionId] = [:]
|
||||
text.enumerateAttribute(ChatTextInputAttributes.customEmoji, in: NSRange(location: 0, length: text.length), using: { value, _, _ in
|
||||
if let value = value as? ChatTextInputTextCustomEmojiAttribute {
|
||||
if let file = value.file {
|
||||
|
|
@ -582,7 +581,7 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
}
|
||||
}
|
||||
})
|
||||
var bubbleUpEmojiOrStickersets: [ItemCollectionId] = []
|
||||
var bubbleUpEmojiOrStickersets: [EngineItemCollectionId] = []
|
||||
for entity in entities {
|
||||
if case let .CustomEmoji(_, fileId) = entity.type {
|
||||
if let packId = bubbleUpEmojiOrStickersetsById[fileId] {
|
||||
|
|
@ -622,11 +621,11 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
let scaledSize = size.aspectFittedOrSmaller(CGSize(width: 1280.0, height: 1280.0))
|
||||
let resource = PhotoLibraryMediaResource(localIdentifier: asset.localIdentifier, uniqueId: Int64.random(in: Int64.min ... Int64.max), forceHd: item.forceHd)
|
||||
|
||||
let media: Media
|
||||
let media: EngineRawMedia
|
||||
representations.append(TelegramMediaImageRepresentation(dimensions: PixelDimensions(scaledSize), resource: resource, progressiveSizes: [], immediateThumbnailData: nil, hasVideo: false, isPersonal: false))
|
||||
media = TelegramMediaImage(imageId: MediaId(namespace: Namespaces.Media.LocalImage, id: randomId), representations: representations, immediateThumbnailData: nil, reference: nil, partialReference: nil, flags: [])
|
||||
media = TelegramMediaImage(imageId: EngineMedia.Id(namespace: Namespaces.Media.LocalImage, id: randomId), representations: representations, immediateThumbnailData: nil, reference: nil, partialReference: nil, flags: [])
|
||||
|
||||
var attributes: [MessageAttribute] = []
|
||||
var attributes: [EngineMessage.Attribute] = []
|
||||
if let timer = item.timer, timer > 0 && (timer <= 60 || timer == viewOnceTimeout) {
|
||||
attributes.append(AutoremoveTimeoutMessageAttribute(timeout: Int32(timer), countdownBeginTime: nil))
|
||||
}
|
||||
|
|
@ -640,7 +639,7 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
attributes.append(TextEntitiesMessageAttribute(entities: entities))
|
||||
}
|
||||
|
||||
var bubbleUpEmojiOrStickersetsById: [Int64: ItemCollectionId] = [:]
|
||||
var bubbleUpEmojiOrStickersetsById: [Int64: EngineItemCollectionId] = [:]
|
||||
text.enumerateAttribute(ChatTextInputAttributes.customEmoji, in: NSRange(location: 0, length: text.length), using: { value, _, _ in
|
||||
if let value = value as? ChatTextInputTextCustomEmojiAttribute {
|
||||
if let file = value.file {
|
||||
|
|
@ -650,7 +649,7 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
}
|
||||
}
|
||||
})
|
||||
var bubbleUpEmojiOrStickersets: [ItemCollectionId] = []
|
||||
var bubbleUpEmojiOrStickersets: [EngineItemCollectionId] = []
|
||||
for entity in entities {
|
||||
if case let .CustomEmoji(_, fileId) = entity.type {
|
||||
if let packId = bubbleUpEmojiOrStickersetsById[fileId] {
|
||||
|
|
@ -701,16 +700,16 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
var randomId: Int64 = 0
|
||||
arc4random_buf(&randomId, 8)
|
||||
let resource = LocalFileReferenceMediaResource(localFilePath: path, randomId: randomId)
|
||||
let media = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: randomId), partialReference: nil, resource: resource, previewRepresentations: previewRepresentations, videoThumbnails: [], immediateThumbnailData: nil, mimeType: mimeType, size: fileSize(path), attributes: [.FileName(fileName: name)], alternativeRepresentations: [])
|
||||
let media = TelegramMediaFile(fileId: EngineMedia.Id(namespace: Namespaces.Media.LocalFile, id: randomId), partialReference: nil, resource: resource, previewRepresentations: previewRepresentations, videoThumbnails: [], immediateThumbnailData: nil, mimeType: mimeType, size: engineFileSize(path), attributes: [.FileName(fileName: name)], alternativeRepresentations: [])
|
||||
|
||||
var attributes: [MessageAttribute] = []
|
||||
var attributes: [EngineMessage.Attribute] = []
|
||||
let text = trimChatInputText(convertMarkdownToAttributes(caption ?? NSAttributedString()))
|
||||
let entities = generateTextEntities(text.string, enabledTypes: .all, currentEntities: generateChatInputTextEntities(text))
|
||||
if !entities.isEmpty {
|
||||
attributes.append(TextEntitiesMessageAttribute(entities: entities))
|
||||
}
|
||||
|
||||
var bubbleUpEmojiOrStickersetsById: [Int64: ItemCollectionId] = [:]
|
||||
var bubbleUpEmojiOrStickersetsById: [Int64: EngineItemCollectionId] = [:]
|
||||
text.enumerateAttribute(ChatTextInputAttributes.customEmoji, in: NSRange(location: 0, length: text.length), using: { value, _, _ in
|
||||
if let value = value as? ChatTextInputTextCustomEmojiAttribute {
|
||||
if let file = value.file {
|
||||
|
|
@ -720,7 +719,7 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
}
|
||||
}
|
||||
})
|
||||
var bubbleUpEmojiOrStickersets: [ItemCollectionId] = []
|
||||
var bubbleUpEmojiOrStickersets: [EngineItemCollectionId] = []
|
||||
for entity in entities {
|
||||
if case let .CustomEmoji(_, fileId) = entity.type {
|
||||
if let packId = bubbleUpEmojiOrStickersetsById[fileId] {
|
||||
|
|
@ -754,16 +753,16 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
var randomId: Int64 = 0
|
||||
arc4random_buf(&randomId, 8)
|
||||
let resource = PhotoLibraryMediaResource(localIdentifier: asset.localIdentifier, uniqueId: Int64.random(in: Int64.min ... Int64.max))
|
||||
let media = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: randomId), partialReference: nil, resource: resource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: mimeType, size: nil, attributes: [.FileName(fileName: name)], alternativeRepresentations: [])
|
||||
let media = TelegramMediaFile(fileId: EngineMedia.Id(namespace: Namespaces.Media.LocalFile, id: randomId), partialReference: nil, resource: resource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: mimeType, size: nil, attributes: [.FileName(fileName: name)], alternativeRepresentations: [])
|
||||
|
||||
var attributes: [MessageAttribute] = []
|
||||
var attributes: [EngineMessage.Attribute] = []
|
||||
let text = trimChatInputText(convertMarkdownToAttributes(caption ?? NSAttributedString()))
|
||||
let entities = generateTextEntities(text.string, enabledTypes: .all, currentEntities: generateChatInputTextEntities(text))
|
||||
if !entities.isEmpty {
|
||||
attributes.append(TextEntitiesMessageAttribute(entities: entities))
|
||||
}
|
||||
|
||||
var bubbleUpEmojiOrStickersetsById: [Int64: ItemCollectionId] = [:]
|
||||
var bubbleUpEmojiOrStickersetsById: [Int64: EngineItemCollectionId] = [:]
|
||||
text.enumerateAttribute(ChatTextInputAttributes.customEmoji, in: NSRange(location: 0, length: text.length), using: { value, _, _ in
|
||||
if let value = value as? ChatTextInputTextCustomEmojiAttribute {
|
||||
if let file = value.file {
|
||||
|
|
@ -773,7 +772,7 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
}
|
||||
}
|
||||
})
|
||||
var bubbleUpEmojiOrStickersets: [ItemCollectionId] = []
|
||||
var bubbleUpEmojiOrStickersets: [EngineItemCollectionId] = []
|
||||
for entity in entities {
|
||||
if case let .CustomEmoji(_, fileId) = entity.type {
|
||||
if let packId = bubbleUpEmojiOrStickersetsById[fileId] {
|
||||
|
|
@ -858,7 +857,7 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
if let coverData = coverImage.jpegData(compressionQuality: 0.87) {
|
||||
account.postbox.mediaBox.storeResourceData(resource.id, data: coverData)
|
||||
videoCover = TelegramMediaImage(
|
||||
imageId: MediaId(namespace: 0, id: 0),
|
||||
imageId: EngineMedia.Id(namespace: 0, id: 0),
|
||||
representations: [
|
||||
TelegramMediaImageRepresentation(dimensions: PixelDimensions(coverSize), resource: resource, progressiveSizes: [], immediateThumbnailData: nil, hasVideo: false, isPersonal: false)
|
||||
],
|
||||
|
|
@ -891,8 +890,8 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
}
|
||||
|
||||
if let dict = adjustments.dictionary(), let data = try? NSKeyedArchiver.archivedData(withRootObject: dict, requiringSecureCoding: false) {
|
||||
let adjustmentsData = MemoryBuffer(data: data)
|
||||
let digest = MemoryBuffer(data: adjustmentsData.md5Digest())
|
||||
let adjustmentsData = EngineMemoryBuffer(data: data)
|
||||
let digest = EngineMemoryBuffer(data: adjustmentsData.md5Digest())
|
||||
resourceAdjustments = VideoMediaResourceAdjustments(data: adjustmentsData, digest: digest, isStory: false)
|
||||
}
|
||||
}
|
||||
|
|
@ -907,7 +906,7 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
resource = VideoLibraryMediaResource(localIdentifier: asset.backingAsset.localIdentifier, conversion: asFile ? .passthrough : .compress(resourceAdjustments))
|
||||
case let .tempFile(path, _, _):
|
||||
if asFile || (asAnimation && !path.contains(".jpg")) {
|
||||
if let size = fileSize(path) {
|
||||
if let size = engineFileSize(path) {
|
||||
resource = LocalFileMediaResource(fileId: Int64.random(in: Int64.min ... Int64.max), size: size)
|
||||
account.postbox.mediaBox.moveResourceData(resource.id, fromTempPath: path)
|
||||
} else {
|
||||
|
|
@ -947,7 +946,7 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
}
|
||||
}
|
||||
|
||||
var attributes: [MessageAttribute] = []
|
||||
var attributes: [EngineMessage.Attribute] = []
|
||||
|
||||
var stickerFiles: [TelegramMediaFile] = []
|
||||
if !stickers.isEmpty {
|
||||
|
|
@ -960,13 +959,13 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
fileAttributes.append(.HasLinkedStickers)
|
||||
}
|
||||
|
||||
let media: Media
|
||||
let media: EngineRawMedia
|
||||
let mediaReference: AnyMediaReference
|
||||
if let adjustments, adjustments.isDefaultValuesForGif(), let originalMediaReference {
|
||||
media = originalMediaReference.media
|
||||
mediaReference = originalMediaReference
|
||||
} else {
|
||||
media = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: Int64.random(in: Int64.min ... Int64.max)), partialReference: nil, resource: resource, previewRepresentations: previewRepresentations, videoThumbnails: [], videoCover: videoCover, immediateThumbnailData: nil, mimeType: "video/mp4", size: nil, attributes: fileAttributes, alternativeRepresentations: [])
|
||||
media = TelegramMediaFile(fileId: EngineMedia.Id(namespace: Namespaces.Media.LocalFile, id: Int64.random(in: Int64.min ... Int64.max)), partialReference: nil, resource: resource, previewRepresentations: previewRepresentations, videoThumbnails: [], videoCover: videoCover, immediateThumbnailData: nil, mimeType: "video/mp4", size: nil, attributes: fileAttributes, alternativeRepresentations: [])
|
||||
mediaReference = .standalone(media: media)
|
||||
}
|
||||
|
||||
|
|
@ -983,7 +982,7 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
attributes.append(TextEntitiesMessageAttribute(entities: entities))
|
||||
}
|
||||
|
||||
var bubbleUpEmojiOrStickersetsById: [Int64: ItemCollectionId] = [:]
|
||||
var bubbleUpEmojiOrStickersetsById: [Int64: EngineItemCollectionId] = [:]
|
||||
text.enumerateAttribute(ChatTextInputAttributes.customEmoji, in: NSRange(location: 0, length: text.length), using: { value, _, _ in
|
||||
if let value = value as? ChatTextInputTextCustomEmojiAttribute {
|
||||
if let file = value.file {
|
||||
|
|
@ -993,7 +992,7 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
}
|
||||
}
|
||||
})
|
||||
var bubbleUpEmojiOrStickersets: [ItemCollectionId] = []
|
||||
var bubbleUpEmojiOrStickersets: [EngineItemCollectionId] = []
|
||||
for entity in entities {
|
||||
if case let .CustomEmoji(_, fileId) = entity.type {
|
||||
if let packId = bubbleUpEmojiOrStickersetsById[fileId] {
|
||||
|
|
@ -1028,7 +1027,7 @@ public func legacyAssetPickerEnqueueMessages(
|
|||
}
|
||||
|
||||
if let paidMessage {
|
||||
var attributes: [MessageAttribute] = []
|
||||
var attributes: [EngineMessage.Attribute] = []
|
||||
if !paidMessage.entities.isEmpty {
|
||||
attributes.append(TextEntitiesMessageAttribute(entities: paidMessage.entities))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
|
|
@ -121,7 +120,7 @@ private struct FetchControls {
|
|||
}
|
||||
|
||||
private enum FileIconImage: Equatable {
|
||||
case imageRepresentation(Media, TelegramMediaImageRepresentation)
|
||||
case imageRepresentation(EngineRawMedia, TelegramMediaImageRepresentation)
|
||||
case albumArt(TelegramMediaFile, SharedMediaPlaybackAlbumArt)
|
||||
case roundVideo(TelegramMediaFile)
|
||||
|
||||
|
|
@ -171,7 +170,7 @@ final class CachedChatListSearchResult {
|
|||
}
|
||||
}
|
||||
|
||||
private func selectStoryMedia(item: Stories.Item, preferredHighQuality: Bool) -> Media? {
|
||||
private func selectStoryMedia(item: Stories.Item, preferredHighQuality: Bool) -> EngineRawMedia? {
|
||||
if !preferredHighQuality, let alternativeMediaValue = item.alternativeMediaList.first {
|
||||
return alternativeMediaValue
|
||||
} else {
|
||||
|
|
@ -372,11 +371,11 @@ public final class ListMessageFileItemNode: ListMessageNode {
|
|||
private let restrictionNode: ASDisplayNode
|
||||
|
||||
private var currentIconImage: FileIconImage?
|
||||
public var currentMedia: Media?
|
||||
public var currentMedia: EngineRawMedia?
|
||||
|
||||
private let statusDisposable = MetaDisposable()
|
||||
private let fetchControls = Atomic<FetchControls?>(value: nil)
|
||||
private var fetchStatus: MediaResourceStatus?
|
||||
private var fetchStatus: EngineMediaResourceStatus?
|
||||
private var resourceStatus: FileMediaResourceMediaStatus?
|
||||
private let fetchDisposable = MetaDisposable()
|
||||
private let playbackStatusDisposable = MetaDisposable()
|
||||
|
|
@ -389,7 +388,7 @@ public final class ListMessageFileItemNode: ListMessageNode {
|
|||
private var absoluteLocation: (CGRect, CGSize)?
|
||||
|
||||
private var context: AccountContext?
|
||||
private(set) var message: Message?
|
||||
private(set) var message: EngineRawMessage?
|
||||
|
||||
private var appliedItem: ListMessageItem?
|
||||
private var layoutParams: ListViewItemLayoutParams?
|
||||
|
|
@ -681,7 +680,7 @@ public final class ListMessageFileItemNode: ListMessageNode {
|
|||
var descriptionExtraData: (title: NSAttributedString, showIcon: Bool, iconId: Int64?, iconColor: Int32)? = nil
|
||||
var globalAuthorTitle: String?
|
||||
|
||||
var selectedMedia: Media?
|
||||
var selectedMedia: EngineRawMedia?
|
||||
if let message = message {
|
||||
var effectiveMessageMedia = message.media
|
||||
for media in message.media {
|
||||
|
|
@ -1093,7 +1092,7 @@ public final class ListMessageFileItemNode: ListMessageNode {
|
|||
updateIconImageSignal = .complete()
|
||||
}
|
||||
case let .albumArt(file, albumArt):
|
||||
updateIconImageSignal = playerAlbumArt(postbox: item.context.account.postbox, engine: item.context.engine, fileReference: .message(message: MessageReference(message), media: file), albumArt: albumArt, thumbnail: true, overlayColor: UIColor(white: 0.0, alpha: 0.3), emptyColor: item.presentationData.theme.theme.list.itemAccentColor)
|
||||
updateIconImageSignal = playerAlbumArt(engine: item.context.engine, fileReference: .message(message: MessageReference(message), media: file), albumArt: albumArt, thumbnail: true, overlayColor: UIColor(white: 0.0, alpha: 0.3), emptyColor: item.presentationData.theme.theme.list.itemAccentColor)
|
||||
case let .roundVideo(file):
|
||||
updateIconImageSignal = mediaGridMessageVideo(postbox: item.context.account.postbox, userLocation: .peer(message.id.peerId), videoReference: FileMediaReference.message(message: MessageReference(message), media: file), autoFetchFullSizeThumbnail: true, overlayColor: UIColor(white: 0.0, alpha: 0.3))
|
||||
}
|
||||
|
|
@ -1526,7 +1525,7 @@ public final class ListMessageFileItemNode: ListMessageNode {
|
|||
}
|
||||
}
|
||||
|
||||
override public func transitionNode(id: MessageId, media: Media, adjustRect: Bool) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
override public func transitionNode(id: EngineMessage.Id, media: EngineRawMedia, adjustRect: Bool) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
if let item = self.item, let message = item.message, message.id == id, self.iconImageNode.supernode != nil {
|
||||
let iconImageNode = self.iconImageNode
|
||||
return (self.iconImageNode, self.iconImageNode.bounds, { [weak iconImageNode] in
|
||||
|
|
@ -1559,7 +1558,7 @@ public final class ListMessageFileItemNode: ListMessageNode {
|
|||
|
||||
var downloadingString: String?
|
||||
if let resourceStatus = self.resourceStatus, !item.isAttachMusic {
|
||||
var maybeFetchStatus: MediaResourceStatus = .Local
|
||||
var maybeFetchStatus: EngineMediaResourceStatus = .Local
|
||||
switch resourceStatus {
|
||||
case .playbackStatus:
|
||||
break
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
|
|
@ -57,7 +56,7 @@ public final class ListMessageSnippetItemNode: ListMessageNode {
|
|||
private let iconImageNode: TransformImageNode
|
||||
|
||||
private var currentIconImageRepresentation: TelegramMediaImageRepresentation?
|
||||
private var currentMedia: Media?
|
||||
private var currentMedia: EngineRawMedia?
|
||||
public var currentPrimaryUrl: String?
|
||||
private var currentIsInstantView: Bool?
|
||||
|
||||
|
|
@ -861,7 +860,7 @@ public final class ListMessageSnippetItemNode: ListMessageNode {
|
|||
}
|
||||
}
|
||||
|
||||
override public func transitionNode(id: MessageId, media: Media, adjustRect: Bool) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
override public func transitionNode(id: EngineMessage.Id, media: EngineRawMedia, adjustRect: Bool) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
if let item = self.item, item.message?.id == id, self.iconImageNode.supernode != nil {
|
||||
let iconImageNode = self.iconImageNode
|
||||
return (self.iconImageNode, self.iconImageNode.bounds, { [weak iconImageNode] in
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import UIKit
|
|||
import Display
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import AvatarBackground
|
||||
import AccountContext
|
||||
import EmojiTextAttachmentView
|
||||
|
|
@ -37,28 +36,25 @@ final class AvatarEditorPreviewView: UIView {
|
|||
|
||||
self.addSubview(self.backgroundView)
|
||||
|
||||
let stickersKey: PostboxViewKey = .orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedProfilePhotoEmoji)
|
||||
self.disposable = (context.account.postbox.combinedView(keys: [stickersKey])
|
||||
self.disposable = (context.engine.data.subscribe(TelegramEngine.EngineData.Item.OrderedLists.ListItems(collectionId: Namespaces.OrderedItemList.CloudFeaturedProfilePhotoEmoji))
|
||||
|> runOn(Queue.concurrentDefaultQueue())
|
||||
|> deliverOnMainQueue).start(next: { [weak self] views in
|
||||
|> deliverOnMainQueue).start(next: { [weak self] items in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
if let view = views.views[stickersKey] as? OrderedItemListView {
|
||||
var files: [TelegramMediaFile] = []
|
||||
for item in view.items.prefix(8) {
|
||||
if let mediaItem = item.contents.get(RecentMediaItem.self) {
|
||||
let file = mediaItem.media._parse()
|
||||
files.append(file)
|
||||
|
||||
self.preloadDisposableSet.add(freeMediaFileResourceInteractiveFetched(account: context.account, userLocation: .other, fileReference: .standalone(media: file), resource: file.resource).start())
|
||||
}
|
||||
}
|
||||
self.files = files
|
||||
if let size = self.currentSize {
|
||||
self.updateLayout(size: size)
|
||||
var files: [TelegramMediaFile] = []
|
||||
for item in items.prefix(8) {
|
||||
if let mediaItem = item.contents.get(RecentMediaItem.self) {
|
||||
let file = mediaItem.media._parse()
|
||||
files.append(file)
|
||||
|
||||
self.preloadDisposableSet.add(freeMediaFileResourceInteractiveFetched(account: context.account, userLocation: .other, fileReference: .standalone(media: file), resource: file.resource).start())
|
||||
}
|
||||
}
|
||||
self.files = files
|
||||
if let size = self.currentSize {
|
||||
self.updateLayout(size: size)
|
||||
}
|
||||
})
|
||||
|
||||
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.handleTap))
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
|
|
@ -845,7 +844,7 @@ public func channelAdminsController(context: AccountContext, updatedPresentation
|
|||
|> deliverOnMainQueue).start(next: { peerId in
|
||||
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
var didReportLoadCompleted = false
|
||||
let membersAndLoadMoreControl: (Disposable, PeerChannelMemberCategoryControl?) = context.peerChannelMemberCategoriesContextsManager.admins(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId) { membersState in
|
||||
let membersAndLoadMoreControl: (Disposable, PeerChannelMemberCategoryControl?) = context.peerChannelMemberCategoriesContextsManager.admins(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId) { membersState in
|
||||
if case .loading = membersState.loadingState, membersState.list.isEmpty {
|
||||
adminsPromise.set(.single(nil))
|
||||
} else {
|
||||
|
|
@ -912,7 +911,7 @@ public func channelAdminsController(context: AccountContext, updatedPresentation
|
|||
}
|
||||
for (participant, peer, presence) in participants {
|
||||
if let peer {
|
||||
var presences: [PeerId: PeerPresence] = [:]
|
||||
var presences: [EnginePeer.Id: EngineRawPeerPresence] = [:]
|
||||
if let presence {
|
||||
presences[peer.id] = presence._asPresence()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import ItemListUI
|
||||
|
|
@ -425,7 +424,7 @@ func completeRights(_ flags: TelegramChatBannedRightsFlags) -> TelegramChatBanne
|
|||
return result
|
||||
}
|
||||
|
||||
private func channelBannedMemberControllerEntries(presentationData: PresentationData, state: ChannelBannedMemberControllerState, accountPeerId: PeerId, channelPeer: EnginePeer?, memberPeer: EnginePeer?, memberPresence: EnginePeer.Presence?, initialParticipant: ChannelParticipant?, initialBannedBy: EnginePeer?, editMember: Bool) -> [ChannelBannedMemberEntry] {
|
||||
private func channelBannedMemberControllerEntries(presentationData: PresentationData, state: ChannelBannedMemberControllerState, accountPeerId: EnginePeer.Id, channelPeer: EnginePeer?, memberPeer: EnginePeer?, memberPresence: EnginePeer.Presence?, initialParticipant: ChannelParticipant?, initialBannedBy: EnginePeer?, editMember: Bool) -> [ChannelBannedMemberEntry] {
|
||||
var entries: [ChannelBannedMemberEntry] = []
|
||||
|
||||
if case let .channel(channel) = channelPeer, let defaultBannedRights = channel.defaultBannedRights, let member = memberPeer {
|
||||
|
|
@ -586,7 +585,7 @@ private func channelBannedMemberControllerEntries(presentationData: Presentation
|
|||
return entries
|
||||
}
|
||||
|
||||
public func channelBannedMemberController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, peerId: PeerId, memberId: PeerId, editMember: Bool = false, initialParticipant: ChannelParticipant?, updated: @escaping (TelegramChatBannedRights?) -> Void, upgradedToSupergroup: @escaping (PeerId, @escaping () -> Void) -> Void) -> ViewController {
|
||||
public func channelBannedMemberController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, peerId: EnginePeer.Id, memberId: EnginePeer.Id, editMember: Bool = false, initialParticipant: ChannelParticipant?, updated: @escaping (TelegramChatBannedRights?) -> Void, upgradedToSupergroup: @escaping (EnginePeer.Id, @escaping () -> Void) -> Void) -> ViewController {
|
||||
let initialState = ChannelBannedMemberControllerState(referenceTimestamp: Int32(Date().timeIntervalSince1970), updatedFlags: nil, updatedTimeout: nil, updating: false, updatedRank: nil, focusedOnRank: false)
|
||||
let statePromise = ValuePromise(initialState, ignoreRepeated: true)
|
||||
let stateValue = Atomic(value: initialState)
|
||||
|
|
@ -609,20 +608,20 @@ public func channelBannedMemberController(context: AccountContext, updatedPresen
|
|||
var errorImpl: (() -> Void)?
|
||||
var scrollToRankImpl: (() -> Void)?
|
||||
|
||||
let peerView = Promise<PeerView>()
|
||||
peerView.set(context.account.viewTracker.peerView(peerId))
|
||||
let peerSignal = Promise<EnginePeer?>()
|
||||
peerSignal.set(context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)))
|
||||
|
||||
let arguments = ChannelBannedMemberControllerArguments(context: context, toggleRight: { rights, value in
|
||||
let _ = (peerView.get()
|
||||
let _ = (peerSignal.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { view in
|
||||
|> deliverOnMainQueue).start(next: { peer in
|
||||
var defaultBannedRightsFlagsValue: TelegramChatBannedRightsFlags?
|
||||
guard let peer = view.peers[peerId] else {
|
||||
guard let peer else {
|
||||
return
|
||||
}
|
||||
if let channel = peer as? TelegramChannel, let initialRightFlags = channel.defaultBannedRights?.flags {
|
||||
if case let .channel(channel) = peer, let initialRightFlags = channel.defaultBannedRights?.flags {
|
||||
defaultBannedRightsFlagsValue = initialRightFlags
|
||||
} else if let group = peer as? TelegramGroup, let initialRightFlags = group.defaultBannedRights?.flags {
|
||||
} else if case let .legacyGroup(group) = peer, let initialRightFlags = group.defaultBannedRights?.flags {
|
||||
defaultBannedRightsFlagsValue = initialRightFlags
|
||||
}
|
||||
guard let defaultBannedRightsFlags = defaultBannedRightsFlagsValue else {
|
||||
|
|
@ -648,7 +647,7 @@ public func channelBannedMemberController(context: AccountContext, updatedPresen
|
|||
}
|
||||
} else {
|
||||
effectiveRightsFlags.insert(rights)
|
||||
for (right, _) in allGroupPermissionList(peer: EnginePeer(peer), expandMedia: false) {
|
||||
for (right, _) in allGroupPermissionList(peer: peer, expandMedia: false) {
|
||||
if groupPermissionDependencies(right).contains(rights) {
|
||||
effectiveRightsFlags.insert(right)
|
||||
}
|
||||
|
|
@ -656,7 +655,7 @@ public func channelBannedMemberController(context: AccountContext, updatedPresen
|
|||
|
||||
for item in banSendMediaSubList() {
|
||||
effectiveRightsFlags.insert(item.0)
|
||||
for (right, _) in allGroupPermissionList(peer: EnginePeer(peer), expandMedia: false) {
|
||||
for (right, _) in allGroupPermissionList(peer: peer, expandMedia: false) {
|
||||
if groupPermissionDependencies(right).contains(item.0) {
|
||||
effectiveRightsFlags.insert(right)
|
||||
}
|
||||
|
|
@ -669,7 +668,7 @@ public func channelBannedMemberController(context: AccountContext, updatedPresen
|
|||
effectiveRightsFlags = effectiveRightsFlags.subtracting(groupPermissionDependencies(rights))
|
||||
} else {
|
||||
effectiveRightsFlags.insert(rights)
|
||||
for (right, _) in allGroupPermissionList(peer: EnginePeer(peer), expandMedia: false) {
|
||||
for (right, _) in allGroupPermissionList(peer: peer, expandMedia: false) {
|
||||
if groupPermissionDependencies(right).contains(rights) {
|
||||
effectiveRightsFlags.insert(right)
|
||||
}
|
||||
|
|
@ -681,10 +680,10 @@ public func channelBannedMemberController(context: AccountContext, updatedPresen
|
|||
}
|
||||
})
|
||||
}, toggleRightWhileDisabled: { right in
|
||||
let _ = (peerView.get()
|
||||
let _ = (peerSignal.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { view in
|
||||
guard let channel = view.peers[view.peerId] as? TelegramChannel else {
|
||||
|> deliverOnMainQueue).start(next: { peer in
|
||||
guard case let .channel(channel) = peer else {
|
||||
return
|
||||
}
|
||||
guard let defaultBannedRights = channel.defaultBannedRights else {
|
||||
|
|
@ -839,16 +838,16 @@ public func channelBannedMemberController(context: AccountContext, updatedPresen
|
|||
var footerButtonTitle: String = presentationData.strings.GroupPermission_SaveChanges
|
||||
|
||||
let rightButtonActionImpl = {
|
||||
let _ = (peerView.get()
|
||||
let _ = (peerSignal.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { view in
|
||||
|> deliverOnMainQueue).start(next: { peer in
|
||||
var defaultBannedRightsFlagsValue: TelegramChatBannedRightsFlags?
|
||||
guard let peer = view.peers[peerId] else {
|
||||
guard let peer else {
|
||||
return
|
||||
}
|
||||
if let channel = peer as? TelegramChannel, let initialRightFlags = channel.defaultBannedRights?.flags {
|
||||
if case let .channel(channel) = peer, let initialRightFlags = channel.defaultBannedRights?.flags {
|
||||
defaultBannedRightsFlagsValue = initialRightFlags
|
||||
} else if let group = peer as? TelegramGroup, let initialRightFlags = group.defaultBannedRights?.flags {
|
||||
} else if case let .legacyGroup(group) = peer, let initialRightFlags = group.defaultBannedRights?.flags {
|
||||
defaultBannedRightsFlagsValue = initialRightFlags
|
||||
}
|
||||
guard let defaultBannedRightsFlags = defaultBannedRightsFlagsValue else {
|
||||
|
|
@ -933,7 +932,7 @@ public func channelBannedMemberController(context: AccountContext, updatedPresen
|
|||
previousRights = banInfo?.rights
|
||||
}
|
||||
|
||||
let updateRankSignal: (PeerId) -> Signal<Void, NoError>
|
||||
let updateRankSignal: (EnginePeer.Id) -> Signal<Void, NoError>
|
||||
if let updateRank {
|
||||
updateRankSignal = { peerId in
|
||||
return context.peerChannelMemberCategoriesContextsManager.updateMemberRank(engine: context.engine, peerId: peerId, memberId: memberId, rank: updateRank)
|
||||
|
|
@ -965,7 +964,7 @@ public func channelBannedMemberController(context: AccountContext, updatedPresen
|
|||
if peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||
let signal = context.engine.peers.convertGroupToSupergroup(peerId: peerId)
|
||||
|> map(Optional.init)
|
||||
|> `catch` { error -> Signal<PeerId?, NoError> in
|
||||
|> `catch` { error -> Signal<EnginePeer.Id?, NoError> in
|
||||
switch error {
|
||||
case .tooManyChannels:
|
||||
Queue.mainQueue().async {
|
||||
|
|
@ -976,7 +975,7 @@ public func channelBannedMemberController(context: AccountContext, updatedPresen
|
|||
}
|
||||
return .single(nil)
|
||||
}
|
||||
|> mapToSignal { upgradedPeerId -> Signal<PeerId?, NoError> in
|
||||
|> mapToSignal { upgradedPeerId -> Signal<EnginePeer.Id?, NoError> in
|
||||
guard let upgradedPeerId = upgradedPeerId else {
|
||||
return .single(nil)
|
||||
}
|
||||
|
|
@ -984,9 +983,9 @@ public func channelBannedMemberController(context: AccountContext, updatedPresen
|
|||
let rankSignal = updateRankSignal(upgradedPeerId)
|
||||
|
||||
return context.peerChannelMemberCategoriesContextsManager.updateMemberBannedRights(engine: context.engine, peerId: upgradedPeerId, memberId: memberId, bannedRights: cleanResolvedRights)
|
||||
|> mapToSignal { _ -> Signal<PeerId?, NoError> in
|
||||
|> mapToSignal { _ -> Signal<EnginePeer.Id?, NoError> in
|
||||
return rankSignal
|
||||
|> mapToSignal { _ -> Signal<PeerId?, NoError> in
|
||||
|> mapToSignal { _ -> Signal<EnginePeer.Id?, NoError> in
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -431,7 +431,7 @@ public func channelBlacklistController(context: AccountContext, updatedPresentat
|
|||
})
|
||||
})
|
||||
|
||||
let (listDisposable, loadMoreControl) = context.peerChannelMemberCategoriesContextsManager.banned(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, updated: { listState in
|
||||
let (listDisposable, loadMoreControl) = context.peerChannelMemberCategoriesContextsManager.banned(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, updated: { listState in
|
||||
if case .loading(true) = listState.loadingState, listState.list.isEmpty {
|
||||
blacklistPromise.set(.single(nil))
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import ItemListPeerActionItem
|
|||
import InviteLinksUI
|
||||
import UndoUI
|
||||
import SendInviteLinkScreen
|
||||
import Postbox
|
||||
|
||||
private final class ChannelMembersControllerArguments {
|
||||
let context: AccountContext
|
||||
|
|
@ -394,7 +393,7 @@ private struct ChannelMembersControllerState: Equatable {
|
|||
}
|
||||
}
|
||||
|
||||
private func channelMembersControllerEntries(context: AccountContext, presentationData: PresentationData, view: PeerView, state: ChannelMembersControllerState, contacts: [RenderedChannelParticipant]?, participants: [RenderedChannelParticipant]?, isGroup: Bool) -> [ChannelMembersEntry] {
|
||||
private func channelMembersControllerEntries(context: AccountContext, presentationData: PresentationData, view: EngineRawPeerView, state: ChannelMembersControllerState, contacts: [RenderedChannelParticipant]?, participants: [RenderedChannelParticipant]?, isGroup: Bool) -> [ChannelMembersEntry] {
|
||||
if participants == nil || participants?.count == nil {
|
||||
return []
|
||||
}
|
||||
|
|
@ -721,10 +720,10 @@ public func channelMembersController(context: AccountContext, updatedPresentatio
|
|||
|
||||
let peerView = context.account.viewTracker.peerView(peerId)
|
||||
|
||||
let (contactsDisposable, _) = context.peerChannelMemberCategoriesContextsManager.contacts(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: nil, updated: { state in
|
||||
let (contactsDisposable, _) = context.peerChannelMemberCategoriesContextsManager.contacts(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: nil, updated: { state in
|
||||
contactsPromise.set(.single(state.list))
|
||||
})
|
||||
let (disposable, loadMoreControl) = context.peerChannelMemberCategoriesContextsManager.recent(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, updated: { state in
|
||||
let (disposable, loadMoreControl) = context.peerChannelMemberCategoriesContextsManager.recent(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, updated: { state in
|
||||
peersPromise.set(.single(state.list))
|
||||
})
|
||||
actionsDisposable.add(disposable)
|
||||
|
|
|
|||
|
|
@ -263,13 +263,13 @@ private func categorySignal(context: AccountContext, peerId: EnginePeer.Id, cate
|
|||
}
|
||||
switch category {
|
||||
case .admins:
|
||||
disposableAndLoadMoreControl = context.peerChannelMemberCategoriesContextsManager.admins(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: nil, updated: processListState)
|
||||
disposableAndLoadMoreControl = context.peerChannelMemberCategoriesContextsManager.admins(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: nil, updated: processListState)
|
||||
case .contacts:
|
||||
disposableAndLoadMoreControl = context.peerChannelMemberCategoriesContextsManager.contacts(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: nil, updated: processListState)
|
||||
disposableAndLoadMoreControl = context.peerChannelMemberCategoriesContextsManager.contacts(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: nil, updated: processListState)
|
||||
case .bots:
|
||||
disposableAndLoadMoreControl = context.peerChannelMemberCategoriesContextsManager.bots(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: nil, updated: processListState)
|
||||
disposableAndLoadMoreControl = context.peerChannelMemberCategoriesContextsManager.bots(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: nil, updated: processListState)
|
||||
case .members:
|
||||
disposableAndLoadMoreControl = context.peerChannelMemberCategoriesContextsManager.recent(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: nil, updated: processListState)
|
||||
disposableAndLoadMoreControl = context.peerChannelMemberCategoriesContextsManager.recent(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: nil, updated: processListState)
|
||||
}
|
||||
|
||||
let (disposable, _) = disposableAndLoadMoreControl
|
||||
|
|
@ -637,7 +637,7 @@ public final class ChannelMembersSearchContainerNode: SearchDisplayControllerCon
|
|||
switch mode {
|
||||
case .searchMembers, .banAndPromoteActions:
|
||||
foundGroupMembers = Signal { subscriber in
|
||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.recent(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: query, updated: { state in
|
||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.recent(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: query, updated: { state in
|
||||
if case .ready = state.loadingState {
|
||||
subscriber.putNext(state.list)
|
||||
}
|
||||
|
|
@ -652,7 +652,7 @@ public final class ChannelMembersSearchContainerNode: SearchDisplayControllerCon
|
|||
|> map { $0 ?? [] }
|
||||
case .searchAdmins:
|
||||
foundGroupMembers = Signal { subscriber in
|
||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.admins(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: query, updated: { state in
|
||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.admins(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: query, updated: { state in
|
||||
if case .ready = state.loadingState {
|
||||
subscriber.putNext(state.list)
|
||||
}
|
||||
|
|
@ -662,7 +662,7 @@ public final class ChannelMembersSearchContainerNode: SearchDisplayControllerCon
|
|||
foundMembers = .single([])
|
||||
case .searchBanned:
|
||||
foundGroupMembers = Signal { subscriber in
|
||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.restricted(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: query, updated: { state in
|
||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.restricted(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: query, updated: { state in
|
||||
if case .ready = state.loadingState {
|
||||
subscriber.putNext(state.list)
|
||||
subscriber.putCompletion()
|
||||
|
|
@ -672,7 +672,7 @@ public final class ChannelMembersSearchContainerNode: SearchDisplayControllerCon
|
|||
}
|
||||
|> runOn(Queue.mainQueue())
|
||||
foundMembers = Signal { subscriber in
|
||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.recent(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: query, updated: { state in
|
||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.recent(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: query, updated: { state in
|
||||
if case .ready = state.loadingState {
|
||||
subscriber.putNext(state.list.filter({ participant in
|
||||
return participant.peer.id != context.account.peerId
|
||||
|
|
@ -684,7 +684,7 @@ public final class ChannelMembersSearchContainerNode: SearchDisplayControllerCon
|
|||
|> runOn(Queue.mainQueue())
|
||||
case .searchKicked:
|
||||
foundGroupMembers = Signal { subscriber in
|
||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.banned(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: query, updated: { state in
|
||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.banned(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: query, updated: { state in
|
||||
if case .ready = state.loadingState {
|
||||
subscriber.putNext(state.list)
|
||||
subscriber.putCompletion()
|
||||
|
|
|
|||
|
|
@ -439,12 +439,12 @@ class ChannelMembersSearchControllerNode: ASDisplayNode {
|
|||
} else {
|
||||
let membersState = Promise<ChannelMemberListState>()
|
||||
|
||||
disposableAndLoadMoreControl = context.peerChannelMemberCategoriesContextsManager.recent(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, updated: { state in
|
||||
disposableAndLoadMoreControl = context.peerChannelMemberCategoriesContextsManager.recent(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, updated: { state in
|
||||
membersState.set(.single(state))
|
||||
})
|
||||
|
||||
let contactsState = Promise<ChannelMemberListState>()
|
||||
contactsDisposableAndLoadMoreControl = context.peerChannelMemberCategoriesContextsManager.contacts(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: nil, updated: { state in
|
||||
contactsDisposableAndLoadMoreControl = context.peerChannelMemberCategoriesContextsManager.contacts(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: nil, updated: { state in
|
||||
contactsState.set(.single(state))
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import TelegramPermissionsUI
|
|||
import ItemListPeerActionItem
|
||||
import Markdown
|
||||
import UndoUI
|
||||
import Postbox
|
||||
import OldChannelsController
|
||||
import MessagePriceItem
|
||||
|
||||
|
|
@ -683,7 +682,7 @@ func groupPermissionDependencies(_ right: TelegramChatBannedRightsFlags) -> Tele
|
|||
}
|
||||
}
|
||||
|
||||
private func channelPermissionsControllerEntries(context: AccountContext, presentationData: PresentationData, view: PeerView, state: ChannelPermissionsControllerState, participants: [RenderedChannelParticipant]?, configuration: StarsSubscriptionConfiguration) -> [ChannelPermissionsEntry] {
|
||||
private func channelPermissionsControllerEntries(context: AccountContext, presentationData: PresentationData, view: EngineRawPeerView, state: ChannelPermissionsControllerState, participants: [RenderedChannelParticipant]?, configuration: StarsSubscriptionConfiguration) -> [ChannelPermissionsEntry] {
|
||||
var entries: [ChannelPermissionsEntry] = []
|
||||
|
||||
if let channel = view.peers[view.peerId] as? TelegramChannel, let participants = participants, let cachedData = view.cachedData as? CachedChannelData, let defaultBannedRights = channel.defaultBannedRights {
|
||||
|
|
@ -870,7 +869,7 @@ public func channelPermissionsController(context: AccountContext, updatedPresent
|
|||
peersPromise.set(.single((peerId, nil)))
|
||||
} else {
|
||||
var loadCompletedCalled = false
|
||||
let disposableAndLoadMoreControl = context.peerChannelMemberCategoriesContextsManager.restricted(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, updated: { state in
|
||||
let disposableAndLoadMoreControl = context.peerChannelMemberCategoriesContextsManager.restricted(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, updated: { state in
|
||||
if case .loading(true) = state.loadingState, !updated {
|
||||
peersPromise.set(.single((peerId, nil)))
|
||||
} else {
|
||||
|
|
@ -897,7 +896,7 @@ public func channelPermissionsController(context: AccountContext, updatedPresent
|
|||
let updateSendPaidMessageStarsDisposable = MetaDisposable()
|
||||
actionsDisposable.add(updateSendPaidMessageStarsDisposable)
|
||||
|
||||
let peerView = Promise<PeerView>()
|
||||
let peerView = Promise<EngineRawPeerView>()
|
||||
peerView.set(sourcePeerId.get()
|
||||
|> mapToSignal(context.account.viewTracker.peerView))
|
||||
|
||||
|
|
@ -1313,7 +1312,7 @@ public func channelPermissionsController(context: AccountContext, updatedPresent
|
|||
let previousParticipants = Atomic<[RenderedChannelParticipant]?>(value: nil)
|
||||
|
||||
let viewAndParticipants = combineLatest(queue: .mainQueue(), sourcePeerId.get(), peerView.get(), peersPromise.get())
|
||||
|> mapToSignal { peerIdAndChanged, view, peers -> Signal<(PeerView, [RenderedChannelParticipant]?), NoError> in
|
||||
|> mapToSignal { peerIdAndChanged, view, peers -> Signal<(EngineRawPeerView, [RenderedChannelParticipant]?), NoError> in
|
||||
let (peerId, changed) = peerIdAndChanged
|
||||
if view.peerId != peerId {
|
||||
return .complete()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import UIKit
|
|||
import Display
|
||||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
|
|
@ -795,7 +794,7 @@ private struct ChannelVisibilityControllerState: Equatable {
|
|||
self.approveMembers = nil
|
||||
}
|
||||
|
||||
init(selectedType: CurrentChannelType?, editingPublicLinkText: String?, addressNameValidationStatus: AddressNameValidationStatus?, updatingAddressName: Bool, revealedRevokePeerId: PeerId?, revokingPeerId: PeerId?, revokingPrivateLink: Bool, forwardingEnabled: Bool?, joinToSend: CurrentChannelJoinToSend?, approveMembers: Bool?) {
|
||||
init(selectedType: CurrentChannelType?, editingPublicLinkText: String?, addressNameValidationStatus: AddressNameValidationStatus?, updatingAddressName: Bool, revealedRevokePeerId: EnginePeer.Id?, revokingPeerId: EnginePeer.Id?, revokingPrivateLink: Bool, forwardingEnabled: Bool?, joinToSend: CurrentChannelJoinToSend?, approveMembers: Bool?) {
|
||||
self.selectedType = selectedType
|
||||
self.editingPublicLinkText = editingPublicLinkText
|
||||
self.addressNameValidationStatus = addressNameValidationStatus
|
||||
|
|
@ -883,7 +882,7 @@ private struct ChannelVisibilityControllerState: Equatable {
|
|||
}
|
||||
}
|
||||
|
||||
private func channelVisibilityControllerEntries(presentationData: PresentationData, mode: ChannelVisibilityControllerMode, view: PeerView, publicChannelsToRevoke: [EnginePeer]?, importers: PeerInvitationImportersState?, state: ChannelVisibilityControllerState, limits: EngineConfiguration.UserLimits, premiumLimits: EngineConfiguration.UserLimits, isPremium: Bool, isPremiumDisabled: Bool, temporaryOrder: [String]?) -> [ChannelVisibilityEntry] {
|
||||
private func channelVisibilityControllerEntries(presentationData: PresentationData, mode: ChannelVisibilityControllerMode, view: EngineRawPeerView, publicChannelsToRevoke: [EnginePeer]?, importers: PeerInvitationImportersState?, state: ChannelVisibilityControllerState, limits: EngineConfiguration.UserLimits, premiumLimits: EngineConfiguration.UserLimits, isPremium: Bool, isPremiumDisabled: Bool, temporaryOrder: [String]?) -> [ChannelVisibilityEntry] {
|
||||
var entries: [ChannelVisibilityEntry] = []
|
||||
|
||||
let isInitialSetup: Bool
|
||||
|
|
@ -1321,7 +1320,7 @@ private func channelVisibilityControllerEntries(presentationData: PresentationDa
|
|||
return entries
|
||||
}
|
||||
|
||||
private func effectiveChannelType(mode: ChannelVisibilityControllerMode, state: ChannelVisibilityControllerState, peer: TelegramChannel, cachedData: CachedPeerData?) -> CurrentChannelType {
|
||||
private func effectiveChannelType(mode: ChannelVisibilityControllerMode, state: ChannelVisibilityControllerState, peer: TelegramChannel, cachedData: EngineCachedPeerData?) -> CurrentChannelType {
|
||||
let selectedType: CurrentChannelType
|
||||
if let current = state.selectedType {
|
||||
selectedType = current
|
||||
|
|
@ -1339,7 +1338,7 @@ private func effectiveChannelType(mode: ChannelVisibilityControllerMode, state:
|
|||
return selectedType
|
||||
}
|
||||
|
||||
private func updatedAddressName(mode: ChannelVisibilityControllerMode, state: ChannelVisibilityControllerState, peer: EnginePeer, cachedData: CachedPeerData?) -> String? {
|
||||
private func updatedAddressName(mode: ChannelVisibilityControllerMode, state: ChannelVisibilityControllerState, peer: EnginePeer, cachedData: EngineCachedPeerData?) -> String? {
|
||||
if case let .channel(peer) = peer {
|
||||
let selectedType = effectiveChannelType(mode: mode, state: state, peer: peer, cachedData: cachedData)
|
||||
|
||||
|
|
@ -1995,12 +1994,12 @@ public func channelVisibilityController(context: AccountContext, updatedPresenta
|
|||
_ = ApplicationSpecificNotice.markAsSeenSetPublicChannelLink(accountManager: context.sharedContext.accountManager).start()
|
||||
|
||||
let signal = context.engine.peers.convertGroupToSupergroup(peerId: peerId)
|
||||
|> mapToSignal { upgradedPeerId -> Signal<PeerId?, ConvertGroupToSupergroupError> in
|
||||
|> mapToSignal { upgradedPeerId -> Signal<EnginePeer.Id?, ConvertGroupToSupergroupError> in
|
||||
return context.engine.peers.updateAddressName(domain: .peer(upgradedPeerId), name: updatedAddressNameValue.isEmpty ? nil : updatedAddressNameValue)
|
||||
|> `catch` { _ -> Signal<Void, NoError> in
|
||||
return .complete()
|
||||
}
|
||||
|> mapToSignal { _ -> Signal<PeerId?, NoError> in
|
||||
|> mapToSignal { _ -> Signal<EnginePeer.Id?, NoError> in
|
||||
return .complete()
|
||||
}
|
||||
|> then(.single(upgradedPeerId))
|
||||
|
|
@ -2305,7 +2304,7 @@ public func channelVisibilityController(context: AccountContext, updatedPresenta
|
|||
peerIds = peerIdsValue
|
||||
}
|
||||
|
||||
let filteredPeerIds = peerIds.compactMap({ peerId -> PeerId? in
|
||||
let filteredPeerIds = peerIds.compactMap({ peerId -> EnginePeer.Id? in
|
||||
if case let .peer(id) = peerId {
|
||||
return id
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -3102,7 +3102,8 @@ private func drawAlbumArtPlaceholder(into c: CGContext, arguments: TransformImag
|
|||
}
|
||||
}
|
||||
|
||||
public func playerAlbumArt(postbox: Postbox, engine: TelegramEngine, fileReference: FileMediaReference?, albumArt: SharedMediaPlaybackAlbumArt?, thumbnail: Bool, overlayColor: UIColor? = nil, emptyColor: UIColor? = nil, drawPlaceholderWhenEmpty: Bool = true, attemptSynchronously: Bool = false) -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> {
|
||||
public func playerAlbumArt(engine: TelegramEngine, fileReference: FileMediaReference?, albumArt: SharedMediaPlaybackAlbumArt?, thumbnail: Bool, overlayColor: UIColor? = nil, emptyColor: UIColor? = nil, drawPlaceholderWhenEmpty: Bool = true, attemptSynchronously: Bool = false) -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> {
|
||||
let postbox = engine.account.postbox
|
||||
var fileArtworkData: Signal<Data?, NoError> = .single(nil)
|
||||
if let fileReference = fileReference {
|
||||
let size = thumbnail ? CGSize(width: 48.0, height: 48.0) : CGSize(width: 320.0, height: 320.0)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import AsyncDisplayKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import AccountContext
|
||||
|
|
@ -556,21 +555,10 @@ private final class DemoSheetContent: CombinedComponent {
|
|||
EngineDataMap(accountSpecificStickerOverrides.map(\.messageId).map(TelegramEngine.EngineData.Item.Messages.Message.init))
|
||||
)
|
||||
|
||||
let stickersKey: PostboxViewKey = .orderedItemList(id: Namespaces.OrderedItemList.CloudPremiumStickers)
|
||||
self.disposable = (combineLatest(
|
||||
queue: Queue.mainQueue(),
|
||||
self.context.engine.stickers.availableReactions(),
|
||||
self.context.account.postbox.combinedView(keys: [stickersKey])
|
||||
|> map { views -> [OrderedItemListEntry]? in
|
||||
if let view = views.views[stickersKey] as? OrderedItemListView {
|
||||
return view.items
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|> filter { items in
|
||||
return items != nil
|
||||
}
|
||||
self.context.engine.data.subscribe(TelegramEngine.EngineData.Item.OrderedLists.ListItems(collectionId: Namespaces.OrderedItemList.CloudPremiumStickers))
|
||||
|> take(1),
|
||||
self.context.engine.data.get(
|
||||
TelegramEngine.EngineData.Item.Peer.Peer(id: self.context.account.peerId),
|
||||
|
|
@ -604,11 +592,9 @@ private final class DemoSheetContent: CombinedComponent {
|
|||
|
||||
if let reactions = reactions {
|
||||
var result: [TelegramMediaFile] = []
|
||||
if let items = items {
|
||||
for item in items {
|
||||
if let mediaItem = item.contents.get(RecentMediaItem.self) {
|
||||
result.append(mediaItem.media._parse())
|
||||
}
|
||||
for item in items {
|
||||
if let mediaItem = item.contents.get(RecentMediaItem.self) {
|
||||
result.append(mediaItem.media._parse())
|
||||
}
|
||||
}
|
||||
return (reactions.reactions.filter({ $0.isPremium }).map { reaction -> AvailableReactions.Reaction in
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import Display
|
|||
import ComponentFlow
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import PresentationDataUtils
|
||||
import ViewControllerComponent
|
||||
|
|
@ -154,13 +153,13 @@ private final class PremiumGiftScreenContentComponent: CombinedComponent {
|
|||
|
||||
let _ = updatePremiumPromoConfigurationOnce(account: context.account).start()
|
||||
|
||||
let stickersKey: PostboxViewKey = .orderedItemList(id: Namespaces.OrderedItemList.CloudPremiumStickers)
|
||||
let stickersKey: EngineRawPostboxViewKey = .orderedItemList(id: Namespaces.OrderedItemList.CloudPremiumStickers)
|
||||
self.stickersDisposable = (self.context.account.postbox.combinedView(keys: [stickersKey])
|
||||
|> deliverOnMainQueue).start(next: { [weak self] views in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
if let view = views.views[stickersKey] as? OrderedItemListView {
|
||||
if let view = views.views[stickersKey] as? EngineRawOrderedItemListView {
|
||||
for item in view.items {
|
||||
if let mediaItem = item.contents.get(RecentMediaItem.self) {
|
||||
let file = mediaItem.media._parse()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import UIKit
|
|||
import Display
|
||||
import AsyncDisplayKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import AccountContext
|
||||
import TelegramPresentationData
|
||||
|
|
@ -103,20 +102,9 @@ public class PremiumLimitsListScreen: ViewController {
|
|||
|
||||
self.appIcons = controller.context.sharedContext.applicationBindings.getAvailableAlternateIcons()
|
||||
|
||||
let stickersKey: PostboxViewKey = .orderedItemList(id: Namespaces.OrderedItemList.CloudPremiumStickers)
|
||||
self.disposable = (combineLatest(
|
||||
queue: Queue.mainQueue(),
|
||||
context.account.postbox.combinedView(keys: [stickersKey])
|
||||
|> map { views -> [OrderedItemListEntry]? in
|
||||
if let view = views.views[stickersKey] as? OrderedItemListView {
|
||||
return view.items
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|> filter { items in
|
||||
return items != nil
|
||||
}
|
||||
context.engine.data.subscribe(TelegramEngine.EngineData.Item.OrderedLists.ListItems(collectionId: Namespaces.OrderedItemList.CloudPremiumStickers))
|
||||
|> take(1),
|
||||
context.engine.data.get(
|
||||
TelegramEngine.EngineData.Item.Peer.Peer(id: context.account.peerId),
|
||||
|
|
@ -137,11 +125,9 @@ public class PremiumLimitsListScreen: ViewController {
|
|||
}
|
||||
|
||||
var result: [TelegramMediaFile.Accessor] = []
|
||||
if let items = items {
|
||||
for item in items {
|
||||
if let mediaItem = item.contents.get(RecentMediaItem.self) {
|
||||
result.append(mediaItem.media)
|
||||
}
|
||||
for item in items {
|
||||
if let mediaItem = item.contents.get(RecentMediaItem.self) {
|
||||
result.append(mediaItem.media)
|
||||
}
|
||||
}
|
||||
return (result.map { file -> TelegramMediaFile in
|
||||
|
|
|
|||
|
|
@ -643,16 +643,15 @@ public final class ReactionContextNode: ASDisplayNode, ASScrollViewDelegate {
|
|||
}
|
||||
|
||||
if let getEmojiContent = getEmojiContent, !self.reactionsLocked {
|
||||
let viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedEmojiPacks)
|
||||
self.stableEmptyResultEmojiDisposable.set((self.context.account.postbox.combinedView(keys: [viewKey])
|
||||
self.stableEmptyResultEmojiDisposable.set((self.context.engine.data.subscribe(TelegramEngine.EngineData.Item.OrderedLists.ListItems(collectionId: Namespaces.OrderedItemList.CloudFeaturedEmojiPacks))
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] views in
|
||||
guard let strongSelf = self, let view = views.views[viewKey] as? OrderedItemListView else {
|
||||
|> deliverOnMainQueue).start(next: { [weak self] items in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
var filteredFiles: [TelegramMediaFile] = []
|
||||
let filterList: [String] = ["😖", "😫", "🫠", "😨", "❓"]
|
||||
for featuredEmojiPack in view.items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
for featuredEmojiPack in items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
for item in featuredEmojiPack.topItems {
|
||||
if let alt = item.file.customEmojiAlt {
|
||||
if filterList.contains(alt) {
|
||||
|
|
@ -1743,20 +1742,19 @@ public final class ReactionContextNode: ASDisplayNode, ASScrollViewDelegate {
|
|||
return
|
||||
}
|
||||
|
||||
let viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedEmojiPacks)
|
||||
let _ = (strongSelf.context.account.postbox.combinedView(keys: [viewKey])
|
||||
let _ = (strongSelf.context.engine.data.subscribe(TelegramEngine.EngineData.Item.OrderedLists.ListItems(collectionId: Namespaces.OrderedItemList.CloudFeaturedEmojiPacks))
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { views in
|
||||
guard let strongSelf = self, let view = views.views[viewKey] as? OrderedItemListView else {
|
||||
|> deliverOnMainQueue).start(next: { items in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
for featuredEmojiPack in view.items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
for featuredEmojiPack in items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
if featuredEmojiPack.info.id == collectionId {
|
||||
if let strongSelf = self {
|
||||
strongSelf.scheduledEmojiContentAnimationHint = EmojiPagerContentComponent.ContentAnimation(type: .groupInstalled(id: collectionId, scrollToGroup: true))
|
||||
}
|
||||
let _ = strongSelf.context.engine.stickers.addStickerPackInteractively(info: featuredEmojiPack.info._parse(), items: featuredEmojiPack.topItems).start()
|
||||
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -2039,14 +2037,14 @@ public final class ReactionContextNode: ASDisplayNode, ASScrollViewDelegate {
|
|||
let remoteSignal = emojiSearchContext.state
|
||||
|
||||
return combineLatest(
|
||||
context.account.postbox.itemCollectionsView(orderedItemListCollectionIds: [], namespaces: [Namespaces.ItemCollection.CloudEmojiPacks], aroundIndex: nil, count: 10000000) |> take(1),
|
||||
context.engine.itemCollections.allItems(namespace: Namespaces.ItemCollection.CloudEmojiPacks) |> take(1),
|
||||
context.engine.stickers.availableReactions() |> take(1),
|
||||
hasPremium |> take(1),
|
||||
remotePacksSignal,
|
||||
remoteSignal,
|
||||
localPacksSignal
|
||||
)
|
||||
|> map { view, availableReactions, hasPremium, foundPacks, foundEmoji, foundLocalPacks -> (groups: [EmojiPagerContentComponent.ItemGroup], canLoadMore: Bool, isSearching: Bool, searchContext: EmojiSearchContext?) in
|
||||
|> map { rawItems, availableReactions, hasPremium, foundPacks, foundEmoji, foundLocalPacks -> (groups: [EmojiPagerContentComponent.ItemGroup], canLoadMore: Bool, isSearching: Bool, searchContext: EmojiSearchContext?) in
|
||||
var result: [(String, TelegramMediaFile.Accessor?, String)] = []
|
||||
|
||||
var allEmoticons: [String: String] = [:]
|
||||
|
|
@ -2071,8 +2069,8 @@ public final class ReactionContextNode: ASDisplayNode, ASScrollViewDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
for entry in view.entries {
|
||||
guard let item = entry.item as? StickerPackItem else {
|
||||
for rawItem in rawItems {
|
||||
guard let item = rawItem as? StickerPackItem else {
|
||||
continue
|
||||
}
|
||||
if !item.file.isPremiumEmoji {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public func searchPeerMembers(context: AccountContext, peerId: EnginePeer.Id, ch
|
|||
|> mapToSignal { participantCount -> Signal<([EnginePeer], Bool), NoError> in
|
||||
if case .peer = chatLocation, let memberCount = participantCount, memberCount <= 64 {
|
||||
return Signal { subscriber in
|
||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.recent(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: nil, requestUpdate: false, updated: { state in
|
||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.recent(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: nil, requestUpdate: false, updated: { state in
|
||||
if case .ready = state.loadingState {
|
||||
subscriber.putNext((state.list.compactMap { participant -> EnginePeer? in
|
||||
if participant.peer.isDeleted {
|
||||
|
|
@ -52,7 +52,7 @@ public func searchPeerMembers(context: AccountContext, peerId: EnginePeer.Id, ch
|
|||
return Signal { subscriber in
|
||||
switch chatLocation {
|
||||
case let .peer(peerId):
|
||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.recent(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: normalizedQuery.isEmpty ? nil : normalizedQuery, updated: { state in
|
||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.recent(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, searchQuery: normalizedQuery.isEmpty ? nil : normalizedQuery, updated: { state in
|
||||
if case .ready = state.loadingState {
|
||||
subscriber.putNext((state.list.compactMap { participant in
|
||||
if participant.peer.isDeleted {
|
||||
|
|
@ -67,7 +67,7 @@ public func searchPeerMembers(context: AccountContext, peerId: EnginePeer.Id, ch
|
|||
disposable.dispose()
|
||||
}
|
||||
case let .replyThread(replyThreadMessage):
|
||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.mentions(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, threadMessageId: EngineMessage.Id(peerId: replyThreadMessage.peerId, namespace: Namespaces.Message.Cloud, id: Int32(clamping: replyThreadMessage.threadId)), searchQuery: normalizedQuery.isEmpty ? nil : normalizedQuery, updated: { state in
|
||||
let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.mentions(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, threadMessageId: EngineMessage.Id(peerId: replyThreadMessage.peerId, namespace: Namespaces.Message.Cloud, id: Int32(clamping: replyThreadMessage.threadId)), searchQuery: normalizedQuery.isEmpty ? nil : normalizedQuery, updated: { state in
|
||||
if case .ready = state.loadingState {
|
||||
subscriber.putNext((state.list.compactMap { participant in
|
||||
if participant.peer.isDeleted {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import AsyncDisplayKit
|
||||
import TelegramCore
|
||||
|
|
@ -159,30 +158,30 @@ private final class BubbleSettingsControllerNode: ASDisplayNode, ASScrollViewDel
|
|||
let headerItem = self.context.sharedContext.makeChatMessageDateHeaderItem(context: self.context, timestamp: self.referenceTimestamp, theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder)
|
||||
|
||||
var items: [ListViewItem] = []
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1))
|
||||
let peerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(1))
|
||||
let otherPeerId = self.context.account.peerId
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
var messages = SimpleDictionary<MessageId, Message>()
|
||||
var peers = EngineSimpleDictionary<EnginePeer.Id, EngineRawPeer>()
|
||||
var messages = EngineSimpleDictionary<EngineMessage.Id, EngineRawMessage>()
|
||||
peers[peerId] = TelegramUser(id: peerId, accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_Chat_2_ReplyName, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: .preset(.blue), backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
peers[otherPeerId] = TelegramUser(id: otherPeerId, accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_Chat_2_ReplyName, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: .preset(.blue), backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
|
||||
let replyMessageId = MessageId(peerId: peerId, namespace: 0, id: 3)
|
||||
messages[replyMessageId] = Message(stableId: 3, stableVersion: 0, id: replyMessageId, globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_1_Text, attributes: [], media: [], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let replyMessageId = EngineMessage.Id(peerId: peerId, namespace: 0, id: 3)
|
||||
messages[replyMessageId] = EngineRawMessage(stableId: 3, stableVersion: 0, id: replyMessageId, globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_1_Text, attributes: [], media: [], peers: peers, associatedMessages: EngineSimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
|
||||
let message1 = Message(stableId: 4, stableVersion: 0, id: MessageId(peerId: otherPeerId, namespace: 0, id: 4), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66003, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_3_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message1 = EngineRawMessage(stableId: 4, stableVersion: 0, id: EngineMessage.Id(peerId: otherPeerId, namespace: 0, id: 4), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66003, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_3_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
items.append(self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, messages: [message1], theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: self.chatBackgroundNode, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil))
|
||||
|
||||
let message2 = Message(stableId: 3, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 3), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66002, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_2_Text, attributes: [ReplyMessageAttribute(messageId: replyMessageId, threadMessageId: nil, quote: nil, isQuote: false, innerSubject: nil)], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message2 = EngineRawMessage(stableId: 3, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id: 3), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66002, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_2_Text, attributes: [ReplyMessageAttribute(messageId: replyMessageId, threadMessageId: nil, quote: nil, isQuote: false, innerSubject: nil)], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
items.append(self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, messages: [message2], theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: self.chatBackgroundNode, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil))
|
||||
|
||||
let waveformBase64 = "DAAOAAkACQAGAAwADwAMABAADQAPABsAGAALAA0AGAAfABoAHgATABgAGQAYABQADAAVABEAHwANAA0ACQAWABkACQAOAAwACQAfAAAAGQAVAAAAEwATAAAACAAfAAAAHAAAABwAHwAAABcAGQAAABQADgAAABQAHwAAAB8AHwAAAAwADwAAAB8AEwAAABoAFwAAAB8AFAAAAAAAHwAAAAAAHgAAAAAAHwAAAAAAHwAAAAAAHwAAAAAAHwAAAAAAHwAAAAAAAAA="
|
||||
let voiceAttributes: [TelegramMediaFileAttribute] = [.Audio(isVoice: true, duration: 23, title: nil, performer: nil, waveform: Data(base64Encoded: waveformBase64)!)]
|
||||
let voiceMedia = TelegramMediaFile(fileId: MediaId(namespace: 0, id: 0), partialReference: nil, resource: LocalFileMediaResource(fileId: 0), previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "audio/ogg", size: 0, attributes: voiceAttributes, alternativeRepresentations: [])
|
||||
|
||||
let message3 = Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66001, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: "", attributes: [], media: [voiceMedia], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let voiceMedia = TelegramMediaFile(fileId: EngineMedia.Id(namespace: 0, id: 0), partialReference: nil, resource: LocalFileMediaResource(fileId: 0), previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "audio/ogg", size: 0, attributes: voiceAttributes, alternativeRepresentations: [])
|
||||
|
||||
let message3 = EngineRawMessage(stableId: 1, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66001, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: "", attributes: [], media: [voiceMedia], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
items.append(self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, messages: [message3], theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: FileMediaResourceStatus(mediaStatus: .playbackStatus(.paused), fetchStatus: .Local), tapMessage: nil, clickThroughMessage: nil, backgroundNode: self.chatBackgroundNode, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil))
|
||||
|
||||
let message4 = Message(stableId: 2, stableVersion: 0, id: MessageId(peerId: otherPeerId, namespace: 0, id: 2), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66001, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_1_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message4 = EngineRawMessage(stableId: 2, stableVersion: 0, id: EngineMessage.Id(peerId: otherPeerId, namespace: 0, id: 2), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66001, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_1_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
items.append(self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, messages: [message4], theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: self.chatBackgroundNode, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil))
|
||||
|
||||
let width: CGFloat
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import LegacyComponents
|
||||
import TelegramPresentationData
|
||||
|
|
@ -933,10 +932,10 @@ public func dataAndStorageController(context: AccountContext, focusOnItemTag: Da
|
|||
}
|
||||
})
|
||||
|
||||
let preferencesKey: PostboxViewKey = .preferences(keys: Set([ApplicationSpecificPreferencesKeys.mediaAutoSaveSettings]))
|
||||
let preferencesKey: EngineRawPostboxViewKey = .preferences(keys: Set([ApplicationSpecificPreferencesKeys.mediaAutoSaveSettings]))
|
||||
let preferences = context.account.postbox.combinedView(keys: [preferencesKey])
|
||||
|> map { views -> MediaAutoSaveSettings in
|
||||
guard let view = views.views[preferencesKey] as? PreferencesView else {
|
||||
guard let view = views.views[preferencesKey] as? EngineRawPreferencesView else {
|
||||
return .default
|
||||
}
|
||||
return view.values[ApplicationSpecificPreferencesKeys.mediaAutoSaveSettings]?.get(MediaAutoSaveSettings.self) ?? MediaAutoSaveSettings.default
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import MtProtoKit
|
||||
|
|
@ -329,10 +328,10 @@ public enum ProxySettingsControllerMode {
|
|||
|
||||
public func proxySettingsController(context: AccountContext, mode: ProxySettingsControllerMode = .default, focusOnItemTag: ProxySettingsEntryTag? = nil) -> ViewController {
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
return proxySettingsController(accountManager: context.sharedContext.accountManager, sharedContext: context.sharedContext, context: context, postbox: context.account.postbox, network: context.account.network, mode: mode, presentationData: presentationData, updatedPresentationData: context.sharedContext.presentationData, focusOnItemTag: focusOnItemTag)
|
||||
return proxySettingsController(accountManager: context.sharedContext.accountManager, sharedContext: context.sharedContext, context: context, network: context.account.network, mode: mode, presentationData: presentationData, updatedPresentationData: context.sharedContext.presentationData, focusOnItemTag: focusOnItemTag)
|
||||
}
|
||||
|
||||
public func proxySettingsController(accountManager: AccountManager<TelegramAccountManagerTypes>, sharedContext: SharedAccountContext, context: AccountContext? = nil, postbox: Postbox, network: Network, mode: ProxySettingsControllerMode, presentationData: PresentationData, updatedPresentationData: Signal<PresentationData, NoError>, focusOnItemTag: ProxySettingsEntryTag? = nil) -> ViewController {
|
||||
public func proxySettingsController(accountManager: AccountManager<TelegramAccountManagerTypes>, sharedContext: SharedAccountContext, context: AccountContext? = nil, network: Network, mode: ProxySettingsControllerMode, presentationData: PresentationData, updatedPresentationData: Signal<PresentationData, NoError>, focusOnItemTag: ProxySettingsEntryTag? = nil) -> ViewController {
|
||||
var pushControllerImpl: ((ViewController) -> Void)?
|
||||
var dismissImpl: (() -> Void)?
|
||||
let stateValue = Atomic(value: ProxySettingsControllerState())
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
|
|
@ -515,10 +514,10 @@ public func saveIncomingMediaController(context: AccountContext, scope: SaveInco
|
|||
controller.peerSelected = { [weak controller] peer, _ in
|
||||
let peerId = peer.id
|
||||
|
||||
let preferencesKey: PostboxViewKey = .preferences(keys: Set([ApplicationSpecificPreferencesKeys.mediaAutoSaveSettings]))
|
||||
let preferencesKey: EngineRawPostboxViewKey = .preferences(keys: Set([ApplicationSpecificPreferencesKeys.mediaAutoSaveSettings]))
|
||||
let preferences = context.account.postbox.combinedView(keys: [preferencesKey])
|
||||
|> map { views -> MediaAutoSaveSettings in
|
||||
guard let view = views.views[preferencesKey] as? PreferencesView else {
|
||||
guard let view = views.views[preferencesKey] as? EngineRawPreferencesView else {
|
||||
return .default
|
||||
}
|
||||
return view.values[ApplicationSpecificPreferencesKeys.mediaAutoSaveSettings]?.get(MediaAutoSaveSettings.self) ?? MediaAutoSaveSettings.default
|
||||
|
|
@ -622,10 +621,10 @@ public func saveIncomingMediaController(context: AccountContext, scope: SaveInco
|
|||
}
|
||||
)
|
||||
|
||||
let preferencesKey: PostboxViewKey = .preferences(keys: Set([ApplicationSpecificPreferencesKeys.mediaAutoSaveSettings]))
|
||||
let preferencesKey: EngineRawPostboxViewKey = .preferences(keys: Set([ApplicationSpecificPreferencesKeys.mediaAutoSaveSettings]))
|
||||
let preferences = context.account.postbox.combinedView(keys: [preferencesKey])
|
||||
|> map { views -> MediaAutoSaveSettings in
|
||||
guard let view = views.views[preferencesKey] as? PreferencesView else {
|
||||
guard let view = views.views[preferencesKey] as? EngineRawPreferencesView else {
|
||||
return .default
|
||||
}
|
||||
return view.values[ApplicationSpecificPreferencesKeys.mediaAutoSaveSettings]?.get(MediaAutoSaveSettings.self) ?? MediaAutoSaveSettings.default
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import Display
|
|||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
import ItemListUI
|
||||
|
|
@ -142,16 +141,16 @@ class ForwardPrivacyChatPreviewItemNode: ListViewItemNode {
|
|||
let insets: UIEdgeInsets
|
||||
let separatorHeight = UIScreenPixel
|
||||
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1))
|
||||
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
let messages = SimpleDictionary<MessageId, Message>()
|
||||
let peerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(1))
|
||||
|
||||
var peers = EngineSimpleDictionary<EnginePeer.Id, EngineRawPeer>()
|
||||
let messages = EngineSimpleDictionary<EngineMessage.Id, EngineRawMessage>()
|
||||
|
||||
peers[peerId] = TelegramUser(id: peerId, accessHash: nil, firstName: item.peerName, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: .preset(.blue), backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
|
||||
let forwardInfo = MessageForwardInfo(author: item.linkEnabled ? peers[peerId] : nil, source: nil, sourceMessageId: nil, date: 0, authorSignature: item.linkEnabled ? nil : item.peerName, psaType: nil, flags: [])
|
||||
|
||||
let messageItem = item.context.sharedContext.makeChatMessagePreviewItem(context: item.context, messages: [Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: forwardInfo, author: nil, text: item.strings.Privacy_Forwards_PreviewMessageText, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])], theme: item.theme, strings: item.strings, wallpaper: item.wallpaper, fontSize: item.fontSize, chatBubbleCorners: item.chatBubbleCorners, dateTimeFormat: item.dateTimeFormat, nameOrder: item.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: currentBackgroundNode, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil)
|
||||
let forwardInfo = EngineMessage.ForwardInfo(author: item.linkEnabled ? peers[peerId] : nil, source: nil, sourceMessageId: nil, date: 0, authorSignature: item.linkEnabled ? nil : item.peerName, psaType: nil, flags: [])
|
||||
|
||||
let messageItem = item.context.sharedContext.makeChatMessagePreviewItem(context: item.context, messages: [EngineRawMessage(stableId: 1, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: forwardInfo, author: nil, text: item.strings.Privacy_Forwards_PreviewMessageText, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])], theme: item.theme, strings: item.strings, wallpaper: item.wallpaper, fontSize: item.fontSize, chatBubbleCorners: item.chatBubbleCorners, dateTimeFormat: item.dateTimeFormat, nameOrder: item.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: currentBackgroundNode, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil)
|
||||
|
||||
var node: ListViewItemNode?
|
||||
if let current = currentNode {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
|
|
@ -24,12 +23,12 @@ private final class ArchivedStickerPacksControllerArguments {
|
|||
let context: AccountContext
|
||||
|
||||
let openStickerPack: (StickerPackCollectionInfo) -> Void
|
||||
let setPackIdWithRevealedOptions: (ItemCollectionId?, ItemCollectionId?) -> Void
|
||||
let setPackIdWithRevealedOptions: (EngineItemCollectionId?, EngineItemCollectionId?) -> Void
|
||||
let addPack: (StickerPackCollectionInfo) -> Void
|
||||
let removePack: (StickerPackCollectionInfo) -> Void
|
||||
let togglePackSelected: (ItemCollectionId) -> Void
|
||||
|
||||
init(context: AccountContext, openStickerPack: @escaping (StickerPackCollectionInfo) -> Void, setPackIdWithRevealedOptions: @escaping (ItemCollectionId?, ItemCollectionId?) -> Void, addPack: @escaping (StickerPackCollectionInfo) -> Void, removePack: @escaping (StickerPackCollectionInfo) -> Void, togglePackSelected: @escaping (ItemCollectionId) -> Void) {
|
||||
let togglePackSelected: (EngineItemCollectionId) -> Void
|
||||
|
||||
init(context: AccountContext, openStickerPack: @escaping (StickerPackCollectionInfo) -> Void, setPackIdWithRevealedOptions: @escaping (EngineItemCollectionId?, EngineItemCollectionId?) -> Void, addPack: @escaping (StickerPackCollectionInfo) -> Void, removePack: @escaping (StickerPackCollectionInfo) -> Void, togglePackSelected: @escaping (EngineItemCollectionId) -> Void) {
|
||||
self.context = context
|
||||
self.openStickerPack = openStickerPack
|
||||
self.setPackIdWithRevealedOptions = setPackIdWithRevealedOptions
|
||||
|
|
@ -45,7 +44,7 @@ private enum ArchivedStickerPacksSection: Int32 {
|
|||
|
||||
private enum ArchivedStickerPacksEntryId: Hashable {
|
||||
case index(Int32)
|
||||
case pack(ItemCollectionId)
|
||||
case pack(EngineItemCollectionId)
|
||||
}
|
||||
|
||||
private enum ArchivedStickerPacksEntry: ItemListNodeEntry {
|
||||
|
|
@ -157,18 +156,18 @@ private enum ArchivedStickerPacksEntry: ItemListNodeEntry {
|
|||
|
||||
private struct ArchivedStickerPacksControllerState: Equatable {
|
||||
let editing: Bool
|
||||
let selectedPackIds: Set<ItemCollectionId>?
|
||||
let packIdWithRevealedOptions: ItemCollectionId?
|
||||
let removingPackIds: Set<ItemCollectionId>
|
||||
|
||||
let selectedPackIds: Set<EngineItemCollectionId>?
|
||||
let packIdWithRevealedOptions: EngineItemCollectionId?
|
||||
let removingPackIds: Set<EngineItemCollectionId>
|
||||
|
||||
init() {
|
||||
self.editing = false
|
||||
self.selectedPackIds = nil
|
||||
self.packIdWithRevealedOptions = nil
|
||||
self.removingPackIds = Set()
|
||||
}
|
||||
|
||||
init(editing: Bool, selectedPackIds: Set<ItemCollectionId>?, packIdWithRevealedOptions: ItemCollectionId?, removingPackIds: Set<ItemCollectionId>) {
|
||||
|
||||
init(editing: Bool, selectedPackIds: Set<EngineItemCollectionId>?, packIdWithRevealedOptions: EngineItemCollectionId?, removingPackIds: Set<EngineItemCollectionId>) {
|
||||
self.editing = editing
|
||||
self.selectedPackIds = selectedPackIds
|
||||
self.packIdWithRevealedOptions = packIdWithRevealedOptions
|
||||
|
|
@ -196,22 +195,22 @@ private struct ArchivedStickerPacksControllerState: Equatable {
|
|||
return ArchivedStickerPacksControllerState(editing: editing, selectedPackIds: self.selectedPackIds, packIdWithRevealedOptions: self.packIdWithRevealedOptions, removingPackIds: self.removingPackIds)
|
||||
}
|
||||
|
||||
func withUpdatedSelectedPackIds(_ selectedPackIds: Set<ItemCollectionId>?) -> ArchivedStickerPacksControllerState {
|
||||
func withUpdatedSelectedPackIds(_ selectedPackIds: Set<EngineItemCollectionId>?) -> ArchivedStickerPacksControllerState {
|
||||
return ArchivedStickerPacksControllerState(editing: self.editing, selectedPackIds: selectedPackIds, packIdWithRevealedOptions: self.packIdWithRevealedOptions, removingPackIds: self.removingPackIds)
|
||||
}
|
||||
|
||||
func withUpdatedPackIdWithRevealedOptions(_ packIdWithRevealedOptions: ItemCollectionId?) -> ArchivedStickerPacksControllerState {
|
||||
|
||||
func withUpdatedPackIdWithRevealedOptions(_ packIdWithRevealedOptions: EngineItemCollectionId?) -> ArchivedStickerPacksControllerState {
|
||||
return ArchivedStickerPacksControllerState(editing: self.editing, selectedPackIds: self.selectedPackIds, packIdWithRevealedOptions: packIdWithRevealedOptions, removingPackIds: self.removingPackIds)
|
||||
}
|
||||
|
||||
func withUpdatedRemovingPackIds(_ removingPackIds: Set<ItemCollectionId>) -> ArchivedStickerPacksControllerState {
|
||||
|
||||
func withUpdatedRemovingPackIds(_ removingPackIds: Set<EngineItemCollectionId>) -> ArchivedStickerPacksControllerState {
|
||||
return ArchivedStickerPacksControllerState(editing: self.editing, selectedPackIds: self.selectedPackIds, packIdWithRevealedOptions: self.packIdWithRevealedOptions, removingPackIds: removingPackIds)
|
||||
}
|
||||
}
|
||||
|
||||
private func archivedStickerPacksControllerEntries(context: AccountContext, mode: ArchivedStickerPacksControllerMode, presentationData: PresentationData, state: ArchivedStickerPacksControllerState, packs: [ArchivedStickerPackItem]?, installedView: CombinedView, stickerSettings: StickerSettings) -> [ArchivedStickerPacksEntry] {
|
||||
private func archivedStickerPacksControllerEntries(context: AccountContext, mode: ArchivedStickerPacksControllerMode, presentationData: PresentationData, state: ArchivedStickerPacksControllerState, packs: [ArchivedStickerPackItem]?, installedIds: [EngineItemCollectionId], stickerSettings: StickerSettings) -> [ArchivedStickerPacksEntry] {
|
||||
var entries: [ArchivedStickerPacksEntry] = []
|
||||
|
||||
|
||||
if let packs = packs {
|
||||
let info: String
|
||||
switch mode {
|
||||
|
|
@ -221,11 +220,8 @@ private func archivedStickerPacksControllerEntries(context: AccountContext, mode
|
|||
info = presentationData.strings.StickerPacksSettings_ArchivedPacks_Info
|
||||
}
|
||||
entries.append(.info(presentationData.theme, info + "\n\n"))
|
||||
|
||||
var installedIds = Set<ItemCollectionId>()
|
||||
if let view = installedView.views[.itemCollectionIds(namespaces: [Namespaces.ItemCollection.CloudStickerPacks])] as? ItemCollectionIdsView, let ids = view.idsByNamespace[Namespaces.ItemCollection.CloudStickerPacks] {
|
||||
installedIds = ids
|
||||
}
|
||||
|
||||
let installedIds = Set(installedIds)
|
||||
|
||||
var index: Int32 = 0
|
||||
for item in packs {
|
||||
|
|
@ -269,7 +265,7 @@ public func archivedStickerPacksController(context: AccountContext, mode: Archiv
|
|||
let resolveDisposable = MetaDisposable()
|
||||
actionsDisposable.add(resolveDisposable)
|
||||
|
||||
let removePackDisposables = DisposableDict<ItemCollectionId>()
|
||||
let removePackDisposables = DisposableDict<EngineItemCollectionId>()
|
||||
actionsDisposable.add(removePackDisposables)
|
||||
|
||||
let namespace: ArchivedStickerPacksNamespace
|
||||
|
|
@ -288,8 +284,8 @@ public func archivedStickerPacksController(context: AccountContext, mode: Archiv
|
|||
updatedPacks(packs)
|
||||
}))
|
||||
|
||||
let installedStickerPacks = Promise<CombinedView>()
|
||||
installedStickerPacks.set(context.account.postbox.combinedView(keys: [.itemCollectionIds(namespaces: [Namespaces.ItemCollection.CloudStickerPacks])]))
|
||||
let installedStickerPacks = Promise<[EngineItemCollectionId]>()
|
||||
installedStickerPacks.set(context.engine.data.subscribe(TelegramEngine.EngineData.Item.ItemCollections.InstalledPackIds(namespace: Namespaces.ItemCollection.CloudStickerPacks)))
|
||||
|
||||
var presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
if let forceTheme {
|
||||
|
|
@ -446,7 +442,7 @@ public func archivedStickerPacksController(context: AccountContext, mode: Archiv
|
|||
|
||||
let signal = combineLatest(context.sharedContext.presentationData, statePromise.get() |> deliverOnMainQueue, stickerPacks.get() |> deliverOnMainQueue, installedStickerPacks.get() |> deliverOnMainQueue, context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.stickerSettings]) |> deliverOnMainQueue)
|
||||
|> deliverOnMainQueue
|
||||
|> map { presentationData, state, packs, installedView, sharedData -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
||||
|> map { presentationData, state, packs, installedIds, sharedData -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
||||
var presentationData = presentationData
|
||||
if let forceTheme {
|
||||
presentationData = presentationData.withUpdated(theme: forceTheme)
|
||||
|
|
@ -538,7 +534,7 @@ public func archivedStickerPacksController(context: AccountContext, mode: Archiv
|
|||
$0.withUpdatedEditing(false).withUpdatedSelectedPackIds(nil)
|
||||
}
|
||||
|
||||
var packIds: [ItemCollectionId] = []
|
||||
var packIds: [EngineItemCollectionId] = []
|
||||
for entry in packs {
|
||||
if let selectedPackIds = state.selectedPackIds, selectedPackIds.contains(entry.info.id) {
|
||||
packIds.append(entry.info.id)
|
||||
|
|
@ -595,7 +591,7 @@ public func archivedStickerPacksController(context: AccountContext, mode: Archiv
|
|||
|
||||
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(title), leftNavigationButton: nil, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: true)
|
||||
|
||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: archivedStickerPacksControllerEntries(context: context, mode: mode, presentationData: presentationData, state: state, packs: packs, installedView: installedView, stickerSettings: stickerSettings), style: .blocks, emptyStateItem: emptyStateItem, toolbarItem: toolbarItem, animateChanges: previous != nil && packs != nil && (previous! != 0 && previous! >= packs!.count - 10))
|
||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: archivedStickerPacksControllerEntries(context: context, mode: mode, presentationData: presentationData, state: state, packs: packs, installedIds: installedIds, stickerSettings: stickerSettings), style: .blocks, emptyStateItem: emptyStateItem, toolbarItem: toolbarItem, animateChanges: previous != nil && packs != nil && (previous! != 0 && previous! >= packs!.count - 10))
|
||||
return (controllerState, (listState, arguments))
|
||||
} |> afterDisposed {
|
||||
actionsDisposable.dispose()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
|
|
@ -30,7 +29,7 @@ private enum FeaturedStickerPacksSection: Int32 {
|
|||
}
|
||||
|
||||
private enum FeaturedStickerPacksEntryId: Hashable {
|
||||
case pack(ItemCollectionId)
|
||||
case pack(EngineItemCollectionId)
|
||||
}
|
||||
|
||||
private enum FeaturedStickerPacksEntry: ItemListNodeEntry {
|
||||
|
|
@ -123,37 +122,35 @@ private struct FeaturedStickerPacksControllerState: Equatable {
|
|||
}
|
||||
}
|
||||
|
||||
private func featuredStickerPacksControllerEntries(context: AccountContext, presentationData: PresentationData, state: FeaturedStickerPacksControllerState, view: CombinedView, featured: [FeaturedStickerPackItem], unreadPacks: [ItemCollectionId: Bool], stickerSettings: StickerSettings) -> [FeaturedStickerPacksEntry] {
|
||||
private func featuredStickerPacksControllerEntries(context: AccountContext, presentationData: PresentationData, state: FeaturedStickerPacksControllerState, view: [EngineRawItemCollectionInfoEntry], featured: [FeaturedStickerPackItem], unreadPacks: [EngineItemCollectionId: Bool], stickerSettings: StickerSettings) -> [FeaturedStickerPacksEntry] {
|
||||
var entries: [FeaturedStickerPacksEntry] = []
|
||||
|
||||
if let stickerPacksView = view.views[.itemCollectionInfos(namespaces: [Namespaces.ItemCollection.CloudStickerPacks])] as? ItemCollectionInfosView, !featured.isEmpty {
|
||||
if let packsEntries = stickerPacksView.entriesByNamespace[Namespaces.ItemCollection.CloudStickerPacks] {
|
||||
var installedPacks = Set<ItemCollectionId>()
|
||||
for entry in packsEntries {
|
||||
installedPacks.insert(entry.id)
|
||||
|
||||
if !featured.isEmpty {
|
||||
var installedPacks = Set<EngineItemCollectionId>()
|
||||
for entry in view {
|
||||
installedPacks.insert(entry.id)
|
||||
}
|
||||
var index: Int32 = 0
|
||||
for item in featured {
|
||||
var unread = false
|
||||
if let value = unreadPacks[item.info.id] {
|
||||
unread = value
|
||||
}
|
||||
var index: Int32 = 0
|
||||
for item in featured {
|
||||
var unread = false
|
||||
if let value = unreadPacks[item.info.id] {
|
||||
unread = value
|
||||
}
|
||||
|
||||
let countTitle: String
|
||||
if item.info.id.namespace == Namespaces.ItemCollection.CloudEmojiPacks {
|
||||
countTitle = presentationData.strings.StickerPack_EmojiCount(item.info.count)
|
||||
} else if item.info.id.namespace == Namespaces.ItemCollection.CloudMaskPacks {
|
||||
countTitle = presentationData.strings.StickerPack_MaskCount(item.info.count)
|
||||
} else {
|
||||
countTitle = presentationData.strings.StickerPack_StickerCount(item.info.count)
|
||||
}
|
||||
|
||||
entries.append(.pack(index, presentationData.theme, presentationData.strings, item.info, unread, item.topItems.first, countTitle, context.sharedContext.energyUsageSettings.loopStickers, installedPacks.contains(item.info.id)))
|
||||
index += 1
|
||||
|
||||
let countTitle: String
|
||||
if item.info.id.namespace == Namespaces.ItemCollection.CloudEmojiPacks {
|
||||
countTitle = presentationData.strings.StickerPack_EmojiCount(item.info.count)
|
||||
} else if item.info.id.namespace == Namespaces.ItemCollection.CloudMaskPacks {
|
||||
countTitle = presentationData.strings.StickerPack_MaskCount(item.info.count)
|
||||
} else {
|
||||
countTitle = presentationData.strings.StickerPack_StickerCount(item.info.count)
|
||||
}
|
||||
|
||||
entries.append(.pack(index, presentationData.theme, presentationData.strings, item.info, unread, item.topItems.first, countTitle, context.sharedContext.energyUsageSettings.loopStickers, installedPacks.contains(item.info.id)))
|
||||
index += 1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return entries
|
||||
}
|
||||
|
||||
|
|
@ -198,13 +195,13 @@ public func featuredStickerPacksController(context: AccountContext) -> ViewContr
|
|||
presentControllerImpl?(textAlertController(context: context, updatedPresentationData: nil, title: nil, text: presentationData.strings.ArchivedPacksAlert_Title, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
}))
|
||||
|
||||
let stickerPacks = Promise<CombinedView>()
|
||||
stickerPacks.set(context.account.postbox.combinedView(keys: [.itemCollectionInfos(namespaces: [Namespaces.ItemCollection.CloudStickerPacks])]))
|
||||
let stickerPacks = Promise<[EngineRawItemCollectionInfoEntry]>()
|
||||
stickerPacks.set(context.engine.data.subscribe(TelegramEngine.EngineData.Item.ItemCollections.InstalledPackInfos(namespace: Namespaces.ItemCollection.CloudStickerPacks)))
|
||||
|
||||
let featured = Promise<[FeaturedStickerPackItem]>()
|
||||
featured.set(context.account.viewTracker.featuredStickerPacks())
|
||||
|
||||
var initialUnreadPacks: [ItemCollectionId: Bool] = [:]
|
||||
var initialUnreadPacks: [EngineItemCollectionId: Bool] = [:]
|
||||
|
||||
let signal = combineLatest(context.sharedContext.presentationData, statePromise.get() |> deliverOnMainQueue, stickerPacks.get() |> deliverOnMainQueue, featured.get() |> deliverOnMainQueue, context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.stickerSettings]) |> deliverOnMainQueue)
|
||||
|> deliverOnMainQueue
|
||||
|
|
@ -232,10 +229,10 @@ public func featuredStickerPacksController(context: AccountContext) -> ViewContr
|
|||
|
||||
let controller = ItemListController(context: context, state: signal)
|
||||
|
||||
var alreadyReadIds = Set<ItemCollectionId>()
|
||||
var alreadyReadIds = Set<EngineItemCollectionId>()
|
||||
|
||||
controller.visibleEntriesUpdated = { entries in
|
||||
var unreadIds: [ItemCollectionId] = []
|
||||
var unreadIds: [EngineItemCollectionId] = []
|
||||
for entry in entries {
|
||||
if let entry = entry as? FeaturedStickerPacksEntry {
|
||||
switch entry {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
|
|
@ -24,7 +23,7 @@ private final class InstalledStickerPacksControllerArguments {
|
|||
let context: AccountContext
|
||||
|
||||
let openStickerPack: (StickerPackCollectionInfo) -> Void
|
||||
let setPackIdWithRevealedOptions: (ItemCollectionId?, ItemCollectionId?) -> Void
|
||||
let setPackIdWithRevealedOptions: (EngineItemCollectionId?, EngineItemCollectionId?) -> Void
|
||||
let removePack: (ArchivedStickerPackItem) -> Void
|
||||
let openStickersBot: () -> Void
|
||||
let openMasks: () -> Void
|
||||
|
|
@ -34,12 +33,12 @@ private final class InstalledStickerPacksControllerArguments {
|
|||
let openArchived: ([ArchivedStickerPackItem]?) -> Void
|
||||
let openSuggestOptions: () -> Void
|
||||
let toggleSuggestAnimatedEmoji: (Bool) -> Void
|
||||
let togglePackSelected: (ItemCollectionId) -> Void
|
||||
let togglePackSelected: (EngineItemCollectionId) -> Void
|
||||
let toggleLargeEmoji: (Bool) -> Void
|
||||
let toggleDynamicPackOrder: (Bool) -> Void
|
||||
let addPack: (StickerPackCollectionInfo) -> Void
|
||||
|
||||
init(context: AccountContext, openStickerPack: @escaping (StickerPackCollectionInfo) -> Void, setPackIdWithRevealedOptions: @escaping (ItemCollectionId?, ItemCollectionId?) -> Void, removePack: @escaping (ArchivedStickerPackItem) -> Void, openStickersBot: @escaping () -> Void, openMasks: @escaping () -> Void, openEmoji: @escaping () -> Void, openQuickReaction: @escaping () -> Void, openFeatured: @escaping () -> Void, openArchived: @escaping ([ArchivedStickerPackItem]?) -> Void, openSuggestOptions: @escaping () -> Void, toggleSuggestAnimatedEmoji: @escaping (Bool) -> Void, togglePackSelected: @escaping (ItemCollectionId) -> Void, toggleLargeEmoji: @escaping (Bool) -> Void, toggleDynamicPackOrder: @escaping (Bool) -> Void, addPack: @escaping (StickerPackCollectionInfo) -> Void) {
|
||||
init(context: AccountContext, openStickerPack: @escaping (StickerPackCollectionInfo) -> Void, setPackIdWithRevealedOptions: @escaping (EngineItemCollectionId?, EngineItemCollectionId?) -> Void, removePack: @escaping (ArchivedStickerPackItem) -> Void, openStickersBot: @escaping () -> Void, openMasks: @escaping () -> Void, openEmoji: @escaping () -> Void, openQuickReaction: @escaping () -> Void, openFeatured: @escaping () -> Void, openArchived: @escaping ([ArchivedStickerPackItem]?) -> Void, openSuggestOptions: @escaping () -> Void, toggleSuggestAnimatedEmoji: @escaping (Bool) -> Void, togglePackSelected: @escaping (EngineItemCollectionId) -> Void, toggleLargeEmoji: @escaping (Bool) -> Void, toggleDynamicPackOrder: @escaping (Bool) -> Void, addPack: @escaping (StickerPackCollectionInfo) -> Void) {
|
||||
self.context = context
|
||||
self.openStickerPack = openStickerPack
|
||||
self.setPackIdWithRevealedOptions = setPackIdWithRevealedOptions
|
||||
|
|
@ -84,7 +83,7 @@ public enum InstalledStickerPacksEntryTag: ItemListItemTag {
|
|||
|
||||
private enum InstalledStickerPacksEntryId: Hashable {
|
||||
case index(Int32)
|
||||
case pack(ItemCollectionId)
|
||||
case pack(EngineItemCollectionId)
|
||||
}
|
||||
|
||||
private indirect enum InstalledStickerPacksEntry: ItemListNodeEntry {
|
||||
|
|
@ -457,18 +456,18 @@ private indirect enum InstalledStickerPacksEntry: ItemListNodeEntry {
|
|||
|
||||
private struct InstalledStickerPacksControllerState: Equatable {
|
||||
let editing: Bool
|
||||
let selectedPackIds: Set<ItemCollectionId>?
|
||||
let packIdWithRevealedOptions: ItemCollectionId?
|
||||
let selectedPackIds: Set<EngineItemCollectionId>?
|
||||
let packIdWithRevealedOptions: EngineItemCollectionId?
|
||||
let trendingPacksExpanded: Bool
|
||||
|
||||
|
||||
init() {
|
||||
self.editing = false
|
||||
self.selectedPackIds = nil
|
||||
self.packIdWithRevealedOptions = nil
|
||||
self.trendingPacksExpanded = false
|
||||
}
|
||||
|
||||
init(editing: Bool, selectedPackIds: Set<ItemCollectionId>?, packIdWithRevealedOptions: ItemCollectionId?, trendingPacksExpanded: Bool) {
|
||||
|
||||
init(editing: Bool, selectedPackIds: Set<EngineItemCollectionId>?, packIdWithRevealedOptions: EngineItemCollectionId?, trendingPacksExpanded: Bool) {
|
||||
self.editing = editing
|
||||
self.selectedPackIds = selectedPackIds
|
||||
self.packIdWithRevealedOptions = packIdWithRevealedOptions
|
||||
|
|
@ -495,11 +494,11 @@ private struct InstalledStickerPacksControllerState: Equatable {
|
|||
return InstalledStickerPacksControllerState(editing: editing, selectedPackIds: self.selectedPackIds, packIdWithRevealedOptions: self.packIdWithRevealedOptions, trendingPacksExpanded: self.trendingPacksExpanded)
|
||||
}
|
||||
|
||||
func withUpdatedSelectedPackIds(_ selectedPackIds: Set<ItemCollectionId>?) -> InstalledStickerPacksControllerState {
|
||||
func withUpdatedSelectedPackIds(_ selectedPackIds: Set<EngineItemCollectionId>?) -> InstalledStickerPacksControllerState {
|
||||
return InstalledStickerPacksControllerState(editing: editing, selectedPackIds: selectedPackIds, packIdWithRevealedOptions: self.packIdWithRevealedOptions, trendingPacksExpanded: self.trendingPacksExpanded)
|
||||
}
|
||||
|
||||
func withUpdatedPackIdWithRevealedOptions(_ packIdWithRevealedOptions: ItemCollectionId?) -> InstalledStickerPacksControllerState {
|
||||
|
||||
func withUpdatedPackIdWithRevealedOptions(_ packIdWithRevealedOptions: EngineItemCollectionId?) -> InstalledStickerPacksControllerState {
|
||||
return InstalledStickerPacksControllerState(editing: self.editing, selectedPackIds: self.selectedPackIds, packIdWithRevealedOptions: packIdWithRevealedOptions, trendingPacksExpanded: self.trendingPacksExpanded)
|
||||
}
|
||||
|
||||
|
|
@ -508,7 +507,7 @@ private struct InstalledStickerPacksControllerState: Equatable {
|
|||
}
|
||||
}
|
||||
|
||||
private func namespaceForMode(_ mode: InstalledStickerPacksControllerMode) -> ItemCollectionId.Namespace {
|
||||
private func namespaceForMode(_ mode: InstalledStickerPacksControllerMode) -> EngineItemCollectionId.Namespace {
|
||||
switch mode {
|
||||
case .general, .modal:
|
||||
return Namespaces.ItemCollection.CloudStickerPacks
|
||||
|
|
@ -521,18 +520,16 @@ private func namespaceForMode(_ mode: InstalledStickerPacksControllerMode) -> It
|
|||
|
||||
private let maxTrendingPacksDisplayedLimit: Int32 = 3
|
||||
|
||||
private func installedStickerPacksControllerEntries(context: AccountContext, presentationData: PresentationData, state: InstalledStickerPacksControllerState, mode: InstalledStickerPacksControllerMode, view: CombinedView, temporaryPackOrder: [ItemCollectionId]?, featured: [FeaturedStickerPackItem], archived: [ArchivedStickerPackItem]?, stickerSettings: StickerSettings, quickReaction: MessageReaction.Reaction?, availableReactions: AvailableReactions?, emojiCount: Int32) -> [InstalledStickerPacksEntry] {
|
||||
private func installedStickerPacksControllerEntries(context: AccountContext, presentationData: PresentationData, state: InstalledStickerPacksControllerState, mode: InstalledStickerPacksControllerMode, view: [EngineRawItemCollectionInfoEntry], temporaryPackOrder: [EngineItemCollectionId]?, featured: [FeaturedStickerPackItem], archived: [ArchivedStickerPackItem]?, stickerSettings: StickerSettings, quickReaction: MessageReaction.Reaction?, availableReactions: AvailableReactions?, emojiCount: Int32) -> [InstalledStickerPacksEntry] {
|
||||
var entries: [InstalledStickerPacksEntry] = []
|
||||
|
||||
var installedPacks = Set<ItemCollectionId>()
|
||||
if let stickerPacksView = view.views[.itemCollectionInfos(namespaces: [namespaceForMode(mode)])] as? ItemCollectionInfosView {
|
||||
if let packsEntries = stickerPacksView.entriesByNamespace[namespaceForMode(mode)] {
|
||||
var sortedPacks: [ItemCollectionInfoEntry] = []
|
||||
for entry in packsEntries {
|
||||
if let _ = entry.info as? StickerPackCollectionInfo {
|
||||
installedPacks.insert(entry.id)
|
||||
sortedPacks.append(entry)
|
||||
}
|
||||
|
||||
var installedPacks = Set<EngineItemCollectionId>()
|
||||
do {
|
||||
var sortedPacks: [EngineRawItemCollectionInfoEntry] = []
|
||||
for entry in view {
|
||||
if let _ = entry.info as? StickerPackCollectionInfo {
|
||||
installedPacks.insert(entry.id)
|
||||
sortedPacks.append(entry)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -580,45 +577,43 @@ private func installedStickerPacksControllerEntries(context: AccountContext, pre
|
|||
entries.append(.suggestAnimatedEmojiInfo(presentationData.theme, presentationData.strings.StickerPacksSettings_SuggestAnimatedEmojiInfo))
|
||||
}
|
||||
|
||||
if let stickerPacksView = view.views[.itemCollectionInfos(namespaces: [namespaceForMode(mode)])] as? ItemCollectionInfosView {
|
||||
if let packsEntries = stickerPacksView.entriesByNamespace[namespaceForMode(mode)] {
|
||||
var sortedPacks: [ItemCollectionInfoEntry] = []
|
||||
for entry in packsEntries {
|
||||
if let _ = entry.info as? StickerPackCollectionInfo {
|
||||
sortedPacks.append(entry)
|
||||
do {
|
||||
var sortedPacks: [EngineRawItemCollectionInfoEntry] = []
|
||||
for entry in view {
|
||||
if let _ = entry.info as? StickerPackCollectionInfo {
|
||||
sortedPacks.append(entry)
|
||||
}
|
||||
}
|
||||
if let temporaryPackOrder = temporaryPackOrder {
|
||||
var packDict: [EngineItemCollectionId: Int] = [:]
|
||||
for i in 0 ..< sortedPacks.count {
|
||||
packDict[sortedPacks[i].id] = i
|
||||
}
|
||||
var tempSortedPacks: [EngineRawItemCollectionInfoEntry] = []
|
||||
var processedPacks = Set<EngineItemCollectionId>()
|
||||
for id in temporaryPackOrder {
|
||||
if let index = packDict[id] {
|
||||
tempSortedPacks.append(sortedPacks[index])
|
||||
processedPacks.insert(id)
|
||||
}
|
||||
}
|
||||
if let temporaryPackOrder = temporaryPackOrder {
|
||||
var packDict: [ItemCollectionId: Int] = [:]
|
||||
for i in 0 ..< sortedPacks.count {
|
||||
packDict[sortedPacks[i].id] = i
|
||||
}
|
||||
var tempSortedPacks: [ItemCollectionInfoEntry] = []
|
||||
var processedPacks = Set<ItemCollectionId>()
|
||||
for id in temporaryPackOrder {
|
||||
if let index = packDict[id] {
|
||||
tempSortedPacks.append(sortedPacks[index])
|
||||
processedPacks.insert(id)
|
||||
}
|
||||
}
|
||||
let restPacks = sortedPacks.filter { !processedPacks.contains($0.id) }
|
||||
sortedPacks = restPacks + tempSortedPacks
|
||||
}
|
||||
var index: Int32 = 0
|
||||
for entry in sortedPacks {
|
||||
if let info = entry.info as? StickerPackCollectionInfo {
|
||||
let countTitle: String
|
||||
if info.id.namespace == Namespaces.ItemCollection.CloudEmojiPacks {
|
||||
countTitle = presentationData.strings.StickerPack_EmojiCount(info.count == 0 ? entry.count : info.count)
|
||||
} else if info.id.namespace == Namespaces.ItemCollection.CloudMaskPacks {
|
||||
countTitle = presentationData.strings.StickerPack_MaskCount(info.count == 0 ? entry.count : info.count)
|
||||
} else {
|
||||
countTitle = presentationData.strings.StickerPack_StickerCount(info.count == 0 ? entry.count : info.count)
|
||||
}
|
||||
|
||||
entries.append(.pack(index, presentationData.theme, presentationData.strings, info, entry.firstItem as? StickerPackItem, countTitle, context.sharedContext.energyUsageSettings.loopStickers, true, ItemListStickerPackItemEditing(editable: true, editing: state.editing, revealed: state.packIdWithRevealedOptions == entry.id, reorderable: true, selectable: true), state.selectedPackIds?.contains(info.id)))
|
||||
index += 1
|
||||
let restPacks = sortedPacks.filter { !processedPacks.contains($0.id) }
|
||||
sortedPacks = restPacks + tempSortedPacks
|
||||
}
|
||||
var index: Int32 = 0
|
||||
for entry in sortedPacks {
|
||||
if let info = entry.info as? StickerPackCollectionInfo {
|
||||
let countTitle: String
|
||||
if info.id.namespace == Namespaces.ItemCollection.CloudEmojiPacks {
|
||||
countTitle = presentationData.strings.StickerPack_EmojiCount(info.count == 0 ? entry.count : info.count)
|
||||
} else if info.id.namespace == Namespaces.ItemCollection.CloudMaskPacks {
|
||||
countTitle = presentationData.strings.StickerPack_MaskCount(info.count == 0 ? entry.count : info.count)
|
||||
} else {
|
||||
countTitle = presentationData.strings.StickerPack_StickerCount(info.count == 0 ? entry.count : info.count)
|
||||
}
|
||||
|
||||
entries.append(.pack(index, presentationData.theme, presentationData.strings, info, entry.firstItem as? StickerPackItem, countTitle, context.sharedContext.energyUsageSettings.loopStickers, true, ItemListStickerPackItemEditing(editable: true, editing: state.editing, revealed: state.packIdWithRevealedOptions == entry.id, reorderable: true, selectable: true), state.selectedPackIds?.contains(info.id)))
|
||||
index += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -668,7 +663,7 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
|||
|
||||
var presentControllerImpl: ((ViewController, ViewControllerPresentationArguments?) -> Void)?
|
||||
var pushControllerImpl: ((ViewController) -> Void)?
|
||||
var navigateToChatControllerImpl: ((PeerId) -> Void)?
|
||||
var navigateToChatControllerImpl: ((EnginePeer.Id) -> Void)?
|
||||
var dismissImpl: (() -> Void)?
|
||||
|
||||
let actionsDisposable = DisposableSet()
|
||||
|
|
@ -874,9 +869,9 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
|||
return .complete()
|
||||
} |> deliverOnMainQueue).start()
|
||||
})
|
||||
let stickerPacks = Promise<CombinedView>()
|
||||
stickerPacks.set(context.account.postbox.combinedView(keys: [.itemCollectionInfos(namespaces: [namespaceForMode(mode)])]))
|
||||
let temporaryPackOrder = Promise<[ItemCollectionId]?>(nil)
|
||||
let stickerPacks = Promise<[EngineRawItemCollectionInfoEntry]>()
|
||||
stickerPacks.set(context.engine.data.subscribe(TelegramEngine.EngineData.Item.ItemCollections.InstalledPackInfos(namespace: namespaceForMode(mode))))
|
||||
let temporaryPackOrder = Promise<[EngineItemCollectionId]?>(nil)
|
||||
|
||||
let featured = Promise<[FeaturedStickerPackItem]>()
|
||||
let quickReaction: Signal<MessageReaction.Reaction?, NoError>
|
||||
|
|
@ -904,14 +899,11 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
|||
return reactionSettings.effectiveQuickReaction(hasPremium: hasPremium)
|
||||
}
|
||||
|> distinctUntilChanged
|
||||
emojiCount.set(context.account.postbox.combinedView(keys: [.itemCollectionInfos(namespaces: [Namespaces.ItemCollection.CloudEmojiPacks])])
|
||||
|> map { view in
|
||||
if let info = view.views[.itemCollectionInfos(namespaces: [Namespaces.ItemCollection.CloudEmojiPacks])] as? ItemCollectionInfosView, let entries = info.entriesByNamespace[Namespaces.ItemCollection.CloudEmojiPacks] {
|
||||
return Int32(entries.count)
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
})
|
||||
emojiCount.set(context.engine.data.subscribe(TelegramEngine.EngineData.Item.ItemCollections.InstalledPackInfos(namespace: Namespaces.ItemCollection.CloudEmojiPacks))
|
||||
|> map { entries in
|
||||
return Int32(entries.count)
|
||||
})
|
||||
|
||||
case .masks:
|
||||
featured.set(.single([]))
|
||||
archivedPromise.set(.single(nil) |> then(context.engine.stickers.archivedStickerPacks(namespace: .masks) |> map(Optional.init)))
|
||||
|
|
@ -948,10 +940,10 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
|||
}
|
||||
|
||||
var packCount: Int? = nil
|
||||
var stickerPacks: [ItemCollectionInfoEntry] = []
|
||||
if let stickerPacksView = view.views[.itemCollectionInfos(namespaces: [namespaceForMode(mode)])] as? ItemCollectionInfosView, let entries = stickerPacksView.entriesByNamespace[namespaceForMode(mode)] {
|
||||
packCount = entries.count
|
||||
stickerPacks = entries
|
||||
var stickerPacks: [EngineRawItemCollectionInfoEntry] = []
|
||||
do {
|
||||
packCount = view.count
|
||||
stickerPacks = view
|
||||
}
|
||||
|
||||
let leftNavigationButton: ItemListNavigationButton? = nil
|
||||
|
|
@ -998,7 +990,7 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
|||
}
|
||||
}
|
||||
|
||||
var packIds: [ItemCollectionId] = []
|
||||
var packIds: [EngineItemCollectionId] = []
|
||||
for entry in stickerPacks {
|
||||
if let selectedPackIds = state.selectedPackIds, selectedPackIds.contains(entry.id) {
|
||||
packIds.append(entry.id)
|
||||
|
|
@ -1029,7 +1021,7 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
|||
}
|
||||
}
|
||||
|
||||
var packIds: [ItemCollectionId] = []
|
||||
var packIds: [EngineItemCollectionId] = []
|
||||
for entry in stickerPacks {
|
||||
if let selectedPackIds = state.selectedPackIds, selectedPackIds.contains(entry.id) {
|
||||
packIds.append(entry.id)
|
||||
|
|
@ -1112,7 +1104,7 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
|||
guard case let .pack(_, _, _, fromPackInfo, _, _, _, _, _, _) = fromEntry else {
|
||||
return .single(false)
|
||||
}
|
||||
var referenceId: ItemCollectionId?
|
||||
var referenceId: EngineItemCollectionId?
|
||||
var beforeAll = false
|
||||
var afterAll = false
|
||||
if toIndex < entries.count {
|
||||
|
|
@ -1130,7 +1122,7 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
|||
afterAll = true
|
||||
}
|
||||
|
||||
var currentIds: [ItemCollectionId] = []
|
||||
var currentIds: [EngineItemCollectionId] = []
|
||||
for entry in entries {
|
||||
switch entry {
|
||||
case let .pack(_, _, _, info, _, _, _, _, _, _):
|
||||
|
|
@ -1184,7 +1176,7 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
|||
})
|
||||
|
||||
controller.setReorderCompleted({ (entries: [InstalledStickerPacksEntry]) -> Void in
|
||||
var currentIds: [ItemCollectionId] = []
|
||||
var currentIds: [EngineItemCollectionId] = []
|
||||
for entry in entries {
|
||||
switch entry {
|
||||
case let .pack(_, _, _, info, _, _, _, _, _, _):
|
||||
|
|
@ -1224,10 +1216,7 @@ public func installedStickerPacksController(context: AccountContext, mode: Insta
|
|||
presentStickerPackController = { [weak controller] info in
|
||||
let _ = (stickerPacks.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { view in
|
||||
guard let stickerPacksView = view.views[.itemCollectionInfos(namespaces: [namespaceForMode(mode)])] as? ItemCollectionInfosView, let entries = stickerPacksView.entriesByNamespace[namespaceForMode(mode)] else {
|
||||
return
|
||||
}
|
||||
|> deliverOnMainQueue).start(next: { entries in
|
||||
var mainStickerPack: StickerPackReference?
|
||||
var packs: [StickerPackReference] = []
|
||||
for entry in entries {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import Display
|
|||
import SwiftSignalKit
|
||||
import AsyncDisplayKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
import AccountContext
|
||||
|
|
@ -268,7 +267,7 @@ private final class TextSizeSelectionControllerNode: ASDisplayNode, ASScrollView
|
|||
context: self.context,
|
||||
chatListLocation: .chatList(groupId: .root),
|
||||
filterData: nil,
|
||||
index: .chatList(ChatListIndex(pinningIndex: isPinned ? 0 : nil, messageIndex: MessageIndex(id: MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: 0), timestamp: timestamp))),
|
||||
index: .chatList(EngineChatListIndex(pinningIndex: isPinned ? 0 : nil, messageIndex: EngineMessage.Index(id: EngineMessage.Id(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: 0), timestamp: timestamp))),
|
||||
content: .peer(ChatListItemContent.PeerData(
|
||||
messages: [
|
||||
EngineMessage(
|
||||
|
|
@ -334,13 +333,13 @@ private final class TextSizeSelectionControllerNode: ASDisplayNode, ASScrollView
|
|||
}
|
||||
|
||||
let selfPeer: EnginePeer = .user(TelegramUser(id: self.context.account.peerId, accessHash: nil, firstName: nil, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer1: EnginePeer = .user(TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer2: EnginePeer = .user(TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(2)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer3: EnginePeer = .channel(TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(3)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, emojiStatus: nil, approximateBoostLevel: nil, subscriptionUntilDate: nil, verificationIconFileId: nil, sendPaidMessageStars: nil, linkedMonoforumId: nil))
|
||||
let peer3Author: EnginePeer = .user(TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer4: EnginePeer = .user(TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer5: EnginePeer = .channel(TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(5)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_5_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .broadcast(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, emojiStatus: nil, approximateBoostLevel: nil, subscriptionUntilDate: nil, verificationIconFileId: nil, sendPaidMessageStars: nil, linkedMonoforumId: nil))
|
||||
let peer6: EnginePeer = .user(TelegramUser(id: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(5)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_6_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer1: EnginePeer = .user(TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(1)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer2: EnginePeer = .user(TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(2)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer3: EnginePeer = .channel(TelegramChannel(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudChannel, id: EnginePeer.Id.Id._internalFromInt64Value(3)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, emojiStatus: nil, approximateBoostLevel: nil, subscriptionUntilDate: nil, verificationIconFileId: nil, sendPaidMessageStars: nil, linkedMonoforumId: nil))
|
||||
let peer3Author: EnginePeer = .user(TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer4: EnginePeer = .user(TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer5: EnginePeer = .channel(TelegramChannel(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudChannel, id: EnginePeer.Id.Id._internalFromInt64Value(5)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_5_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .broadcast(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, emojiStatus: nil, approximateBoostLevel: nil, subscriptionUntilDate: nil, verificationIconFileId: nil, sendPaidMessageStars: nil, linkedMonoforumId: nil))
|
||||
let peer6: EnginePeer = .user(TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.SecretChat, id: EnginePeer.Id.Id._internalFromInt64Value(5)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_6_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
|
||||
let timestamp = self.referenceTimestamp
|
||||
|
||||
|
|
@ -452,30 +451,30 @@ private final class TextSizeSelectionControllerNode: ASDisplayNode, ASScrollView
|
|||
let headerItem = self.context.sharedContext.makeChatMessageDateHeaderItem(context: self.context, timestamp: self.referenceTimestamp, theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder)
|
||||
|
||||
var items: [ListViewItem] = []
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1))
|
||||
let peerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(1))
|
||||
let otherPeerId = self.context.account.peerId
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
var messages = SimpleDictionary<MessageId, Message>()
|
||||
var peers = EngineSimpleDictionary<EnginePeer.Id, EngineRawPeer>()
|
||||
var messages = EngineSimpleDictionary<EngineMessage.Id, EngineRawMessage>()
|
||||
peers[peerId] = TelegramUser(id: peerId, accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_Chat_2_ReplyName, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: .preset(.blue), backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
peers[otherPeerId] = TelegramUser(id: otherPeerId, accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_Chat_2_ReplyName, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: .preset(.blue), backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
|
||||
let replyMessageId = MessageId(peerId: peerId, namespace: 0, id: 3)
|
||||
messages[replyMessageId] = Message(stableId: 3, stableVersion: 0, id: replyMessageId, globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_1_Text, attributes: [], media: [], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let replyMessageId = EngineMessage.Id(peerId: peerId, namespace: 0, id: 3)
|
||||
messages[replyMessageId] = EngineRawMessage(stableId: 3, stableVersion: 0, id: replyMessageId, globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_1_Text, attributes: [], media: [], peers: peers, associatedMessages: EngineSimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
|
||||
let message1 = Message(stableId: 4, stableVersion: 0, id: MessageId(peerId: otherPeerId, namespace: 0, id: 4), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66003, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_3_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message1 = EngineRawMessage(stableId: 4, stableVersion: 0, id: EngineMessage.Id(peerId: otherPeerId, namespace: 0, id: 4), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66003, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_3_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
items.append(self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, messages: [message1], theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: self.chatBackgroundNode, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil))
|
||||
|
||||
let message2 = Message(stableId: 3, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 3), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66002, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_2_Text, attributes: [ReplyMessageAttribute(messageId: replyMessageId, threadMessageId: nil, quote: nil, isQuote: false, innerSubject: nil)], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message2 = EngineRawMessage(stableId: 3, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id: 3), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66002, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_2_Text, attributes: [ReplyMessageAttribute(messageId: replyMessageId, threadMessageId: nil, quote: nil, isQuote: false, innerSubject: nil)], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
items.append(self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, messages: [message2], theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: self.chatBackgroundNode, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil))
|
||||
|
||||
let waveformBase64 = "DAAOAAkACQAGAAwADwAMABAADQAPABsAGAALAA0AGAAfABoAHgATABgAGQAYABQADAAVABEAHwANAA0ACQAWABkACQAOAAwACQAfAAAAGQAVAAAAEwATAAAACAAfAAAAHAAAABwAHwAAABcAGQAAABQADgAAABQAHwAAAB8AHwAAAAwADwAAAB8AEwAAABoAFwAAAB8AFAAAAAAAHwAAAAAAHgAAAAAAHwAAAAAAHwAAAAAAHwAAAAAAHwAAAAAAHwAAAAAAAAA="
|
||||
let voiceAttributes: [TelegramMediaFileAttribute] = [.Audio(isVoice: true, duration: 23, title: nil, performer: nil, waveform: Data(base64Encoded: waveformBase64)!)]
|
||||
let voiceMedia = TelegramMediaFile(fileId: MediaId(namespace: 0, id: 0), partialReference: nil, resource: LocalFileMediaResource(fileId: 0), previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "audio/ogg", size: 0, attributes: voiceAttributes, alternativeRepresentations: [])
|
||||
let voiceMedia = TelegramMediaFile(fileId: EngineMedia.Id(namespace: 0, id: 0), partialReference: nil, resource: LocalFileMediaResource(fileId: 0), previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "audio/ogg", size: 0, attributes: voiceAttributes, alternativeRepresentations: [])
|
||||
|
||||
let message3 = Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66001, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: "", attributes: [], media: [voiceMedia], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message3 = EngineRawMessage(stableId: 1, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66001, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: "", attributes: [], media: [voiceMedia], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
items.append(self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, messages: [message3], theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: FileMediaResourceStatus(mediaStatus: .playbackStatus(.paused), fetchStatus: .Local), tapMessage: nil, clickThroughMessage: nil, backgroundNode: self.chatBackgroundNode, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil))
|
||||
|
||||
let message4 = Message(stableId: 2, stableVersion: 0, id: MessageId(peerId: otherPeerId, namespace: 0, id: 2), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66001, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_1_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message4 = EngineRawMessage(stableId: 2, stableVersion: 0, id: EngineMessage.Id(peerId: otherPeerId, namespace: 0, id: 2), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66001, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_1_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
items.append(self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, messages: [message4], theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: self.chatBackgroundNode, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil))
|
||||
|
||||
let width: CGFloat
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import AsyncDisplayKit
|
||||
import TelegramCore
|
||||
|
|
@ -400,7 +399,7 @@ final class ThemePreviewControllerNode: ASDisplayNode, ASScrollViewDelegate {
|
|||
context: self.context,
|
||||
chatListLocation: .chatList(groupId: .root),
|
||||
filterData: nil,
|
||||
index: .chatList(ChatListIndex(pinningIndex: isPinned ? 0 : nil, messageIndex: MessageIndex(id: MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: 0), timestamp: timestamp))),
|
||||
index: .chatList(EngineChatListIndex(pinningIndex: isPinned ? 0 : nil, messageIndex: EngineMessage.Index(id: EngineMessage.Id(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: 0), timestamp: timestamp))),
|
||||
content: .peer(ChatListItemContent.PeerData(
|
||||
messages: [
|
||||
EngineMessage(
|
||||
|
|
@ -468,14 +467,14 @@ final class ThemePreviewControllerNode: ASDisplayNode, ASScrollViewDelegate {
|
|||
let chatListPresentationData = ChatListPresentationData(theme: self.previewTheme, fontSize: self.presentationData.listsFontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameSortOrder: self.presentationData.nameSortOrder, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: true)
|
||||
|
||||
let selfPeer: EnginePeer = .user(TelegramUser(id: self.context.account.peerId, accessHash: nil, firstName: nil, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer1: EnginePeer = .user(TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer2: EnginePeer = .user(TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(2)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer3: EnginePeer = .channel(TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(3)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, emojiStatus: nil, approximateBoostLevel: nil, subscriptionUntilDate: nil, verificationIconFileId: nil, sendPaidMessageStars: nil, linkedMonoforumId: nil))
|
||||
let peer3Author: EnginePeer = .user(TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer4: EnginePeer = .user(TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer5: EnginePeer = .channel(TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(5)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_5_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .broadcast(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, emojiStatus: nil, approximateBoostLevel: nil, subscriptionUntilDate: nil, verificationIconFileId: nil, sendPaidMessageStars: nil, linkedMonoforumId: nil))
|
||||
let peer6: EnginePeer = .user(TelegramUser(id: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(5)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_6_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer7: EnginePeer = .user(TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(6)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_7_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer1: EnginePeer = .user(TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(1)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer2: EnginePeer = .user(TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(2)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer3: EnginePeer = .channel(TelegramChannel(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudChannel, id: EnginePeer.Id.Id._internalFromInt64Value(3)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, emojiStatus: nil, approximateBoostLevel: nil, subscriptionUntilDate: nil, verificationIconFileId: nil, sendPaidMessageStars: nil, linkedMonoforumId: nil))
|
||||
let peer3Author: EnginePeer = .user(TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer4: EnginePeer = .user(TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer5: EnginePeer = .channel(TelegramChannel(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudChannel, id: EnginePeer.Id.Id._internalFromInt64Value(5)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_5_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .broadcast(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, emojiStatus: nil, approximateBoostLevel: nil, subscriptionUntilDate: nil, verificationIconFileId: nil, sendPaidMessageStars: nil, linkedMonoforumId: nil))
|
||||
let peer6: EnginePeer = .user(TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.SecretChat, id: EnginePeer.Id.Id._internalFromInt64Value(5)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_6_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer7: EnginePeer = .user(TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(6)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_7_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
|
||||
let timestamp = self.referenceTimestamp
|
||||
|
||||
|
|
@ -592,43 +591,43 @@ final class ThemePreviewControllerNode: ASDisplayNode, ASScrollViewDelegate {
|
|||
let headerItem = self.context.sharedContext.makeChatMessageDateHeaderItem(context: self.context, timestamp: self.referenceTimestamp, theme: self.previewTheme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder)
|
||||
|
||||
var items: [ListViewItem] = []
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1))
|
||||
let peerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(1))
|
||||
let otherPeerId = self.context.account.peerId
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
var messages = SimpleDictionary<MessageId, Message>()
|
||||
var peers = EngineSimpleDictionary<EnginePeer.Id, EngineRawPeer>()
|
||||
var messages = EngineSimpleDictionary<EngineMessage.Id, EngineRawMessage>()
|
||||
peers[peerId] = TelegramUser(id: peerId, accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_Chat_2_ReplyName, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: .preset(.blue), backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
peers[otherPeerId] = TelegramUser(id: otherPeerId, accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_Chat_2_ReplyName, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: .preset(.blue), backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
|
||||
var sampleMessages: [Message] = []
|
||||
var sampleMessages: [EngineRawMessage] = []
|
||||
|
||||
let message1 = Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: otherPeerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_4_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message1 = EngineRawMessage(stableId:1, stableVersion: 0, id: EngineMessage.Id(peerId: otherPeerId, namespace: 0, id:1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_4_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
sampleMessages.append(message1)
|
||||
|
||||
let message2 = Message(stableId: 2, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 2), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66001, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_5_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message2 = EngineRawMessage(stableId:2, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id:2), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66001, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_5_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
sampleMessages.append(message2)
|
||||
|
||||
let message3 = Message(stableId: 3, stableVersion: 0, id: MessageId(peerId: otherPeerId, namespace: 0, id: 3), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66002, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_6_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message3 = EngineRawMessage(stableId:3, stableVersion: 0, id: EngineMessage.Id(peerId: otherPeerId, namespace: 0, id:3), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66002, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_6_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
sampleMessages.append(message3)
|
||||
|
||||
let message4 = Message(stableId: 4, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 4), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66003, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_7_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message4 = EngineRawMessage(stableId:4, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id:4), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66003, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_7_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
messages[message4.id] = message4
|
||||
sampleMessages.append(message4)
|
||||
|
||||
let message5 = Message(stableId: 5, stableVersion: 0, id: MessageId(peerId: otherPeerId, namespace: 0, id: 5), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66004, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_1_Text, attributes: [ReplyMessageAttribute(messageId: message4.id, threadMessageId: nil, quote: nil, isQuote: false, innerSubject: nil)], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message5 = EngineRawMessage(stableId:5, stableVersion: 0, id: EngineMessage.Id(peerId: otherPeerId, namespace: 0, id:5), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66004, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_1_Text, attributes: [ReplyMessageAttribute(messageId: message4.id, threadMessageId: nil, quote: nil, isQuote: false, innerSubject: nil)], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
messages[message5.id] = message5
|
||||
sampleMessages.append(message5)
|
||||
|
||||
let waveformBase64 = "DAAOAAkACQAGAAwADwAMABAADQAPABsAGAALAA0AGAAfABoAHgATABgAGQAYABQADAAVABEAHwANAA0ACQAWABkACQAOAAwACQAfAAAAGQAVAAAAEwATAAAACAAfAAAAHAAAABwAHwAAABcAGQAAABQADgAAABQAHwAAAB8AHwAAAAwADwAAAB8AEwAAABoAFwAAAB8AFAAAAAAAHwAAAAAAHgAAAAAAHwAAAAAAHwAAAAAAHwAAAAAAHwAAAAAAHwAAAAAAAAA="
|
||||
let voiceAttributes: [TelegramMediaFileAttribute] = [.Audio(isVoice: true, duration: 23, title: nil, performer: nil, waveform: Data(base64Encoded: waveformBase64)!)]
|
||||
let voiceMedia = TelegramMediaFile(fileId: MediaId(namespace: 0, id: 0), partialReference: nil, resource: LocalFileMediaResource(fileId: 0), previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "audio/ogg", size: 0, attributes: voiceAttributes, alternativeRepresentations: [])
|
||||
let voiceMedia = TelegramMediaFile(fileId: EngineMedia.Id(namespace: 0, id: 0), partialReference: nil, resource: LocalFileMediaResource(fileId: 0), previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "audio/ogg", size: 0, attributes: voiceAttributes, alternativeRepresentations: [])
|
||||
|
||||
let message6 = Message(stableId: 6, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 6), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66005, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: "", attributes: [], media: [voiceMedia], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message6 = EngineRawMessage(stableId:6, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id:6), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66005, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: "", attributes: [], media: [voiceMedia], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
sampleMessages.append(message6)
|
||||
|
||||
let message7 = Message(stableId: 7, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 7), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66006, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_2_Text, attributes: [ReplyMessageAttribute(messageId: message5.id, threadMessageId: nil, quote: nil, isQuote: false, innerSubject: nil)], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message7 = EngineRawMessage(stableId:7, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id:7), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66006, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_2_Text, attributes: [ReplyMessageAttribute(messageId: message5.id, threadMessageId: nil, quote: nil, isQuote: false, innerSubject: nil)], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
sampleMessages.append(message7)
|
||||
|
||||
let message8 = Message(stableId: 8, stableVersion: 0, id: MessageId(peerId: otherPeerId, namespace: 0, id: 8), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66007, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_3_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message8 = EngineRawMessage(stableId:8, stableVersion: 0, id: EngineMessage.Id(peerId: otherPeerId, namespace: 0, id:8), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66007, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_3_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
sampleMessages.append(message8)
|
||||
|
||||
items = sampleMessages.reversed().map { message in
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import Display
|
|||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
import ItemListUI
|
||||
|
|
@ -156,20 +155,20 @@ class ThemeSettingsChatPreviewItemNode: ListViewItemNode {
|
|||
let insets: UIEdgeInsets
|
||||
let separatorHeight = UIScreenPixel
|
||||
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1))
|
||||
let otherPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(2))
|
||||
let peerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(1))
|
||||
let otherPeerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(2))
|
||||
var items: [ListViewItem] = []
|
||||
for messageItem in item.messageItems.reversed() {
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
var messages = SimpleDictionary<MessageId, Message>()
|
||||
var peers = EngineSimpleDictionary<EnginePeer.Id, EngineRawPeer>()
|
||||
var messages = EngineSimpleDictionary<EngineMessage.Id, EngineRawMessage>()
|
||||
|
||||
let replyMessageId = MessageId(peerId: peerId, namespace: 0, id: 3)
|
||||
let replyMessageId = EngineMessage.Id(peerId: peerId, namespace: 0, id: 3)
|
||||
if let (author, text) = messageItem.reply {
|
||||
peers[peerId] = TelegramUser(id: peerId, accessHash: nil, firstName: author, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: messageItem.nameColor, backgroundEmojiId: messageItem.backgroundEmojiId, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
messages[replyMessageId] = Message(stableId: 3, stableVersion: 0, id: replyMessageId, globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: text, attributes: [], media: [], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
messages[replyMessageId] = EngineRawMessage(stableId: 3, stableVersion: 0, id: replyMessageId, globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: text, attributes: [], media: [], peers: peers, associatedMessages: EngineSimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
}
|
||||
|
||||
let message = Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: messageItem.outgoing ? otherPeerId : peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: messageItem.outgoing ? [] : [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: messageItem.outgoing ? TelegramUser(id: otherPeerId, accessHash: nil, firstName: "", lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil) : nil, text: messageItem.text, attributes: messageItem.reply != nil ? [ReplyMessageAttribute(messageId: replyMessageId, threadMessageId: nil, quote: nil, isQuote: false, innerSubject: nil)] : [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message = EngineRawMessage(stableId: 1, stableVersion: 0, id: EngineMessage.Id(peerId: messageItem.outgoing ? otherPeerId : peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: messageItem.outgoing ? [] : [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: messageItem.outgoing ? TelegramUser(id: otherPeerId, accessHash: nil, firstName: "", lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil) : nil, text: messageItem.text, attributes: messageItem.reply != nil ? [ReplyMessageAttribute(messageId: replyMessageId, threadMessageId: nil, quote: nil, isQuote: false, innerSubject: nil)] : [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
items.append(item.context.sharedContext.makeChatMessagePreviewItem(context: item.context, messages: [message], theme: item.componentTheme, strings: item.strings, wallpaper: item.wallpaper, fontSize: item.fontSize, chatBubbleCorners: item.chatBubbleCorners, dateTimeFormat: item.dateTimeFormat, nameOrder: item.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: currentBackgroundNode, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,18 +10,15 @@ import AccountContext
|
|||
import UndoUI
|
||||
import InviteLinksUI
|
||||
import TextFormat
|
||||
import Postbox
|
||||
|
||||
private final class UsernameSetupControllerArguments {
|
||||
let account: Account
|
||||
let updatePublicLinkText: (String?, String) -> Void
|
||||
let shareLink: () -> Void
|
||||
let activateLink: (String) -> Void
|
||||
let deactivateLink: (String) -> Void
|
||||
let openAuction: (String) -> Void
|
||||
|
||||
init(account: Account, updatePublicLinkText: @escaping (String?, String) -> Void, shareLink: @escaping () -> Void, activateLink: @escaping (String) -> Void, deactivateLink: @escaping (String) -> Void, openAuction: @escaping (String) -> Void) {
|
||||
self.account = account
|
||||
|
||||
init(updatePublicLinkText: @escaping (String?, String) -> Void, shareLink: @escaping () -> Void, activateLink: @escaping (String) -> Void, deactivateLink: @escaping (String) -> Void, openAuction: @escaping (String) -> Void) {
|
||||
self.updatePublicLinkText = updatePublicLinkText
|
||||
self.shareLink = shareLink
|
||||
self.activateLink = activateLink
|
||||
|
|
@ -291,10 +288,10 @@ private struct UsernameSetupControllerState: Equatable {
|
|||
}
|
||||
}
|
||||
|
||||
private func usernameSetupControllerEntries(presentationData: PresentationData, view: PeerView, state: UsernameSetupControllerState, temporaryOrder: [String]?, mode: UsernameSetupMode) -> [UsernameSetupEntry] {
|
||||
private func usernameSetupControllerEntries(presentationData: PresentationData, peer: EnginePeer?, state: UsernameSetupControllerState, temporaryOrder: [String]?, mode: UsernameSetupMode) -> [UsernameSetupEntry] {
|
||||
var entries: [UsernameSetupEntry] = []
|
||||
|
||||
if let peer = view.peers[view.peerId] as? TelegramUser {
|
||||
|
||||
if case let .user(peer) = peer {
|
||||
let currentUsername: String
|
||||
if let current = state.editingPublicLinkText {
|
||||
currentUsername = current
|
||||
|
|
@ -444,7 +441,7 @@ public func usernameSetupController(context: AccountContext, mode: UsernameSetup
|
|||
peerId = botPeerId
|
||||
}
|
||||
|
||||
let arguments = UsernameSetupControllerArguments(account: context.account, updatePublicLinkText: { currentText, text in
|
||||
let arguments = UsernameSetupControllerArguments(updatePublicLinkText: { currentText, text in
|
||||
if text.isEmpty {
|
||||
checkAddressNameDisposable.set(nil)
|
||||
updateState { state in
|
||||
|
|
@ -544,20 +541,18 @@ public func usernameSetupController(context: AccountContext, mode: UsernameSetup
|
|||
|
||||
let temporaryOrder = Promise<[String]?>(nil)
|
||||
|
||||
let peerView = context.account.viewTracker.peerView(peerId)
|
||||
let peerSignal = context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId))
|
||||
|> deliverOnMainQueue
|
||||
|
||||
|
||||
let signal = combineLatest(
|
||||
context.sharedContext.presentationData,
|
||||
statePromise.get() |> deliverOnMainQueue,
|
||||
peerView,
|
||||
peerSignal,
|
||||
temporaryOrder.get()
|
||||
)
|
||||
|> map { presentationData, state, view, temporaryOrder -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
||||
let peer = peerViewMainPeer(view)
|
||||
|
||||
|> map { presentationData, state, peer, temporaryOrder -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
||||
var rightNavigationButton: ItemListNavigationButton?
|
||||
if let peer = peer as? TelegramUser {
|
||||
if case let .user(peer) = peer {
|
||||
var doneEnabled = true
|
||||
|
||||
if let addressNameValidationStatus = state.addressNameValidationStatus {
|
||||
|
|
@ -613,7 +608,7 @@ public func usernameSetupController(context: AccountContext, mode: UsernameSetup
|
|||
title = presentationData.strings.Username_Title
|
||||
}
|
||||
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(title), leftNavigationButton: leftNavigationButton, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: false)
|
||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: usernameSetupControllerEntries(presentationData: presentationData, view: view, state: state, temporaryOrder: temporaryOrder, mode: mode), style: .blocks, focusItemTag: mode == .account ? UsernameEntryTag.username : nil, animateChanges: true)
|
||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: usernameSetupControllerEntries(presentationData: presentationData, peer: peer, state: state, temporaryOrder: temporaryOrder, mode: mode), style: .blocks, focusItemTag: mode == .account ? UsernameEntryTag.username : nil, animateChanges: true)
|
||||
|
||||
return (controllerState, (listState, arguments))
|
||||
} |> afterDisposed {
|
||||
|
|
|
|||
|
|
@ -1497,7 +1497,7 @@ final class ShareControllerNode: ViewControllerTracingNode, ASScrollViewDelegate
|
|||
if fromForeignApp, case let .preparing(long) = status, !transitioned {
|
||||
transitioned = true
|
||||
if long {
|
||||
strongSelf.transitionToContentNode(ShareProlongedLoadingContainerNode(theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, forceNativeAppearance: true, postbox: strongSelf.context?.stateManager.postbox, environment: strongSelf.environment), fastOut: true)
|
||||
strongSelf.transitionToContentNode(ShareProlongedLoadingContainerNode(theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings, forceNativeAppearance: true, environment: strongSelf.environment), fastOut: true)
|
||||
} else {
|
||||
strongSelf.transitionToContentNode(ShareLoadingContainerNode(theme: strongSelf.presentationData.theme, forceNativeAppearance: true), fastOut: true)
|
||||
}
|
||||
|
|
@ -1880,7 +1880,7 @@ final class ShareControllerNode: ViewControllerTracingNode, ASScrollViewDelegate
|
|||
transition.updateAlpha(node: startAtTimestampNode, alpha: 0.0)
|
||||
}
|
||||
|
||||
self.transitionToContentNode(ShareProlongedLoadingContainerNode(theme: self.presentationData.theme, strings: self.presentationData.strings, forceNativeAppearance: true, postbox: self.context?.stateManager.postbox, environment: self.environment), fastOut: true)
|
||||
self.transitionToContentNode(ShareProlongedLoadingContainerNode(theme: self.presentationData.theme, strings: self.presentationData.strings, forceNativeAppearance: true, environment: self.environment), fastOut: true)
|
||||
let timestamp = CACurrentMediaTime()
|
||||
self.shareDisposable.set(signal.start(completed: { [weak self] in
|
||||
let minDelay = 0.6
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import TelegramAnimatedStickerNode
|
|||
import AppBundle
|
||||
import TelegramUniversalVideoContent
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import AccountContext
|
||||
|
||||
private func fileSize(_ path: String, useTotalFileAllocatedSize: Bool = false) -> Int64? {
|
||||
|
|
@ -235,7 +234,7 @@ public final class ShareProlongedLoadingContainerNode: ASDisplayNode, ShareConte
|
|||
return self.elapsedTime + 3.0 + 0.15
|
||||
}
|
||||
|
||||
public init(theme: PresentationTheme, strings: PresentationStrings, forceNativeAppearance: Bool, postbox: Postbox?, environment: ShareControllerEnvironment) {
|
||||
public init(theme: PresentationTheme, strings: PresentationStrings, forceNativeAppearance: Bool, environment: ShareControllerEnvironment) {
|
||||
self.theme = theme
|
||||
self.strings = strings
|
||||
|
||||
|
|
@ -276,8 +275,7 @@ public final class ShareProlongedLoadingContainerNode: ASDisplayNode, ShareConte
|
|||
}
|
||||
}))
|
||||
|
||||
if let postbox, let mediaManager = environment.mediaManager, let path = getAppBundle().path(forResource: "BlankVideo", ofType: "m4v"), let size = fileSize(path) {
|
||||
let _ = postbox
|
||||
if let mediaManager = environment.mediaManager, let path = getAppBundle().path(forResource: "BlankVideo", ofType: "m4v"), let size = fileSize(path) {
|
||||
let _ = mediaManager
|
||||
|
||||
let decoration = ChatBubbleVideoDecoration(corners: ImageCorners(), nativeSize: CGSize(width: 100.0, height: 100.0), contentMode: .aspectFit, backgroundColor: .black)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import Display
|
|||
import AsyncDisplayKit
|
||||
import ComponentFlow
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import AccountContext
|
||||
import TelegramPresentationData
|
||||
|
|
@ -124,7 +123,7 @@ final class StatsMessageItemNode: ListViewItemNode, ItemListItemNode {
|
|||
private let activateArea: AccessibilityAreaNode
|
||||
|
||||
private var item: StatsMessageItem?
|
||||
private var contentImageMedia: Media?
|
||||
private var contentImageMedia: EngineRawMedia?
|
||||
|
||||
override public var canBeSelected: Bool {
|
||||
return true
|
||||
|
|
@ -307,7 +306,7 @@ final class StatsMessageItemNode: ListViewItemNode, ItemListItemNode {
|
|||
let presentationData = item.context.sharedContext.currentPresentationData.with { $0 }
|
||||
|
||||
var text: String
|
||||
var contentImageMedia: Media?
|
||||
var contentImageMedia: EngineRawMedia?
|
||||
let timestamp: Int32
|
||||
|
||||
switch item.item {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import AsyncDisplayKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
|
|
@ -357,19 +356,19 @@ public final class CallController: ViewController {
|
|||
self.superDismiss()
|
||||
}
|
||||
|
||||
let callPeerView: Signal<PeerView?, NoError>
|
||||
callPeerView = self.account.postbox.peerView(id: self.call.peerId) |> map(Optional.init)
|
||||
|
||||
let callPeerView: Signal<EnginePeer?, NoError>
|
||||
callPeerView = TelegramEngine(account: self.account).data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: self.call.peerId))
|
||||
|
||||
self.peerDisposable = (combineLatest(queue: .mainQueue(),
|
||||
self.account.postbox.peerView(id: self.account.peerId) |> take(1),
|
||||
TelegramEngine(account: self.account).data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: self.account.peerId)) |> take(1),
|
||||
callPeerView,
|
||||
self.sharedContext.activeAccountsWithInfo |> take(1)
|
||||
)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] accountView, view, activeAccountsWithInfo in
|
||||
if let strongSelf = self {
|
||||
if let view {
|
||||
if let accountPeer = accountView.peers[accountView.peerId], let peer = view.peers[view.peerId] {
|
||||
strongSelf.controllerNode.updatePeer(accountPeer: EnginePeer(accountPeer), peer: EnginePeer(peer), hasOther: activeAccountsWithInfo.accounts.count > 1)
|
||||
if let accountPeer = accountView {
|
||||
strongSelf.controllerNode.updatePeer(accountPeer: accountPeer, peer: view, hasOther: activeAccountsWithInfo.accounts.count > 1)
|
||||
strongSelf.isDataReady.set(.single(true))
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import UIKit
|
|||
import AsyncDisplayKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
|
|
@ -368,9 +367,9 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||
strongSelf.update()
|
||||
}
|
||||
}))
|
||||
let callPeerView: Signal<PeerView?, NoError>
|
||||
let callPeerView: Signal<EnginePeer?, NoError>
|
||||
if let peerId = call.peerId {
|
||||
callPeerView = account.postbox.peerView(id: peerId) |> map(Optional.init)
|
||||
callPeerView = TelegramEngine(account: account).data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId))
|
||||
} else {
|
||||
callPeerView = .single(nil)
|
||||
}
|
||||
|
|
@ -384,7 +383,7 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||
|> deliverOnMainQueue).start(next: { [weak self] view, state, isMuted, members in
|
||||
if let strongSelf = self {
|
||||
if let view {
|
||||
strongSelf.currentPeer = view.peers[view.peerId].flatMap(EnginePeer.init)
|
||||
strongSelf.currentPeer = view
|
||||
} else {
|
||||
strongSelf.currentPeer = nil
|
||||
}
|
||||
|
|
@ -429,14 +428,14 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||
var effectiveLevel: Float = 0.0
|
||||
var audioLevels = audioLevels
|
||||
if !strongSelf.currentIsMuted {
|
||||
audioLevels.append((PeerId(0), 0, myAudioLevel, true))
|
||||
audioLevels.append((EnginePeer.Id(0), 0, myAudioLevel, true))
|
||||
}
|
||||
effectiveLevel = audioLevels.map { $0.2 }.max() ?? 0.0
|
||||
strongSelf.backgroundNode.audioLevel = effectiveLevel
|
||||
}))
|
||||
|
||||
if let groupCall = call as? PresentationGroupCallImpl {
|
||||
let _ = (allowedStoryReactions(account: account)
|
||||
let _ = (allowedStoryReactions(engine: TelegramEngine(account: account))
|
||||
|> deliverOnMainQueue).start(next: { [weak self] reactionItems in
|
||||
self?.reactionItems = reactionItems
|
||||
})
|
||||
|
|
@ -479,19 +478,19 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||
membersCount = 1
|
||||
}
|
||||
|
||||
var speakingPeer: Peer?
|
||||
var speakingPeer: EnginePeer?
|
||||
if let members = currentMembers {
|
||||
var speakingPeers: [Peer] = []
|
||||
var speakingPeers: [EnginePeer] = []
|
||||
for member in members.participants {
|
||||
if let memberPeer = member.peer, members.speakingParticipants.contains(memberPeer.id) {
|
||||
speakingPeers.append(memberPeer._asPeer())
|
||||
speakingPeers.append(memberPeer)
|
||||
}
|
||||
}
|
||||
speakingPeer = speakingPeers.first
|
||||
}
|
||||
|
||||
|
||||
if let speakingPeer = speakingPeer {
|
||||
speakerSubtitle = EnginePeer(speakingPeer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
speakerSubtitle = speakingPeer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
}
|
||||
displaySpeakerSubtitle = speakerSubtitle != title && !speakerSubtitle.isEmpty
|
||||
|
||||
|
|
|
|||
|
|
@ -1497,7 +1497,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||
if let peerId {
|
||||
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
rawAdminIds = Signal { subscriber in
|
||||
let (disposable, _) = accountContext.peerChannelMemberCategoriesContextsManager.admins(engine: accountContext.engine, postbox: accountContext.account.postbox, network: accountContext.account.network, accountPeerId: accountContext.account.peerId, peerId: peerId, updated: { list in
|
||||
let (disposable, _) = accountContext.peerChannelMemberCategoriesContextsManager.admins(engine: accountContext.engine, accountPeerId: accountContext.account.peerId, peerId: peerId, updated: { list in
|
||||
var peerIds = Set<PeerId>()
|
||||
for item in list.list {
|
||||
if let adminInfo = item.participant.adminInfo, adminInfo.rights.rights.contains(.canManageCalls) {
|
||||
|
|
@ -1982,7 +1982,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||
return EmptyDisposable
|
||||
}
|
||||
|
||||
let (disposable, _) = self.accountContext.peerChannelMemberCategoriesContextsManager.admins(engine: self.accountContext.engine, postbox: self.accountContext.account.postbox, network: self.accountContext.account.network, accountPeerId: self.accountContext.account.peerId, peerId: peerId, updated: { list in
|
||||
let (disposable, _) = self.accountContext.peerChannelMemberCategoriesContextsManager.admins(engine: self.accountContext.engine, accountPeerId: self.accountContext.account.peerId, peerId: peerId, updated: { list in
|
||||
var peerIds = Set<PeerId>()
|
||||
for item in list.list {
|
||||
if let adminInfo = item.participant.adminInfo, adminInfo.rights.rights.contains(.canManageCalls) {
|
||||
|
|
@ -2326,7 +2326,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||
if let peerId = peerId ?? self.streamPeerId {
|
||||
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
rawAdminIds = Signal { subscriber in
|
||||
let (disposable, _) = accountContext.peerChannelMemberCategoriesContextsManager.admins(engine: accountContext.engine, postbox: accountContext.account.postbox, network: accountContext.account.network, accountPeerId: accountContext.account.peerId, peerId: peerId, updated: { list in
|
||||
let (disposable, _) = accountContext.peerChannelMemberCategoriesContextsManager.admins(engine: accountContext.engine, accountPeerId: accountContext.account.peerId, peerId: peerId, updated: { list in
|
||||
var peerIds = Set<PeerId>()
|
||||
for item in list.list {
|
||||
if let adminInfo = item.participant.adminInfo, adminInfo.rights.rights.contains(.canManageCalls) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import AsyncDisplayKit
|
|||
import Display
|
||||
import ComponentFlow
|
||||
import ViewControllerComponent
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import AccountContext
|
||||
import PlainButtonComponent
|
||||
|
|
@ -1419,7 +1418,7 @@ final class VideoChatScreenComponent: Component {
|
|||
)
|
||||
self.inputMediaInteraction?.forceTheme = defaultDarkColorPresentationTheme
|
||||
|
||||
let _ = (allowedStoryReactions(account: context.account)
|
||||
let _ = (allowedStoryReactions(engine: context.engine)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] reactionItems in
|
||||
self?.reactionItems = reactionItems
|
||||
})
|
||||
|
|
@ -4269,20 +4268,16 @@ private func hasFirstResponder(_ view: UIView) -> Bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func allowedStoryReactions(account: Account) -> Signal<[ReactionItem], NoError> {
|
||||
let viewKey: PostboxViewKey = .orderedItemList(id: Namespaces.OrderedItemList.CloudTopReactions)
|
||||
let topReactions = account.postbox.combinedView(keys: [viewKey])
|
||||
|> map { views -> [RecentReactionItem] in
|
||||
guard let view = views.views[viewKey] as? OrderedItemListView else {
|
||||
return []
|
||||
}
|
||||
return view.items.compactMap { item -> RecentReactionItem? in
|
||||
func allowedStoryReactions(engine: TelegramEngine) -> Signal<[ReactionItem], NoError> {
|
||||
let topReactions = engine.data.subscribe(TelegramEngine.EngineData.Item.OrderedLists.ListItems(collectionId: Namespaces.OrderedItemList.CloudTopReactions))
|
||||
|> map { items -> [RecentReactionItem] in
|
||||
return items.compactMap { item -> RecentReactionItem? in
|
||||
return item.contents.get(RecentReactionItem.self)
|
||||
}
|
||||
}
|
||||
|
||||
return combineLatest(
|
||||
TelegramEngine(account: account).stickers.availableReactions(),
|
||||
engine.stickers.availableReactions(),
|
||||
topReactions
|
||||
)
|
||||
|> take(1)
|
||||
|
|
|
|||
|
|
@ -66,4 +66,48 @@ public extension TelegramEngine.EngineData.Item {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum ItemCollections {
|
||||
public struct InstalledPackInfos: TelegramEngineDataItem, PostboxViewDataItem {
|
||||
public typealias Result = [EngineRawItemCollectionInfoEntry]
|
||||
|
||||
private let namespace: ItemCollectionId.Namespace
|
||||
|
||||
public init(namespace: ItemCollectionId.Namespace) {
|
||||
self.namespace = namespace
|
||||
}
|
||||
|
||||
var key: PostboxViewKey {
|
||||
return .itemCollectionInfos(namespaces: [self.namespace])
|
||||
}
|
||||
|
||||
func extract(view: PostboxView) -> Result {
|
||||
guard let view = view as? ItemCollectionInfosView else {
|
||||
preconditionFailure()
|
||||
}
|
||||
return view.entriesByNamespace[self.namespace] ?? []
|
||||
}
|
||||
}
|
||||
|
||||
public struct InstalledPackIds: TelegramEngineDataItem, PostboxViewDataItem {
|
||||
public typealias Result = [ItemCollectionId]
|
||||
|
||||
private let namespace: ItemCollectionId.Namespace
|
||||
|
||||
public init(namespace: ItemCollectionId.Namespace) {
|
||||
self.namespace = namespace
|
||||
}
|
||||
|
||||
var key: PostboxViewKey {
|
||||
return .itemCollectionIds(namespaces: [self.namespace])
|
||||
}
|
||||
|
||||
func extract(view: PostboxView) -> Result {
|
||||
guard let view = view as? ItemCollectionIdsView else {
|
||||
preconditionFailure()
|
||||
}
|
||||
return Array(view.idsByNamespace[self.namespace] ?? [])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -310,6 +310,30 @@ public extension TelegramEngine.EngineData.Item {
|
|||
}
|
||||
}
|
||||
|
||||
public struct CachedData: TelegramEngineDataItem, TelegramEngineMapKeyDataItem, PostboxViewDataItem {
|
||||
public typealias Result = Optional<EngineCachedPeerData>
|
||||
|
||||
fileprivate var id: EnginePeer.Id
|
||||
public var mapKey: EnginePeer.Id {
|
||||
return self.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()
|
||||
}
|
||||
return view.cachedPeerData
|
||||
}
|
||||
}
|
||||
|
||||
public struct ParticipantCount: TelegramEngineDataItem, TelegramEngineMapKeyDataItem, PostboxViewDataItem {
|
||||
public typealias Result = Optional<Int>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
import Foundation
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
|
||||
public extension TelegramEngine {
|
||||
final class ItemCollections {
|
||||
private let account: Account
|
||||
|
||||
init(account: Account) {
|
||||
self.account = account
|
||||
}
|
||||
|
||||
public func allItems(namespace: ItemCollectionId.Namespace) -> Signal<[EngineRawItemCollectionItem], NoError> {
|
||||
return self.account.postbox.itemCollectionsView(orderedItemListCollectionIds: [], namespaces: [namespace], aroundIndex: nil, count: 10000000)
|
||||
|> map { view -> [EngineRawItemCollectionItem] in
|
||||
return view.entries.map { $0.item }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -80,7 +80,11 @@ public final class TelegramEngine {
|
|||
public lazy var orderedLists: OrderedLists = {
|
||||
return OrderedLists(account: self.account)
|
||||
}()
|
||||
|
||||
|
||||
public lazy var itemCollections: ItemCollections = {
|
||||
return ItemCollections(account: self.account)
|
||||
}()
|
||||
|
||||
public lazy var itemCache: ItemCache = {
|
||||
return ItemCache(account: self.account)
|
||||
}()
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ public typealias EngineMediaResourceDataFetchError = MediaResourceDataFetchError
|
|||
public typealias EngineMediaResourceStatus = MediaResourceStatus
|
||||
public typealias EnginePostboxCoding = PostboxCoding
|
||||
public typealias EngineRawItemCollectionInfo = ItemCollectionInfo
|
||||
public typealias EngineRawItemCollectionInfoEntry = ItemCollectionInfoEntry
|
||||
public typealias EngineRawItemCollectionItem = ItemCollectionItem
|
||||
public typealias EngineRawMedia = Media
|
||||
public typealias EngineRawMessage = Message
|
||||
|
|
@ -43,11 +44,43 @@ public typealias EngineRawMediaResourceDataFetchCopyLocalItem = MediaResourceDat
|
|||
public typealias EngineRawCachedMediaResourceRepresentation = CachedMediaResourceRepresentation
|
||||
public typealias EngineCachedMediaRepresentationKeepDuration = CachedMediaRepresentationKeepDuration
|
||||
public typealias EngineCachedPeerData = CachedPeerData
|
||||
public typealias EngineMessageHistoryThreadData = MessageHistoryThreadData
|
||||
public typealias EngineViewUpdateType = ViewUpdateType
|
||||
public typealias EngineRawPeerPresence = PeerPresence
|
||||
public typealias EnginePeerGroupId = PeerGroupId
|
||||
public typealias EngineChatLocationInput = ChatLocationInput
|
||||
public typealias EngineHistoryViewInputTag = HistoryViewInputTag
|
||||
public typealias EngineInitialMessageHistoryData = InitialMessageHistoryData
|
||||
public typealias EngineSimpleDictionary = SimpleDictionary
|
||||
public typealias EngineRawValueBoxKey = ValueBoxKey
|
||||
public typealias EngineRawMessageHistoryView = MessageHistoryView
|
||||
public typealias EngineRawPeerView = PeerView
|
||||
public typealias EngineRawMessageHistoryEntry = MessageHistoryEntry
|
||||
public typealias EngineRawMutableMessageHistoryEntryAttributes = MutableMessageHistoryEntryAttributes
|
||||
public typealias EngineMessageHistoryViewReadState = MessageHistoryViewReadState
|
||||
public typealias EngineMessageIdNamespaces = MessageIdNamespaces
|
||||
public typealias EngineHistoryViewInputAnchor = HistoryViewInputAnchor
|
||||
public typealias EngineRawPostboxViewKey = PostboxViewKey
|
||||
public typealias EngineRawPreferencesView = PreferencesView
|
||||
public typealias EngineRawOrderedItemListView = OrderedItemListView
|
||||
public typealias EngineRawUnreadMessageCountsView = UnreadMessageCountsView
|
||||
public typealias EngineRawMessageHistoryThreadIndexView = MessageHistoryThreadIndexView
|
||||
public typealias EngineRawCombinedReadStateView = CombinedReadStateView
|
||||
public typealias EngineRawMessageHistoryThreadInfoView = MessageHistoryThreadInfoView
|
||||
public typealias EngineRawBasicPeerView = BasicPeerView
|
||||
public typealias EngineRawCachedPeerDataView = CachedPeerDataView
|
||||
public typealias EngineRawUnreadMessageCountsItem = UnreadMessageCountsItem
|
||||
public typealias EngineRawMessageHistorySavedMessagesIndexView = MessageHistorySavedMessagesIndexView
|
||||
public typealias EngineRawChatInterfaceStateView = ChatInterfaceStateView
|
||||
|
||||
public func engineFileSize(_ path: String, useTotalFileAllocatedSize: Bool = false) -> Int64? {
|
||||
return fileSize(path, useTotalFileAllocatedSize: useTotalFileAllocatedSize)
|
||||
}
|
||||
|
||||
public func engineAreMediaArraysEqual(_ lhs: [EngineRawMedia], _ rhs: [EngineRawMedia]) -> Bool {
|
||||
return areMediaArraysEqual(lhs, rhs)
|
||||
}
|
||||
|
||||
public func enginePersistentHash32(_ string: String) -> Int32 {
|
||||
return persistentHash32(string)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Intents
|
||||
import Display
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import TelegramUIPreferences
|
||||
|
|
@ -55,7 +54,7 @@ public enum SendMessageIntentSubject: CaseIterable {
|
|||
}
|
||||
}
|
||||
|
||||
public func donateSendMessageIntent(account: Account, sharedContext: SharedAccountContext, intentContext: SendMessageIntentContext, peerIds: [PeerId]) {
|
||||
public func donateSendMessageIntent(account: Account, sharedContext: SharedAccountContext, intentContext: SendMessageIntentContext, peerIds: [EnginePeer.Id]) {
|
||||
if #available(iOSApplicationExtension 13.2, iOS 13.2, *) {
|
||||
let _ = (sharedContext.accountManager.transaction { transaction -> Bool in
|
||||
if case .none = transaction.getAccessChallengeData() {
|
||||
|
|
@ -64,11 +63,11 @@ public func donateSendMessageIntent(account: Account, sharedContext: SharedAccou
|
|||
return false
|
||||
}
|
||||
}
|
||||
|> mapToSignal { unlocked -> Signal<[(Peer, SendMessageIntentSubject, UIImage?)], NoError> in
|
||||
|> mapToSignal { unlocked -> Signal<[(EngineRawPeer, SendMessageIntentSubject, UIImage?)], NoError> in
|
||||
if unlocked {
|
||||
return sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.intentsSettings])
|
||||
|> take(1)
|
||||
|> mapToSignal { sharedData -> Signal<[(Peer, SendMessageIntentSubject)], NoError> in
|
||||
|> mapToSignal { sharedData -> Signal<[(EngineRawPeer, SendMessageIntentSubject)], NoError> in
|
||||
let settings = sharedData.entries[ApplicationSpecificSharedDataKeys.intentsSettings]?.get(IntentsSettings.self) ?? IntentsSettings.defaultSettings
|
||||
if let accountId = settings.account, accountId != account.peerId {
|
||||
return .single([])
|
||||
|
|
@ -82,8 +81,8 @@ public func donateSendMessageIntent(account: Account, sharedContext: SharedAccou
|
|||
EngineDataMap(peerIds.map(TelegramEngine.EngineData.Item.Peer.IsContact.init)),
|
||||
EngineDataMap(peerIds.map(TelegramEngine.EngineData.Item.Messages.ChatListGroup.init))
|
||||
)
|
||||
|> map { peerMap, isContactMap, chatListGroupMap -> [(Peer, SendMessageIntentSubject)] in
|
||||
var peers: [(Peer, SendMessageIntentSubject)] = []
|
||||
|> map { peerMap, isContactMap, chatListGroupMap -> [(EngineRawPeer, SendMessageIntentSubject)] in
|
||||
var peers: [(EngineRawPeer, SendMessageIntentSubject)] = []
|
||||
for peerId in peerIds {
|
||||
if peerId.namespace != Namespaces.Peer.SecretChat, let maybePeer = peerMap[peerId], let peer = maybePeer {
|
||||
var subject: SendMessageIntentSubject?
|
||||
|
|
@ -134,14 +133,14 @@ public func donateSendMessageIntent(account: Account, sharedContext: SharedAccou
|
|||
return peers
|
||||
}
|
||||
}
|
||||
|> mapToSignal { peers -> Signal<[(Peer, SendMessageIntentSubject, UIImage?)], NoError> in
|
||||
var signals: [Signal<(Peer, SendMessageIntentSubject, UIImage?), NoError>] = []
|
||||
|> mapToSignal { peers -> Signal<[(EngineRawPeer, SendMessageIntentSubject, UIImage?)], NoError> in
|
||||
var signals: [Signal<(EngineRawPeer, SendMessageIntentSubject, UIImage?), NoError>] = []
|
||||
for (peer, subject) in peers {
|
||||
if peer.id == account.peerId {
|
||||
signals.append(.single((peer, subject, savedMessagesAvatar)))
|
||||
} else {
|
||||
let peerAndAvatar = (peerAvatarImage(account: account, peerReference: PeerReference(peer), authorOfMessage: nil, representation: peer.smallProfileImage, clipStyle: .none) ?? .single(nil))
|
||||
|> map { imageVersions -> (Peer, SendMessageIntentSubject, UIImage?) in
|
||||
|> map { imageVersions -> (EngineRawPeer, SendMessageIntentSubject, UIImage?) in
|
||||
var avatarImage: UIImage?
|
||||
if let image = imageVersions?.0 {
|
||||
avatarImage = image
|
||||
|
|
@ -214,7 +213,7 @@ public func donateSendMessageIntent(account: Account, sharedContext: SharedAccou
|
|||
}
|
||||
}
|
||||
|
||||
public func deleteSendMessageIntents(peerId: PeerId) {
|
||||
public func deleteSendMessageIntents(peerId: EnginePeer.Id) {
|
||||
if #available(iOS 10.0, *) {
|
||||
INInteraction.delete(with: "sendMessage_\(peerId.toInt64())")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import UIKit
|
|||
import AsyncDisplayKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import LegacyComponents
|
||||
import TelegramPresentationData
|
||||
|
|
@ -32,14 +31,14 @@ private final class AttachmentFileControllerArguments {
|
|||
let scanDocument: () -> Void
|
||||
let expandSavedMusic: () -> Void
|
||||
let expandRecentMusic: () -> Void
|
||||
let send: (Message) -> Void
|
||||
let toggleMediaPlayback: (Message) -> Void
|
||||
let send: (EngineRawMessage) -> Void
|
||||
let toggleMediaPlayback: (EngineRawMessage) -> Void
|
||||
let isSelectionActive: () -> Bool
|
||||
let toggleMessageSelection: (Message) -> Void
|
||||
let setMessageSelection: ([MessageId], Message?, Bool) -> Void
|
||||
let toggleMessageSelection: (EngineRawMessage) -> Void
|
||||
let setMessageSelection: ([EngineMessage.Id], EngineRawMessage?, Bool) -> Void
|
||||
let openMessageContextAction: ((EngineMessage, ASDisplayNode?, CGRect?, UIGestureRecognizer?) -> Void)
|
||||
|
||||
init(context: AccountContext, isAudio: Bool, isAttach: Bool, openGallery: @escaping () -> Void, openFiles: @escaping () -> Void, scanDocument: @escaping () -> Void, expandSavedMusic: @escaping () -> Void, expandRecentMusic: @escaping () -> Void, send: @escaping (Message) -> Void, toggleMediaPlayback: @escaping (Message) -> Void, isSelectionActive: @escaping () -> Bool, toggleMessageSelection: @escaping (Message) -> Void, setMessageSelection: @escaping ([MessageId], Message?, Bool) -> Void, openMessageContextAction: @escaping ((EngineMessage, ASDisplayNode?, CGRect?, UIGestureRecognizer?) -> Void)) {
|
||||
init(context: AccountContext, isAudio: Bool, isAttach: Bool, openGallery: @escaping () -> Void, openFiles: @escaping () -> Void, scanDocument: @escaping () -> Void, expandSavedMusic: @escaping () -> Void, expandRecentMusic: @escaping () -> Void, send: @escaping (EngineRawMessage) -> Void, toggleMediaPlayback: @escaping (EngineRawMessage) -> Void, isSelectionActive: @escaping () -> Bool, toggleMessageSelection: @escaping (EngineRawMessage) -> Void, setMessageSelection: @escaping ([EngineMessage.Id], EngineRawMessage?, Bool) -> Void, openMessageContextAction: @escaping ((EngineMessage, ASDisplayNode?, CGRect?, UIGestureRecognizer?) -> Void)) {
|
||||
self.context = context
|
||||
self.isAudio = isAudio
|
||||
self.isAttach = isAttach
|
||||
|
|
@ -64,7 +63,7 @@ private enum AttachmentFileSection: Int32 {
|
|||
case global
|
||||
}
|
||||
|
||||
private func areMessagesEqual(_ lhsMessage: Message?, _ rhsMessage: Message?) -> Bool {
|
||||
private func areMessagesEqual(_ lhsMessage: EngineRawMessage?, _ rhsMessage: EngineRawMessage?) -> Bool {
|
||||
guard let lhsMessage = lhsMessage, let rhsMessage = rhsMessage else {
|
||||
return lhsMessage == nil && rhsMessage == nil
|
||||
}
|
||||
|
|
@ -83,15 +82,15 @@ private enum AttachmentFileEntry: ItemListNodeEntry {
|
|||
case scanDocument(PresentationTheme, String)
|
||||
|
||||
case savedHeader(PresentationTheme, String)
|
||||
case savedFile(Int32, PresentationTheme, Message?, ChatHistoryMessageSelection)
|
||||
case savedFile(Int32, PresentationTheme, EngineRawMessage?, ChatHistoryMessageSelection)
|
||||
case savedShowMore(PresentationTheme, String)
|
||||
|
||||
case recentHeader(PresentationTheme, String)
|
||||
case recentFile(Int32, PresentationTheme, Message?, ChatHistoryMessageSelection)
|
||||
case recentFile(Int32, PresentationTheme, EngineRawMessage?, ChatHistoryMessageSelection)
|
||||
case recentShowMore(PresentationTheme, String)
|
||||
|
||||
case globalHeader(PresentationTheme, String)
|
||||
case globalFile(Int32, PresentationTheme, Message?, ChatHistoryMessageSelection)
|
||||
case globalFile(Int32, PresentationTheme, EngineRawMessage?, ChatHistoryMessageSelection)
|
||||
case globalShowMore(PresentationTheme, String)
|
||||
|
||||
var section: ItemListSectionId {
|
||||
|
|
@ -277,7 +276,7 @@ private enum AttachmentFileEntry: ItemListNodeEntry {
|
|||
|
||||
let dateTimeFormat = arguments.context.sharedContext.currentPresentationData.with({$0}).dateTimeFormat
|
||||
let chatPresentationData = ChatPresentationData(theme: ChatPresentationThemeData(theme: presentationData.theme, wallpaper: .color(0)), fontSize: presentationData.fontSize, strings: presentationData.strings, dateTimeFormat: dateTimeFormat, nameDisplayOrder: .firstLast, disableAnimations: false, largeEmoji: false, chatBubbleCorners: PresentationChatBubbleCorners(mainRadius: 0, auxiliaryRadius: 0, mergeBubbleCorners: false))
|
||||
return ListMessageItem(presentationData: chatPresentationData, systemStyle: .glass, context: arguments.context, chatLocation: .peer(id: PeerId(0)), interaction: interaction, message: message, selection: selection, displayHeader: false, isDownloadList: arguments.isAudio, isStoryMusic: true, isAttachMusic: arguments.isAttach, displayFileInfo: true, displayBackground: true, style: .blocks, sectionId: self.section)
|
||||
return ListMessageItem(presentationData: chatPresentationData, systemStyle: .glass, context: arguments.context, chatLocation: .peer(id: EnginePeer.Id(0)), interaction: interaction, message: message, selection: selection, displayHeader: false, isDownloadList: arguments.isAudio, isStoryMusic: true, isAttachMusic: arguments.isAttach, displayFileInfo: true, displayBackground: true, style: .blocks, sectionId: self.section)
|
||||
case let .recentShowMore(theme, text):
|
||||
return ItemListPeerActionItem(presentationData: presentationData, systemStyle: .glass, icon: PresentationResourcesItemList.downArrowImage(theme), title: text, sectionId: self.section, editing: false, action: {
|
||||
arguments.expandRecentMusic()
|
||||
|
|
@ -302,7 +301,7 @@ private enum AttachmentFileEntry: ItemListNodeEntry {
|
|||
|
||||
let dateTimeFormat = arguments.context.sharedContext.currentPresentationData.with({$0}).dateTimeFormat
|
||||
let chatPresentationData = ChatPresentationData(theme: ChatPresentationThemeData(theme: presentationData.theme, wallpaper: .color(0)), fontSize: presentationData.fontSize, strings: presentationData.strings, dateTimeFormat: dateTimeFormat, nameDisplayOrder: .firstLast, disableAnimations: false, largeEmoji: false, chatBubbleCorners: PresentationChatBubbleCorners(mainRadius: 0, auxiliaryRadius: 0, mergeBubbleCorners: false))
|
||||
return ListMessageItem(presentationData: chatPresentationData, systemStyle: .glass, context: arguments.context, chatLocation: .peer(id: PeerId(0)), interaction: interaction, message: message, selection: selection, displayHeader: false, isDownloadList: arguments.isAudio, isStoryMusic: true, isAttachMusic: arguments.isAttach, displayFileInfo: true, displayBackground: true, style: .blocks, sectionId: self.section)
|
||||
return ListMessageItem(presentationData: chatPresentationData, systemStyle: .glass, context: arguments.context, chatLocation: .peer(id: EnginePeer.Id(0)), interaction: interaction, message: message, selection: selection, displayHeader: false, isDownloadList: arguments.isAudio, isStoryMusic: true, isAttachMusic: arguments.isAttach, displayFileInfo: true, displayBackground: true, style: .blocks, sectionId: self.section)
|
||||
case let .globalShowMore(theme, text):
|
||||
return ItemListPeerActionItem(presentationData: presentationData, systemStyle: .glass, icon: PresentationResourcesItemList.downArrowImage(theme), title: text, sectionId: self.section, editing: false, action: {
|
||||
|
||||
|
|
@ -315,8 +314,8 @@ private func attachmentFileControllerEntries(
|
|||
presentationData: PresentationData,
|
||||
mode: AttachmentFileControllerMode,
|
||||
state: AttachmentFileControllerState,
|
||||
savedMusic: [Message]?,
|
||||
recentDocuments: [Message]?,
|
||||
savedMusic: [EngineRawMessage]?,
|
||||
recentDocuments: [EngineRawMessage]?,
|
||||
hasScan: Bool,
|
||||
empty: Bool
|
||||
) -> [AttachmentFileEntry] {
|
||||
|
|
@ -513,11 +512,11 @@ private struct AttachmentFileControllerState: Equatable {
|
|||
var searching: Bool
|
||||
var savedMusicExpanded: Bool
|
||||
var recentMusicExpanded: Bool
|
||||
var selectedMessageIds: [MessageId]?
|
||||
var messageMap: [MessageId: EngineMessage]
|
||||
var selectedMessageIds: [EngineMessage.Id]?
|
||||
var messageMap: [EngineMessage.Id: EngineMessage]
|
||||
}
|
||||
|
||||
private func messageSelectionState(state: AttachmentFileControllerState, message: Message?) -> ChatHistoryMessageSelection {
|
||||
private func messageSelectionState(state: AttachmentFileControllerState, message: EngineRawMessage?) -> ChatHistoryMessageSelection {
|
||||
guard let message, let selectedMessageIds = state.selectedMessageIds else {
|
||||
return .none
|
||||
}
|
||||
|
|
@ -641,7 +640,7 @@ public func makeAttachmentFileControllerImpl(
|
|||
|> `catch` { _ in
|
||||
return .single(.result([]))
|
||||
}
|
||||
|> mapToSignal { result -> Signal<[Message], NoError> in
|
||||
|> mapToSignal { result -> Signal<[EngineRawMessage], NoError> in
|
||||
guard case let .result(result) = result else {
|
||||
return .complete()
|
||||
}
|
||||
|
|
@ -739,15 +738,15 @@ public func makeAttachmentFileControllerImpl(
|
|||
}
|
||||
)
|
||||
|
||||
let recentDocuments: Signal<[Message]?, NoError>
|
||||
let recentDocuments: Signal<[EngineRawMessage]?, NoError>
|
||||
let savedMusicContext: ProfileSavedMusicContext?
|
||||
let savedMusic: Signal<[Message]?, NoError>
|
||||
let savedMusic: Signal<[EngineRawMessage]?, NoError>
|
||||
switch mode {
|
||||
case .recent:
|
||||
recentDocuments = .single(nil)
|
||||
|> then(
|
||||
context.engine.messages.searchMessages(location: .sentMedia(tags: [.file]), query: "", state: nil)
|
||||
|> map { result -> [Message]? in
|
||||
|> map { result -> [EngineRawMessage]? in
|
||||
return result.0.messages
|
||||
}
|
||||
)
|
||||
|
|
@ -757,7 +756,7 @@ public func makeAttachmentFileControllerImpl(
|
|||
recentDocuments = .single(nil)
|
||||
|> then(
|
||||
context.engine.messages.searchMessages(location: .general(scope: .everywhere, groupId: nil, tags: [.music], minDate: nil, maxDate: nil, folderId: nil), query: "", state: nil)
|
||||
|> map { result -> [Message]? in
|
||||
|> map { result -> [EngineRawMessage]? in
|
||||
return result.0.messages
|
||||
}
|
||||
)
|
||||
|
|
@ -767,11 +766,11 @@ public func makeAttachmentFileControllerImpl(
|
|||
savedMusicContext!.state
|
||||
|> map { state in
|
||||
let peerId = context.account.peerId
|
||||
var messages: [Message] = []
|
||||
let peers = SimpleDictionary<PeerId, Peer>()
|
||||
var messages: [EngineRawMessage] = []
|
||||
let peers = EngineSimpleDictionary<EnginePeer.Id, EngineRawPeer>()
|
||||
for file in state.files {
|
||||
let stableId = UInt32(clamping: file.fileId.id % Int64(Int32.max))
|
||||
messages.append(Message(stableId: stableId, stableVersion: 0, id: MessageId(peerId: peerId, namespace: Namespaces.Message.Local, id: Int32(stableId)), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [], tags: [.music], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: nil, text: "", attributes: [], media: [file], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:]))
|
||||
messages.append(EngineRawMessage(stableId: stableId, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: Namespaces.Message.Local, id: Int32(stableId)), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [], tags: [.music], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: nil, text: "", attributes: [], media: [file], peers: peers, associatedMessages: EngineSimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:]))
|
||||
}
|
||||
return messages
|
||||
}
|
||||
|
|
@ -783,7 +782,7 @@ public func makeAttachmentFileControllerImpl(
|
|||
let existingCloseButton = Atomic<BarComponentHostNode?>(value: nil)
|
||||
let existingSearchButton = Atomic<BarComponentHostNode?>(value: nil)
|
||||
|
||||
let previousRecentDocuments = Atomic<[Message]?>(value: nil)
|
||||
let previousRecentDocuments = Atomic<[EngineRawMessage]?>(value: nil)
|
||||
let signal = combineLatest(queue: Queue.mainQueue(),
|
||||
presentationData,
|
||||
recentDocuments,
|
||||
|
|
@ -960,7 +959,7 @@ public func makeAttachmentFileControllerImpl(
|
|||
controller.mulitpleCompletion = { sendMode, _, _, caption in
|
||||
let _ = stateValue.with({ state in
|
||||
if let selectedMessageIds = state.selectedMessageIds {
|
||||
var remoteMessageIds: [MessageId] = []
|
||||
var remoteMessageIds: [EngineMessage.Id] = []
|
||||
for id in selectedMessageIds {
|
||||
if let message = state.messageMap[id]?._asMessage() {
|
||||
if message.id.namespace == Namespaces.Message.Cloud {
|
||||
|
|
@ -974,7 +973,7 @@ public func makeAttachmentFileControllerImpl(
|
|||
|> `catch` { _ in
|
||||
return .single(.result([]))
|
||||
}
|
||||
|> mapToSignal { result -> Signal<[Message], NoError> in
|
||||
|> mapToSignal { result -> Signal<[EngineRawMessage], NoError> in
|
||||
guard case let .result(result) = result else {
|
||||
return .complete()
|
||||
}
|
||||
|
|
@ -984,7 +983,7 @@ public func makeAttachmentFileControllerImpl(
|
|||
guard let peer, let peerReference = PeerReference(peer) else {
|
||||
return
|
||||
}
|
||||
var messageMap: [MessageId: Message] = [:]
|
||||
var messageMap: [EngineMessage.Id: EngineRawMessage] = [:]
|
||||
for message in remoteMessages {
|
||||
messageMap[message.id] = message
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import AsyncDisplayKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import ItemListUI
|
||||
|
|
@ -30,7 +29,7 @@ final class AttachmentFileSearchItem: ItemListControllerSearch {
|
|||
let presentationData: PresentationData
|
||||
let focus: () -> Void
|
||||
let cancel: () -> Void
|
||||
let send: (Message) -> Void
|
||||
let send: (EngineRawMessage) -> Void
|
||||
let dismissInput: () -> Void
|
||||
let didPreviewAudio: () -> Void
|
||||
|
||||
|
|
@ -38,7 +37,7 @@ final class AttachmentFileSearchItem: ItemListControllerSearch {
|
|||
private var activity: ValuePromise<Bool> = ValuePromise(ignoreRepeated: false)
|
||||
private let activityDisposable = MetaDisposable()
|
||||
|
||||
init(context: AccountContext, mode: AttachmentFileControllerMode, presentationData: PresentationData, focus: @escaping () -> Void, cancel: @escaping () -> Void, send: @escaping (Message) -> Void, dismissInput: @escaping () -> Void, didPreviewAudio: @escaping () -> Void) {
|
||||
init(context: AccountContext, mode: AttachmentFileControllerMode, presentationData: PresentationData, focus: @escaping () -> Void, cancel: @escaping () -> Void, send: @escaping (EngineRawMessage) -> Void, dismissInput: @escaping () -> Void, didPreviewAudio: @escaping () -> Void) {
|
||||
self.context = context
|
||||
self.mode = mode
|
||||
self.presentationData = presentationData
|
||||
|
|
@ -108,7 +107,7 @@ private final class AttachmentFileSearchItemNode: ItemListControllerSearchNode {
|
|||
|
||||
private var validLayout: ContainerViewLayout?
|
||||
|
||||
init(context: AccountContext, mode: AttachmentFileControllerMode, presentationData: PresentationData, focus: @escaping () -> Void, send: @escaping (Message) -> Void, cancel: @escaping () -> Void, updateActivity: @escaping(Bool) -> Void, dismissInput: @escaping () -> Void, didPreviewAudio: @escaping () -> Void) {
|
||||
init(context: AccountContext, mode: AttachmentFileControllerMode, presentationData: PresentationData, focus: @escaping () -> Void, send: @escaping (EngineRawMessage) -> Void, cancel: @escaping () -> Void, updateActivity: @escaping(Bool) -> Void, dismissInput: @escaping () -> Void, didPreviewAudio: @escaping () -> Void) {
|
||||
self.context = context
|
||||
self.mode = mode
|
||||
self.presentationData = presentationData
|
||||
|
|
@ -217,11 +216,11 @@ private final class AttachmentFileSearchItemNode: ItemListControllerSearchNode {
|
|||
|
||||
private final class AttachmentFileSearchContainerInteraction {
|
||||
let context: AccountContext
|
||||
let send: (Message) -> Void
|
||||
let toggleMediaPlayback: (Message) -> Void
|
||||
let send: (EngineRawMessage) -> Void
|
||||
let toggleMediaPlayback: (EngineRawMessage) -> Void
|
||||
let expandSection: (Int32) -> Void
|
||||
|
||||
init(context: AccountContext, send: @escaping (Message) -> Void, toggleMediaPlayback: @escaping (Message) -> Void, expandSection: @escaping (Int32) -> Void) {
|
||||
init(context: AccountContext, send: @escaping (EngineRawMessage) -> Void, toggleMediaPlayback: @escaping (EngineRawMessage) -> Void, expandSection: @escaping (Int32) -> Void) {
|
||||
self.context = context
|
||||
self.send = send
|
||||
self.toggleMediaPlayback = toggleMediaPlayback
|
||||
|
|
@ -232,11 +231,11 @@ private final class AttachmentFileSearchContainerInteraction {
|
|||
private enum AttachmentFileSearchEntryId: Hashable {
|
||||
case header(Int32)
|
||||
case placeholder(Int32, Int32)
|
||||
case message(Int32, MessageId)
|
||||
case message(Int32, EngineMessage.Id)
|
||||
case showMore(Int32)
|
||||
}
|
||||
|
||||
private func areMessagesEqual(_ lhsMessage: Message?, _ rhsMessage: Message?) -> Bool {
|
||||
private func areMessagesEqual(_ lhsMessage: EngineRawMessage?, _ rhsMessage: EngineRawMessage?) -> Bool {
|
||||
guard let lhsMessage = lhsMessage, let rhsMessage = rhsMessage else {
|
||||
return lhsMessage == nil && rhsMessage == nil
|
||||
}
|
||||
|
|
@ -251,7 +250,7 @@ private func areMessagesEqual(_ lhsMessage: Message?, _ rhsMessage: Message?) ->
|
|||
|
||||
private enum AttachmentFileSearchEntry: Comparable, Identifiable {
|
||||
case header(title: String, section: Int32)
|
||||
case file(index: Int32, message: Message?, section: Int32)
|
||||
case file(index: Int32, message: EngineRawMessage?, section: Int32)
|
||||
case showMore(text: String, section: Int32)
|
||||
|
||||
var section: ItemListSectionId {
|
||||
|
|
@ -334,7 +333,7 @@ private enum AttachmentFileSearchEntry: Comparable, Identifiable {
|
|||
let isStoryMusic = mode.isAudio
|
||||
let isDownloadList = mode.isAudio
|
||||
|
||||
return ListMessageItem(presentationData: ChatPresentationData(presentationData: presentationData), systemStyle: .glass, context: interaction.context, chatLocation: .peer(id: PeerId(0)), interaction: itemInteraction, message: message, selection: .none, displayHeader: false, isDownloadList: isDownloadList, isStoryMusic: isStoryMusic, isAttachMusic: true, displayFileInfo: displayFileInfo, displayBackground: true, style: .blocks, sectionId: section)
|
||||
return ListMessageItem(presentationData: ChatPresentationData(presentationData: presentationData), systemStyle: .glass, context: interaction.context, chatLocation: .peer(id: EnginePeer.Id(0)), interaction: itemInteraction, message: message, selection: .none, displayHeader: false, isDownloadList: isDownloadList, isStoryMusic: isStoryMusic, isAttachMusic: true, displayFileInfo: displayFileInfo, displayBackground: true, style: .blocks, sectionId: section)
|
||||
case let .showMore(text, section):
|
||||
return ItemListPeerActionItem(presentationData: ItemListPresentationData(presentationData), style: .blocks, systemStyle: .glass, icon: PresentationResourcesItemList.downArrowImage(presentationData.theme), title: text, sectionId: section, editing: false, action: {
|
||||
interaction.expandSection(section)
|
||||
|
|
@ -379,7 +378,7 @@ private func attachmentFileSearchContainerPreparedRecentTransition(
|
|||
|
||||
public final class AttachmentFileSearchContainerNode: SearchDisplayControllerContentNode {
|
||||
private let context: AccountContext
|
||||
private let send: (Message) -> Void
|
||||
private let send: (EngineRawMessage) -> Void
|
||||
|
||||
private let dimNode: ASDisplayNode
|
||||
private let backgroundNode: ASDisplayNode
|
||||
|
|
@ -415,7 +414,7 @@ public final class AttachmentFileSearchContainerNode: SearchDisplayControllerCon
|
|||
return _hasDim
|
||||
}
|
||||
|
||||
public init(context: AccountContext, mode: AttachmentFileControllerMode, presentationData: PresentationData, send: @escaping (Message) -> Void, updateActivity: @escaping (Bool) -> Void, didPreviewAudio: @escaping () -> Void) {
|
||||
public init(context: AccountContext, mode: AttachmentFileControllerMode, presentationData: PresentationData, send: @escaping (EngineRawMessage) -> Void, updateActivity: @escaping (Bool) -> Void, didPreviewAudio: @escaping () -> Void) {
|
||||
self.context = context
|
||||
self.send = send
|
||||
|
||||
|
|
@ -512,16 +511,16 @@ public final class AttachmentFileSearchContainerNode: SearchDisplayControllerCon
|
|||
|
||||
let queryTokens = stringTokens(query.lowercased())
|
||||
|
||||
let shared: Signal<[Message]?, NoError>
|
||||
let savedMusic: Signal<[Message]?, NoError>
|
||||
let globalMusic: Signal<[Message]?, NoError>
|
||||
let shared: Signal<[EngineRawMessage]?, NoError>
|
||||
let savedMusic: Signal<[EngineRawMessage]?, NoError>
|
||||
let globalMusic: Signal<[EngineRawMessage]?, NoError>
|
||||
switch mode {
|
||||
case .recent:
|
||||
shared = .single(nil)
|
||||
|> then(
|
||||
context.engine.messages.searchMessages(location: .sentMedia(tags: [.file]), query: query, state: nil)
|
||||
|> delay(0.6, queue: Queue.mainQueue())
|
||||
|> map { result -> [Message]? in
|
||||
|> map { result -> [EngineRawMessage]? in
|
||||
return result.0.messages
|
||||
}
|
||||
)
|
||||
|
|
@ -532,7 +531,7 @@ public final class AttachmentFileSearchContainerNode: SearchDisplayControllerCon
|
|||
|> then(
|
||||
context.engine.messages.searchMessages(location: .general(scope: .everywhere, groupId: nil, tags: [.music], minDate: nil, maxDate: nil, folderId: nil), query: query, state: nil)
|
||||
|> delay(0.6, queue: Queue.mainQueue())
|
||||
|> map { result -> [Message]? in
|
||||
|> map { result -> [EngineRawMessage]? in
|
||||
return result.0.messages.filter { !$0.isRestricted(platform: "ios", contentSettings: context.currentContentSettings.with { $0 }) }
|
||||
}
|
||||
)
|
||||
|
|
@ -542,8 +541,8 @@ public final class AttachmentFileSearchContainerNode: SearchDisplayControllerCon
|
|||
|> delay(0.6, queue: Queue.mainQueue())
|
||||
|> map { state in
|
||||
let peerId = context.account.peerId
|
||||
var messages: [Message] = []
|
||||
let peers = SimpleDictionary<PeerId, Peer>()
|
||||
var messages: [EngineRawMessage] = []
|
||||
let peers = EngineSimpleDictionary<EnginePeer.Id, EngineRawPeer>()
|
||||
for file in state.files {
|
||||
var indexString = ""
|
||||
for attribute in file.attributes {
|
||||
|
|
@ -564,7 +563,7 @@ public final class AttachmentFileSearchContainerNode: SearchDisplayControllerCon
|
|||
continue
|
||||
}
|
||||
let stableId = UInt32(clamping: file.fileId.id % Int64(Int32.max))
|
||||
messages.append(Message(stableId: stableId, stableVersion: 0, id: MessageId(peerId: peerId, namespace: Namespaces.Message.Local, id: Int32(stableId)), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [], tags: [.music], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: nil, text: "", attributes: [], media: [file], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:]))
|
||||
messages.append(EngineRawMessage(stableId: stableId, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: Namespaces.Message.Local, id: Int32(stableId)), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [], tags: [.music], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: nil, text: "", attributes: [], media: [file], peers: peers, associatedMessages: EngineSimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:]))
|
||||
}
|
||||
return messages
|
||||
}
|
||||
|
|
@ -598,14 +597,14 @@ public final class AttachmentFileSearchContainerNode: SearchDisplayControllerCon
|
|||
return []
|
||||
}
|
||||
let peerId = context.account.peerId
|
||||
var messages: [Message] = []
|
||||
let peers = SimpleDictionary<PeerId, Peer>()
|
||||
var messages: [EngineRawMessage] = []
|
||||
let peers = EngineSimpleDictionary<EnginePeer.Id, EngineRawPeer>()
|
||||
for result in results {
|
||||
switch result {
|
||||
case let .internalReference(internalReference):
|
||||
if let file = internalReference.file {
|
||||
let stableId = UInt32(clamping: file.fileId.id % Int64(Int32.max))
|
||||
messages.append(Message(stableId: stableId, stableVersion: 0, id: MessageId(peerId: peerId, namespace: Namespaces.Message.Local, id: Int32(stableId)), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [], tags: [.music], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: nil, text: "", attributes: [], media: [file], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:]))
|
||||
messages.append(EngineRawMessage(stableId: stableId, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: Namespaces.Message.Local, id: Int32(stableId)), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [], tags: [.music], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: nil, text: "", attributes: [], media: [file], peers: peers, associatedMessages: EngineSimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:]))
|
||||
}
|
||||
default:
|
||||
break
|
||||
|
|
@ -900,20 +899,20 @@ public final class AttachmentFileSearchContainerNode: SearchDisplayControllerCon
|
|||
}
|
||||
}
|
||||
|
||||
private func stringTokens(_ string: String) -> [ValueBoxKey] {
|
||||
private func stringTokens(_ string: String) -> [EngineRawValueBoxKey] {
|
||||
let nsString = string.folding(options: .diacriticInsensitive, locale: .current).lowercased() as NSString
|
||||
|
||||
let flag = UInt(kCFStringTokenizerUnitWord)
|
||||
let tokenizer = CFStringTokenizerCreate(kCFAllocatorDefault, nsString, CFRangeMake(0, nsString.length), flag, CFLocaleCopyCurrent())
|
||||
var tokenType = CFStringTokenizerAdvanceToNextToken(tokenizer)
|
||||
var tokens: [ValueBoxKey] = []
|
||||
var tokens: [EngineRawValueBoxKey] = []
|
||||
|
||||
var addedTokens = Set<ValueBoxKey>()
|
||||
var addedTokens = Set<EngineRawValueBoxKey>()
|
||||
while tokenType != [] {
|
||||
let currentTokenRange = CFStringTokenizerGetCurrentTokenRange(tokenizer)
|
||||
|
||||
if currentTokenRange.location >= 0 && currentTokenRange.length != 0 {
|
||||
let token = ValueBoxKey(length: currentTokenRange.length * 2)
|
||||
let token = EngineRawValueBoxKey(length: currentTokenRange.length * 2)
|
||||
nsString.getCharacters(token.memory.assumingMemoryBound(to: unichar.self), range: NSMakeRange(currentTokenRange.location, currentTokenRange.length))
|
||||
if !addedTokens.contains(token) {
|
||||
tokens.append(token)
|
||||
|
|
@ -926,7 +925,7 @@ private func stringTokens(_ string: String) -> [ValueBoxKey] {
|
|||
return tokens
|
||||
}
|
||||
|
||||
private func matchStringTokens(_ tokens: [ValueBoxKey], with other: [ValueBoxKey]) -> Bool {
|
||||
private func matchStringTokens(_ tokens: [EngineRawValueBoxKey], with other: [EngineRawValueBoxKey]) -> Bool {
|
||||
if other.isEmpty {
|
||||
return false
|
||||
} else if other.count == 1 {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ swift_library(
|
|||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/ComponentFlow:ComponentFlow",
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import AccountContext
|
|||
import TelegramCore
|
||||
import MultilineTextComponent
|
||||
import EmojiStatusComponent
|
||||
import Postbox
|
||||
import TelegramStringFormatting
|
||||
import TelegramNotices
|
||||
import EntityKeyboard
|
||||
|
|
@ -288,15 +287,15 @@ final class AvatarEditorScreenComponent: Component {
|
|||
} else {
|
||||
self.stickerSearchContext = nil
|
||||
|
||||
let emojiItemsSignal = context.account.postbox.itemCollectionsView(orderedItemListCollectionIds: [], namespaces: [Namespaces.ItemCollection.CloudEmojiPacks], aroundIndex: nil, count: 10000000)
|
||||
let emojiItemsSignal = context.engine.itemCollections.allItems(namespace: Namespaces.ItemCollection.CloudEmojiPacks)
|
||||
|> take(1)
|
||||
|
||||
let buildGroups: (ItemCollectionsView, [String: String], StickerSearchContext.State, StickerSearchContext?) -> (groups: [EmojiPagerContentComponent.ItemGroup], canLoadMore: Bool, isSearching: Bool, searchContext: StickerSearchContext?) = { view, allEmoticons, stickerState, searchContext in
|
||||
|
||||
let buildGroups: ([EngineRawItemCollectionItem], [String: String], StickerSearchContext.State, StickerSearchContext?) -> (groups: [EmojiPagerContentComponent.ItemGroup], canLoadMore: Bool, isSearching: Bool, searchContext: StickerSearchContext?) = { items, allEmoticons, stickerState, searchContext in
|
||||
let hasPremium = true
|
||||
|
||||
|
||||
var emoji: [(String, TelegramMediaFile.Accessor?, String)] = []
|
||||
for entry in view.entries {
|
||||
guard let item = entry.item as? StickerPackItem else {
|
||||
for rawItem in items {
|
||||
guard let item = rawItem as? StickerPackItem else {
|
||||
continue
|
||||
}
|
||||
if let alt = item.file.customEmojiAlt {
|
||||
|
|
@ -311,7 +310,7 @@ final class AvatarEditorScreenComponent: Component {
|
|||
}
|
||||
|
||||
var emojiItems: [EmojiPagerContentComponent.Item] = []
|
||||
var existingIds = Set<MediaId>()
|
||||
var existingIds = Set<EngineMedia.Id>()
|
||||
for item in emoji {
|
||||
if let itemFile = item.1 {
|
||||
if existingIds.contains(itemFile.fileId) {
|
||||
|
|
@ -402,8 +401,8 @@ final class AvatarEditorScreenComponent: Component {
|
|||
let allEmoticons = [query.basicEmoji.0: query.basicEmoji.0]
|
||||
let searchContext = context.engine.stickers.stickerSearchContext(query: nil, emoticon: [query.basicEmoji.0], inputLanguageCode: languageCode)
|
||||
resultSignal = combineLatest(emojiItemsSignal, searchContext.state)
|
||||
|> map { view, stickerState in
|
||||
return buildGroups(view, allEmoticons, stickerState, searchContext)
|
||||
|> map { items, stickerState in
|
||||
return buildGroups(items, allEmoticons, stickerState, searchContext)
|
||||
}
|
||||
} else {
|
||||
var keywordsSignal = context.engine.stickers.searchEmojiKeywords(inputLanguageCode: languageCode, query: query, completeMatch: false)
|
||||
|
|
@ -432,15 +431,15 @@ final class AvatarEditorScreenComponent: Component {
|
|||
let emoticon = Array(allEmoticons.keys)
|
||||
guard !emoticon.isEmpty else {
|
||||
return combineLatest(emojiItemsSignal, .single(StickerSearchContext.State(items: [], canLoadMore: false, isLoadingMore: false)))
|
||||
|> map { view, stickerState in
|
||||
return buildGroups(view, allEmoticons, stickerState, nil)
|
||||
|> map { items, stickerState in
|
||||
return buildGroups(items, allEmoticons, stickerState, nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let searchContext = context.engine.stickers.stickerSearchContext(query: query, emoticon: emoticon, inputLanguageCode: languageCode)
|
||||
return combineLatest(emojiItemsSignal, searchContext.state)
|
||||
|> map { view, stickerState in
|
||||
return buildGroups(view, allEmoticons, stickerState, searchContext)
|
||||
|> map { items, stickerState in
|
||||
return buildGroups(items, allEmoticons, stickerState, searchContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -465,7 +464,7 @@ final class AvatarEditorScreenComponent: Component {
|
|||
|> mapToSignal { files, isFinalResult -> Signal<(items: [EmojiPagerContentComponent.ItemGroup], isFinalResult: Bool), NoError> in
|
||||
var items: [EmojiPagerContentComponent.Item] = []
|
||||
|
||||
var existingIds = Set<MediaId>()
|
||||
var existingIds = Set<EngineMedia.Id>()
|
||||
for itemFile in files {
|
||||
if existingIds.contains(itemFile.fileId) {
|
||||
continue
|
||||
|
|
@ -560,18 +559,14 @@ final class AvatarEditorScreenComponent: Component {
|
|||
openSearch: {
|
||||
},
|
||||
addGroupAction: { [weak self] groupId, isPremiumLocked, _ in
|
||||
guard let strongSelf = self, let controller = strongSelf.controller?(), let collectionId = groupId.base as? ItemCollectionId else {
|
||||
guard let strongSelf = self, let controller = strongSelf.controller?(), let collectionId = groupId.base as? EngineItemCollectionId else {
|
||||
return
|
||||
}
|
||||
let context = controller.context
|
||||
let viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedEmojiPacks)
|
||||
let _ = (context.account.postbox.combinedView(keys: [viewKey])
|
||||
let _ = (context.engine.data.subscribe(TelegramEngine.EngineData.Item.OrderedLists.ListItems(collectionId: Namespaces.OrderedItemList.CloudFeaturedEmojiPacks))
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { views in
|
||||
guard let view = views.views[viewKey] as? OrderedItemListView else {
|
||||
return
|
||||
}
|
||||
for featuredStickerPack in view.items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
|> deliverOnMainQueue).start(next: { items in
|
||||
for featuredStickerPack in items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
if featuredStickerPack.info.id == collectionId {
|
||||
let _ = (context.engine.stickers.loadedStickerPack(reference: .id(id: featuredStickerPack.info.id.id, accessHash: featuredStickerPack.info.accessHash), forceActualized: false)
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
|
|
@ -591,7 +586,7 @@ final class AvatarEditorScreenComponent: Component {
|
|||
}
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
})
|
||||
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -698,18 +693,14 @@ final class AvatarEditorScreenComponent: Component {
|
|||
openSearch: {
|
||||
},
|
||||
addGroupAction: { [weak self] groupId, isPremiumLocked, _ in
|
||||
guard let strongSelf = self, let controller = strongSelf.controller?(), let collectionId = groupId.base as? ItemCollectionId else {
|
||||
guard let strongSelf = self, let controller = strongSelf.controller?(), let collectionId = groupId.base as? EngineItemCollectionId else {
|
||||
return
|
||||
}
|
||||
let context = controller.context
|
||||
let viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedStickerPacks)
|
||||
let _ = (context.account.postbox.combinedView(keys: [viewKey])
|
||||
let _ = (context.engine.data.subscribe(TelegramEngine.EngineData.Item.OrderedLists.ListItems(collectionId: Namespaces.OrderedItemList.CloudFeaturedStickerPacks))
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { views in
|
||||
guard let view = views.views[viewKey] as? OrderedItemListView else {
|
||||
return
|
||||
}
|
||||
for featuredStickerPack in view.items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
|> deliverOnMainQueue).start(next: { items in
|
||||
for featuredStickerPack in items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
if featuredStickerPack.info.id == collectionId {
|
||||
let _ = (context.engine.stickers.loadedStickerPack(reference: .id(id: featuredStickerPack.info.id.id, accessHash: featuredStickerPack.info.accessHash), forceActualized: false)
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
|
|
@ -755,15 +746,11 @@ final class AvatarEditorScreenComponent: Component {
|
|||
])])
|
||||
context.sharedContext.mainWindow?.presentInGlobalOverlay(actionSheet)
|
||||
} else if groupId == AnyHashable("featuredTop") {
|
||||
let viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedStickerPacks)
|
||||
let _ = (context.account.postbox.combinedView(keys: [viewKey])
|
||||
let _ = (context.engine.data.subscribe(TelegramEngine.EngineData.Item.OrderedLists.ListItems(collectionId: Namespaces.OrderedItemList.CloudFeaturedStickerPacks))
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { views in
|
||||
guard let view = views.views[viewKey] as? OrderedItemListView else {
|
||||
return
|
||||
}
|
||||
|> deliverOnMainQueue).start(next: { items in
|
||||
var stickerPackIds: [Int64] = []
|
||||
for featuredStickerPack in view.items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
for featuredStickerPack in items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
stickerPackIds.append(featuredStickerPack.info.id.id)
|
||||
}
|
||||
let _ = ApplicationSpecificNotice.setDismissedTrendingStickerPacks(accountManager: context.sharedContext.accountManager, values: stickerPackIds).start()
|
||||
|
|
@ -1535,7 +1522,7 @@ final class AvatarEditorScreenComponent: Component {
|
|||
}
|
||||
|
||||
let values = MediaEditorValues(
|
||||
peerId: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(0)),
|
||||
peerId: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(0)),
|
||||
originalDimensions: PixelDimensions(size),
|
||||
cropOffset: .zero,
|
||||
cropRect: CGRect(origin: .zero, size: size),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import MergeLists
|
||||
|
|
@ -18,11 +17,11 @@ public struct ChatMessageEntryAttributes: Equatable {
|
|||
public var updatingMedia: ChatUpdatingMessageMedia?
|
||||
public var isPlaying: Bool
|
||||
public var isCentered: Bool
|
||||
public var authorStoryStats: PeerStoryStats?
|
||||
public var authorStoryStats: EnginePeerStoryStats?
|
||||
public var displayContinueThreadFooter: Bool
|
||||
public var pinToTop: Bool
|
||||
|
||||
public init(rank: CachedChannelAdminRank?, isContact: Bool, contentTypeHint: ChatMessageEntryContentType, updatingMedia: ChatUpdatingMessageMedia?, isPlaying: Bool, isCentered: Bool, authorStoryStats: PeerStoryStats?, displayContinueThreadFooter: Bool, pinToTop: Bool) {
|
||||
public init(rank: CachedChannelAdminRank?, isContact: Bool, contentTypeHint: ChatMessageEntryContentType, updatingMedia: ChatUpdatingMessageMedia?, isPlaying: Bool, isCentered: Bool, authorStoryStats: EnginePeerStoryStats?, displayContinueThreadFooter: Bool, pinToTop: Bool) {
|
||||
self.rank = rank
|
||||
self.isContact = isContact
|
||||
self.contentTypeHint = contentTypeHint
|
||||
|
|
@ -54,10 +53,10 @@ public enum ChatInfoData: Equatable {
|
|||
}
|
||||
|
||||
public enum ChatHistoryEntry: Identifiable, Comparable {
|
||||
case MessageEntry(Message, ChatPresentationData, Bool, MessageHistoryEntryLocation?, ChatHistoryMessageSelection, ChatMessageEntryAttributes)
|
||||
case MessageGroupEntry(Int64, [(Message, Bool, ChatHistoryMessageSelection, ChatMessageEntryAttributes, MessageHistoryEntryLocation?)], ChatPresentationData)
|
||||
case UnreadEntry(MessageIndex, ChatPresentationData)
|
||||
case ReplyCountEntry(MessageIndex, Bool, Int, ChatPresentationData)
|
||||
case MessageEntry(EngineRawMessage, ChatPresentationData, Bool, EngineMessageHistoryEntryLocation?, ChatHistoryMessageSelection, ChatMessageEntryAttributes)
|
||||
case MessageGroupEntry(Int64, [(EngineRawMessage, Bool, ChatHistoryMessageSelection, ChatMessageEntryAttributes, EngineMessageHistoryEntryLocation?)], ChatPresentationData)
|
||||
case UnreadEntry(EngineMessage.Index, ChatPresentationData)
|
||||
case ReplyCountEntry(EngineMessage.Index, Bool, Int, ChatPresentationData)
|
||||
case ChatInfoEntry(ChatInfoData, ChatPresentationData)
|
||||
|
||||
public var stableId: UInt64 {
|
||||
|
|
@ -89,7 +88,7 @@ public enum ChatHistoryEntry: Identifiable, Comparable {
|
|||
}
|
||||
}
|
||||
|
||||
public var index: MessageIndex {
|
||||
public var index: EngineMessage.Index {
|
||||
switch self {
|
||||
case let .MessageEntry(message, _, _, _, _, _):
|
||||
return message.index
|
||||
|
|
@ -102,14 +101,14 @@ public enum ChatHistoryEntry: Identifiable, Comparable {
|
|||
case let .ChatInfoEntry(infoData, _):
|
||||
switch infoData {
|
||||
case .newThreadInfo:
|
||||
return MessageIndex.absoluteUpperBound()
|
||||
return EngineMessage.Index.absoluteUpperBound()
|
||||
default:
|
||||
return MessageIndex.absoluteLowerBound()
|
||||
return EngineMessage.Index.absoluteLowerBound()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public var firstIndex: MessageIndex {
|
||||
public var firstIndex: EngineMessage.Index {
|
||||
switch self {
|
||||
case let .MessageEntry(message, _, _, _, _, _):
|
||||
return message.index
|
||||
|
|
@ -122,9 +121,9 @@ public enum ChatHistoryEntry: Identifiable, Comparable {
|
|||
case let .ChatInfoEntry(infoData, _):
|
||||
switch infoData {
|
||||
case .newThreadInfo:
|
||||
return MessageIndex.absoluteUpperBound()
|
||||
return EngineMessage.Index.absoluteUpperBound()
|
||||
default:
|
||||
return MessageIndex.absoluteLowerBound()
|
||||
return EngineMessage.Index.absoluteLowerBound()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import ComponentFlow
|
|||
import Display
|
||||
import AsyncDisplayKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import AccountContext
|
||||
import ChatListUI
|
||||
import MergeLists
|
||||
|
|
@ -69,7 +68,7 @@ public final class ChatInlineSearchResultsListComponent: Component {
|
|||
|
||||
public enum Contents: Equatable {
|
||||
case empty
|
||||
case tag(MemoryBuffer)
|
||||
case tag(EngineMemoryBuffer)
|
||||
case search(query: String, includeSavedPeers: Bool)
|
||||
case monoforumChats(query: String)
|
||||
}
|
||||
|
|
@ -94,9 +93,9 @@ public final class ChatInlineSearchResultsListComponent: Component {
|
|||
public let initialScrollingState: ScrollingState?
|
||||
public let messageSelected: (EngineMessage) -> Void
|
||||
public let peerSelected: (EnginePeer) -> Void
|
||||
public let loadTagMessages: (MemoryBuffer, MessageIndex?) -> Signal<MessageHistoryView, NoError>?
|
||||
public let loadTagMessages: (EngineMemoryBuffer, EngineMessage.Index?) -> Signal<EngineRawMessageHistoryView, NoError>?
|
||||
public let getSearchResult: () -> Signal<SearchMessagesResult?, NoError>?
|
||||
public let getSavedPeers: (String) -> Signal<[(EnginePeer, MessageIndex?)], NoError>?
|
||||
public let getSavedPeers: (String) -> Signal<[(EnginePeer, EngineMessage.Index?)], NoError>?
|
||||
public let getChats: (String) -> Signal<EngineChatList?, NoError>?
|
||||
public let loadMoreSearchResults: () -> Void
|
||||
|
||||
|
|
@ -111,9 +110,9 @@ public final class ChatInlineSearchResultsListComponent: Component {
|
|||
initialScrollingState: ScrollingState?,
|
||||
messageSelected: @escaping (EngineMessage) -> Void,
|
||||
peerSelected: @escaping (EnginePeer) -> Void,
|
||||
loadTagMessages: @escaping (MemoryBuffer, MessageIndex?) -> Signal<MessageHistoryView, NoError>?,
|
||||
loadTagMessages: @escaping (EngineMemoryBuffer, EngineMessage.Index?) -> Signal<EngineRawMessageHistoryView, NoError>?,
|
||||
getSearchResult: @escaping () -> Signal<SearchMessagesResult?, NoError>?,
|
||||
getSavedPeers: @escaping (String) -> Signal<[(EnginePeer, MessageIndex?)], NoError>?,
|
||||
getSavedPeers: @escaping (String) -> Signal<[(EnginePeer, EngineMessage.Index?)], NoError>?,
|
||||
getChats: @escaping (String) -> Signal<EngineChatList?, NoError>?,
|
||||
loadMoreSearchResults: @escaping () -> Void
|
||||
) {
|
||||
|
|
@ -243,7 +242,7 @@ public final class ChatInlineSearchResultsListComponent: Component {
|
|||
private struct ContentsState: Equatable {
|
||||
enum ContentId: Equatable {
|
||||
case empty
|
||||
case tag(MemoryBuffer)
|
||||
case tag(EngineMemoryBuffer)
|
||||
case search(String)
|
||||
}
|
||||
|
||||
|
|
@ -274,8 +273,8 @@ public final class ChatInlineSearchResultsListComponent: Component {
|
|||
private let emptyResultsText = ComponentView<Empty>()
|
||||
private let emptyResultsAnimation = ComponentView<Empty>()
|
||||
|
||||
private var tagContents: (index: MessageIndex?, disposable: Disposable?)?
|
||||
private var searchContents: (index: MessageIndex?, disposable: Disposable?)?
|
||||
private var tagContents: (index: EngineMessage.Index?, disposable: Disposable?)?
|
||||
private var searchContents: (index: EngineMessage.Index?, disposable: Disposable?)?
|
||||
|
||||
private var nextContentsId: Int = 0
|
||||
private var contentsState: ContentsState?
|
||||
|
|
@ -453,7 +452,7 @@ public final class ChatInlineSearchResultsListComponent: Component {
|
|||
guard let visibleRange = displayedRange.visibleRange else {
|
||||
return
|
||||
}
|
||||
var loadAroundIndex: MessageIndex?
|
||||
var loadAroundIndex: EngineMessage.Index?
|
||||
if visibleRange.firstIndex <= 5 {
|
||||
if contentsState.hasLater {
|
||||
loadAroundIndex = contentsState.messages.first?.index
|
||||
|
|
@ -615,7 +614,7 @@ public final class ChatInlineSearchResultsListComponent: Component {
|
|||
let disposable = MetaDisposable()
|
||||
self.searchContents = (nil, disposable)
|
||||
|
||||
let savedPeers: Signal<[(EnginePeer, MessageIndex?)], NoError>
|
||||
let savedPeers: Signal<[(EnginePeer, EngineMessage.Index?)], NoError>
|
||||
if includeSavedPeers, !query.isEmpty, let savedPeersSignal = component.getSavedPeers(query) {
|
||||
savedPeers = savedPeersSignal
|
||||
} else {
|
||||
|
|
@ -624,7 +623,7 @@ public final class ChatInlineSearchResultsListComponent: Component {
|
|||
|
||||
if let historySignal = component.getSearchResult() {
|
||||
disposable.set((savedPeers
|
||||
|> mapToSignal { savedPeers -> Signal<([(EnginePeer, MessageIndex?)], SearchMessagesResult?), NoError> in
|
||||
|> mapToSignal { savedPeers -> Signal<([(EnginePeer, EngineMessage.Index?)], SearchMessagesResult?), NoError> in
|
||||
if savedPeers.isEmpty {
|
||||
return historySignal
|
||||
|> map { result in
|
||||
|
|
@ -769,7 +768,7 @@ public final class ChatInlineSearchResultsListComponent: Component {
|
|||
|
||||
/*if let historySignal = component.getSearchResult() {
|
||||
disposable.set((savedPeers
|
||||
|> mapToSignal { savedPeers -> Signal<([(EnginePeer, MessageIndex?)], SearchMessagesResult?), NoError> in
|
||||
|> mapToSignal { savedPeers -> Signal<([(EnginePeer, EngineMessage.Index?)], SearchMessagesResult?), NoError> in
|
||||
if savedPeers.isEmpty {
|
||||
return historySignal
|
||||
|> map { result in
|
||||
|
|
@ -1030,14 +1029,14 @@ public final class ChatInlineSearchResultsListComponent: Component {
|
|||
if let forwardInfo = message.forwardInfo {
|
||||
effectiveAuthor = forwardInfo.author.flatMap(EnginePeer.init)
|
||||
if effectiveAuthor == nil, let authorSignature = forwardInfo.authorSignature {
|
||||
effectiveAuthor = EnginePeer(TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(Int64(authorSignature.persistentHashValue % 32))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
effectiveAuthor = EnginePeer(TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.Empty, id: EnginePeer.Id.Id._internalFromInt64Value(Int64(authorSignature.persistentHashValue % 32))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
}
|
||||
}
|
||||
if let sourceAuthorInfo = message._asMessage().sourceAuthorInfo {
|
||||
if let originalAuthor = sourceAuthorInfo.originalAuthor, let peer = message.peers[originalAuthor] {
|
||||
effectiveAuthor = EnginePeer(peer)
|
||||
} else if let authorSignature = sourceAuthorInfo.originalAuthorName {
|
||||
effectiveAuthor = EnginePeer(TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(Int64(authorSignature.persistentHashValue % 32))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
effectiveAuthor = EnginePeer(TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.Empty, id: EnginePeer.Id.Id._internalFromInt64Value(Int64(authorSignature.persistentHashValue % 32))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
}
|
||||
}
|
||||
if effectiveAuthor == nil {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ swift_library(
|
|||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
"//submodules/Postbox",
|
||||
"//submodules/Display",
|
||||
"//submodules/AsyncDisplayKit",
|
||||
"//submodules/SSignalKit/SwiftSignalKit",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import Foundation
|
||||
import UIKit
|
||||
import Postbox
|
||||
import Display
|
||||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
|
|
@ -61,7 +60,7 @@ public struct ChatMessageAttachedContentNodeMediaFlags: OptionSet {
|
|||
|
||||
public final class ChatMessageAttachedContentNode: ASDisplayNode {
|
||||
private enum InlineMedia: Equatable {
|
||||
case media(Media)
|
||||
case media(EngineRawMedia)
|
||||
case peerAvatar(EnginePeer)
|
||||
|
||||
static func ==(lhs: InlineMedia, rhs: InlineMedia) -> Bool {
|
||||
|
|
@ -108,8 +107,8 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode {
|
|||
private var linkHighlightingNode: LinkHighlightingNode?
|
||||
|
||||
private var context: AccountContext?
|
||||
private var message: Message?
|
||||
private var media: Media?
|
||||
private var message: EngineRawMessage?
|
||||
private var media: EngineRawMedia?
|
||||
private var theme: ChatPresentationThemeData?
|
||||
private var mainColor: UIColor?
|
||||
|
||||
|
|
@ -168,7 +167,7 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode {
|
|||
self.activateBadgeAction?()
|
||||
}
|
||||
|
||||
public typealias AsyncLayout = (_ presentationData: ChatPresentationData, _ automaticDownloadSettings: MediaAutoDownloadSettings, _ associatedData: ChatMessageItemAssociatedData, _ attributes: ChatMessageEntryAttributes, _ context: AccountContext, _ controllerInteraction: ChatControllerInteraction, _ message: Message, _ messageRead: Bool, _ chatLocation: ChatLocation, _ title: String?, _ titleBadge: String?, _ subtitle: NSAttributedString?, _ text: String?, _ entities: [MessageTextEntity]?, _ media: ([Media], ChatMessageAttachedContentNodeMediaFlags)?, _ mediaBadge: String?, _ actionIcon: ChatMessageAttachedContentActionIcon?, _ actionTitle: String?, _ displayLine: Bool, _ layoutConstants: ChatMessageItemLayoutConstants, _ preparePosition: ChatMessageBubblePreparePosition, _ constrainedSize: CGSize, _ animationCache: AnimationCache, _ animationRenderer: MultiAnimationRenderer) -> (CGFloat, (CGSize, ChatMessageBubbleContentPosition) -> (CGFloat, (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation, Bool, ListViewItemApply?) -> Void)))
|
||||
public typealias AsyncLayout = (_ presentationData: ChatPresentationData, _ automaticDownloadSettings: MediaAutoDownloadSettings, _ associatedData: ChatMessageItemAssociatedData, _ attributes: ChatMessageEntryAttributes, _ context: AccountContext, _ controllerInteraction: ChatControllerInteraction, _ message: EngineRawMessage, _ messageRead: Bool, _ chatLocation: ChatLocation, _ title: String?, _ titleBadge: String?, _ subtitle: NSAttributedString?, _ text: String?, _ entities: [MessageTextEntity]?, _ media: ([EngineRawMedia], ChatMessageAttachedContentNodeMediaFlags)?, _ mediaBadge: String?, _ actionIcon: ChatMessageAttachedContentActionIcon?, _ actionTitle: String?, _ displayLine: Bool, _ layoutConstants: ChatMessageItemLayoutConstants, _ preparePosition: ChatMessageBubblePreparePosition, _ constrainedSize: CGSize, _ animationCache: AnimationCache, _ animationRenderer: MultiAnimationRenderer) -> (CGFloat, (CGSize, ChatMessageBubbleContentPosition) -> (CGFloat, (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation, Bool, ListViewItemApply?) -> Void)))
|
||||
|
||||
public func makeProgress() -> Promise<Bool> {
|
||||
let progress = Promise<Bool>()
|
||||
|
|
@ -236,7 +235,7 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode {
|
|||
if let peer = forwardInfo.author {
|
||||
author = peer
|
||||
} else if let authorSignature = forwardInfo.authorSignature {
|
||||
author = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(Int64(authorSignature.persistentHashValue % 32))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
author = TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.Empty, id: EnginePeer.Id.Id._internalFromInt64Value(Int64(authorSignature.persistentHashValue % 32))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -314,7 +313,7 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode {
|
|||
insets.right += 6.0
|
||||
}
|
||||
|
||||
var contentMediaValue: Media?
|
||||
var contentMediaValue: EngineRawMedia?
|
||||
var contentFileValue: TelegramMediaFile?
|
||||
var contentAnimatedFilesValue: [TelegramMediaFile] = []
|
||||
|
||||
|
|
@ -1563,7 +1562,7 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode {
|
|||
pattern = MessageInlineBlockBackgroundView.Pattern(
|
||||
context: context,
|
||||
fileId: backgroundEmojiId,
|
||||
file: message.associatedMedia[MediaId(
|
||||
file: message.associatedMedia[EngineMedia.Id(
|
||||
namespace: Namespaces.Media.CloudFile,
|
||||
id: backgroundEmojiId
|
||||
)] as? TelegramMediaFile
|
||||
|
|
@ -1605,7 +1604,7 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode {
|
|||
}
|
||||
}
|
||||
|
||||
public func updateHiddenMedia(_ media: [Media]?) -> Bool {
|
||||
public func updateHiddenMedia(_ media: [EngineRawMedia]?) -> Bool {
|
||||
if let currentMedia = self.media {
|
||||
if let media = media {
|
||||
var found = false
|
||||
|
|
@ -1628,7 +1627,7 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode {
|
|||
return false
|
||||
}
|
||||
|
||||
public func transitionNode(media: Media) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
public func transitionNode(media: EngineRawMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
if let contentImageNode = self.contentMedia, let image = self.media as? TelegramMediaImage, image.isEqual(to: media) {
|
||||
return (contentImageNode, contentImageNode.bounds, { [weak contentImageNode] in
|
||||
return (contentImageNode?.view.snapshotContentTree(unhide: true), nil)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import Display
|
||||
import TelegramCore
|
||||
|
|
@ -47,8 +46,8 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode {
|
|||
public let context: AccountContext
|
||||
public let presentationData: ChatPresentationData
|
||||
public let customTintColor: UIColor?
|
||||
public let message: Message
|
||||
public let topMessage: Message
|
||||
public let message: EngineRawMessage
|
||||
public let topMessage: EngineRawMessage
|
||||
public let associatedData: ChatMessageItemAssociatedData
|
||||
public let chatLocation: ChatLocation
|
||||
public let attributes: ChatMessageEntryAttributes
|
||||
|
|
@ -71,8 +70,8 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode {
|
|||
context: AccountContext,
|
||||
presentationData: ChatPresentationData,
|
||||
customTintColor: UIColor?,
|
||||
message: Message,
|
||||
topMessage: Message,
|
||||
message: EngineRawMessage,
|
||||
topMessage: EngineRawMessage,
|
||||
associatedData: ChatMessageItemAssociatedData,
|
||||
chatLocation: ChatLocation,
|
||||
attributes: ChatMessageEntryAttributes,
|
||||
|
|
@ -181,7 +180,7 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode {
|
|||
|
||||
private let fetchControls = Atomic<FetchControls?>(value: nil)
|
||||
private var resourceStatus: FileMediaResourceStatus?
|
||||
private var actualFetchStatus: MediaResourceStatus?
|
||||
private var actualFetchStatus: EngineMediaResourceStatus?
|
||||
private let fetchDisposable = MetaDisposable()
|
||||
|
||||
public var toggleSelection: (Bool) -> Void = { _ in }
|
||||
|
|
@ -192,7 +191,7 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode {
|
|||
public var updateTranscriptionExpanded: ((AudioTranscriptionButtonComponent.TranscriptionState) -> Void)?
|
||||
|
||||
private var context: AccountContext?
|
||||
private var message: Message?
|
||||
private var message: EngineRawMessage?
|
||||
private var arguments: Arguments?
|
||||
private var presentationData: ChatPresentationData?
|
||||
private var file: TelegramMediaFile?
|
||||
|
|
@ -445,7 +444,7 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode {
|
|||
return .single(nil)
|
||||
}
|
||||
return convertOpusToAAC(sourcePath: result, allocateTempFile: {
|
||||
return TempBox.shared.tempFile(fileName: "audio.m4a").path
|
||||
return EngineTempBox.shared.tempFile(fileName: "audio.m4a").path
|
||||
})
|
||||
}
|
||||
|> mapToSignal { result -> Signal<LocallyTranscribedAudio?, NoError> in
|
||||
|
|
@ -581,7 +580,7 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode {
|
|||
let durationFont = Font.regular(floor(arguments.presentationData.fontSize.baseDisplaySize * 11.0 / 17.0))
|
||||
|
||||
var updateImageSignal: Signal<(TransformImageArguments) -> DrawingContext?, NoError>?
|
||||
var updatedStatusSignal: Signal<(FileMediaResourceStatus, MediaResourceStatus?), NoError>?
|
||||
var updatedStatusSignal: Signal<(FileMediaResourceStatus, EngineMediaResourceStatus?), NoError>?
|
||||
var updatedAudioLevelEventsSignal: Signal<Float, NoError>?
|
||||
var updatedPlaybackStatusSignal: Signal<MediaPlayerStatus, NoError>?
|
||||
var updatedFetchControls: FetchControls?
|
||||
|
|
@ -622,13 +621,13 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode {
|
|||
if statusUpdated {
|
||||
if arguments.message.flags.isSending {
|
||||
updatedStatusSignal = combineLatest(messageFileMediaResourceStatus(context: arguments.context, file: arguments.file, message: EngineMessage(arguments.message), isRecentActions: arguments.isRecentActions), messageMediaFileStatus(context: arguments.context, messageId: arguments.message.id, file: arguments.file))
|
||||
|> map { resourceStatus, actualFetchStatus -> (FileMediaResourceStatus, MediaResourceStatus?) in
|
||||
|> map { resourceStatus, actualFetchStatus -> (FileMediaResourceStatus, EngineMediaResourceStatus?) in
|
||||
return (resourceStatus, actualFetchStatus)
|
||||
}
|
||||
updatedAudioLevelEventsSignal = messageFileMediaPlaybackAudioLevelEvents(context: arguments.context, file: arguments.file, message: EngineMessage(arguments.message), isRecentActions: arguments.isRecentActions, isGlobalSearch: false, isDownloadList: false, isSavedMusic: false)
|
||||
} else {
|
||||
updatedStatusSignal = messageFileMediaResourceStatus(context: arguments.context, file: arguments.file, message: EngineMessage(arguments.message), isRecentActions: arguments.isRecentActions)
|
||||
|> map { resourceStatus -> (FileMediaResourceStatus, MediaResourceStatus?) in
|
||||
|> map { resourceStatus -> (FileMediaResourceStatus, EngineMediaResourceStatus?) in
|
||||
return (resourceStatus, nil)
|
||||
}
|
||||
updatedAudioLevelEventsSignal = messageFileMediaPlaybackAudioLevelEvents(context: arguments.context, file: arguments.file, message: EngineMessage(arguments.message), isRecentActions: arguments.isRecentActions, isGlobalSearch: false, isDownloadList: false, isSavedMusic: false)
|
||||
|
|
@ -1425,7 +1424,7 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode {
|
|||
if var updatedStatusSignal = updatedStatusSignal {
|
||||
if strongSelf.file?.isInstantVideo == true {
|
||||
updatedStatusSignal = updatedStatusSignal
|
||||
|> mapToThrottled { next -> Signal<(FileMediaResourceStatus, MediaResourceStatus?), NoError> in
|
||||
|> mapToThrottled { next -> Signal<(FileMediaResourceStatus, EngineMediaResourceStatus?), NoError> in
|
||||
return .single(next) |> then(.complete() |> delay(0.1, queue: Queue.concurrentDefaultQueue()))
|
||||
}
|
||||
}
|
||||
|
|
@ -1650,7 +1649,7 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode {
|
|||
|
||||
var playbackState: (position: Double, duration: Double, generationTimestamp: Double) = (0.0, 0.0, 0.0)
|
||||
if !isAudio {
|
||||
var fetchStatus: MediaResourceStatus?
|
||||
var fetchStatus: EngineMediaResourceStatus?
|
||||
if let actualFetchStatus = self.actualFetchStatus, message.forwardInfo != nil {
|
||||
fetchStatus = actualFetchStatus
|
||||
} else if case let .fetchStatus(status) = resourceStatus.mediaStatus {
|
||||
|
|
@ -1813,7 +1812,7 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode {
|
|||
}
|
||||
}
|
||||
|
||||
image = playerAlbumArt(postbox: context.account.postbox, engine: context.engine, fileReference: .message(message: MessageReference(message), media: file), albumArt: .init(thumbnailResource: ExternalMusicAlbumArtResource(file: .message(message: MessageReference(message), media: file), title: title ?? "", performer: performer ?? "", isThumbnail: true), fullSizeResource: ExternalMusicAlbumArtResource(file: .message(message: MessageReference(message), media: file), title: title ?? "", performer: performer ?? "", isThumbnail: false)), thumbnail: true, overlayColor: UIColor(white: 0.0, alpha: 0.3), drawPlaceholderWhenEmpty: false, attemptSynchronously: !animated)
|
||||
image = playerAlbumArt(engine: context.engine, fileReference: .message(message: MessageReference(message), media: file), albumArt: .init(thumbnailResource: ExternalMusicAlbumArtResource(file: .message(message: MessageReference(message), media: file), title: title ?? "", performer: performer ?? "", isThumbnail: true), fullSizeResource: ExternalMusicAlbumArtResource(file: .message(message: MessageReference(message), media: file), title: title ?? "", performer: performer ?? "", isThumbnail: false)), thumbnail: true, overlayColor: UIColor(white: 0.0, alpha: 0.3), drawPlaceholderWhenEmpty: false, attemptSynchronously: !animated)
|
||||
}
|
||||
}
|
||||
let statusNode = SemanticStatusNode(backgroundNodeColor: backgroundNodeColor, foregroundNodeColor: foregroundNodeColor, image: image, overlayForegroundNodeColor: presentationData.theme.theme.chat.message.mediaOverlayControlColors.foregroundColor)
|
||||
|
|
@ -2079,7 +2078,7 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode {
|
|||
}
|
||||
}
|
||||
|
||||
public func transitionNode(media: Media) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
public func transitionNode(media: EngineRawMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
|
||||
if let iconNode = self.iconNode, let file = self.file, file.isEqual(to: media) {
|
||||
return (iconNode, iconNode.bounds, { [weak iconNode] in
|
||||
return (iconNode?.view.snapshotContentTree(unhide: true), nil)
|
||||
|
|
@ -2089,7 +2088,7 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode {
|
|||
}
|
||||
}
|
||||
|
||||
public func updateHiddenMedia(_ media: [Media]?) -> Bool {
|
||||
public func updateHiddenMedia(_ media: [EngineRawMedia]?) -> Bool {
|
||||
var isHidden = false
|
||||
if let file = self.file, let media = media {
|
||||
for m in media {
|
||||
|
|
|
|||
|
|
@ -1082,13 +1082,13 @@ public final class ChatMessageAvatarHeaderNodeImpl: ListViewItemHeaderNode, Chat
|
|||
}
|
||||
|
||||
if peer.isPremium && context.sharedContext.energyUsageSettings.autoplayVideo {
|
||||
self.cachedDataDisposable.set((context.account.postbox.peerView(id: peer.id)
|
||||
|> deliverOnMainQueue).startStrict(next: { [weak self] peerView in
|
||||
self.cachedDataDisposable.set((context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.CachedData(id: peer.id))
|
||||
|> deliverOnMainQueue).startStrict(next: { [weak self] cachedData in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
let cachedPeerData = peerView.cachedData as? CachedUserData
|
||||
|
||||
let cachedPeerData = cachedData as? CachedUserData
|
||||
var personalPhoto: TelegramMediaImage?
|
||||
var profilePhoto: TelegramMediaImage?
|
||||
var isKnown = false
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ swift_library(
|
|||
deps = [
|
||||
"//submodules/AsyncDisplayKit",
|
||||
"//submodules/Display",
|
||||
"//submodules/Postbox",
|
||||
"//submodules/TelegramCore",
|
||||
"//submodules/SSignalKit/SwiftSignalKit",
|
||||
"//submodules/TelegramPresentationData",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
|
|
@ -24,8 +23,8 @@ public final class ChatMessageNotificationItem: NotificationItem {
|
|||
public let strings: PresentationStrings
|
||||
public let dateTimeFormat: PresentationDateTimeFormat
|
||||
public let nameDisplayOrder: PresentationPersonNameOrder
|
||||
public let messages: [Message]
|
||||
public let threadData: MessageHistoryThreadData?
|
||||
public let messages: [EngineRawMessage]
|
||||
public let threadData: EngineMessageHistoryThreadData?
|
||||
public let tapAction: () -> Bool
|
||||
public let expandAction: (@escaping () -> (ASDisplayNode?, () -> Void)) -> Void
|
||||
|
||||
|
|
@ -33,7 +32,7 @@ public final class ChatMessageNotificationItem: NotificationItem {
|
|||
return messages.first?.id.peerId
|
||||
}
|
||||
|
||||
public init(context: AccountContext, strings: PresentationStrings, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, messages: [Message], threadData: MessageHistoryThreadData?, tapAction: @escaping () -> Bool, expandAction: @escaping (() -> (ASDisplayNode?, () -> Void)) -> Void) {
|
||||
public init(context: AccountContext, strings: PresentationStrings, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, messages: [EngineRawMessage], threadData: EngineMessageHistoryThreadData?, tapAction: @escaping () -> Bool, expandAction: @escaping (() -> (ASDisplayNode?, () -> Void)) -> Void) {
|
||||
self.context = context
|
||||
self.strings = strings
|
||||
self.dateTimeFormat = dateTimeFormat
|
||||
|
|
@ -187,7 +186,7 @@ final class ChatMessageNotificationItemNode: NotificationItemNode {
|
|||
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)
|
||||
}
|
||||
|
||||
var updatedMedia: Media?
|
||||
var updatedMedia: EngineRawMedia?
|
||||
var imageDimensions: CGSize?
|
||||
var isRound = false
|
||||
var messageText: String
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@ public final class ChatRecentActionsController: TelegramBaseController {
|
|||
func openFilterSetup() {
|
||||
if self.adminsPromise == nil {
|
||||
self.adminsPromise = Promise()
|
||||
let (disposable, _) = self.context.peerChannelMemberCategoriesContextsManager.admins(engine: self.context.engine, postbox: self.context.account.postbox, network: self.context.account.network, accountPeerId: self.context.account.peerId, peerId: self.peer.id) { membersState in
|
||||
let (disposable, _) = self.context.peerChannelMemberCategoriesContextsManager.admins(engine: self.context.engine, accountPeerId: self.context.account.peerId, peerId: self.peer.id) { membersState in
|
||||
if case .loading = membersState.loadingState, membersState.list.isEmpty {
|
||||
self.adminsPromise?.set(.single(nil))
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import Display
|
||||
import TelegramPresentationData
|
||||
|
|
@ -43,7 +42,7 @@ private final class ChatRecentActionsListOpaqueState {
|
|||
|
||||
final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
||||
private let context: AccountContext
|
||||
private let peer: Peer
|
||||
private let peer: EngineRawPeer
|
||||
private var presentationData: PresentationData
|
||||
|
||||
private let pushController: (ViewController) -> Void
|
||||
|
|
@ -95,20 +94,20 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
|||
private let eventLogContext: ChannelAdminEventLogContext
|
||||
|
||||
private var enqueuedTransitions: [(ChatRecentActionsHistoryTransition, Bool)] = []
|
||||
private var searchResultsState: (String, [MessageIndex])?
|
||||
private var searchResultsState: (String, [EngineMessage.Index])?
|
||||
|
||||
private var historyDisposable: Disposable?
|
||||
private let resolvePeerByNameDisposable = MetaDisposable()
|
||||
private var adminsDisposable: Disposable?
|
||||
private var adminsState: ChannelMemberListState?
|
||||
private let banDisposables = DisposableDict<PeerId>()
|
||||
private let reportFalsePositiveDisposables = DisposableDict<MessageId>()
|
||||
private let banDisposables = DisposableDict<EnginePeer.Id>()
|
||||
private let reportFalsePositiveDisposables = DisposableDict<EngineMessage.Id>()
|
||||
|
||||
private weak var antiSpamTooltipController: UndoOverlayController?
|
||||
|
||||
private weak var controller: ChatRecentActionsController?
|
||||
|
||||
init(context: AccountContext, controller: ChatRecentActionsController, peer: Peer, presentationData: PresentationData, pushController: @escaping (ViewController) -> Void, presentController: @escaping (ViewController, PresentationContextType, Any?) -> Void, getNavigationController: @escaping () -> NavigationController?) {
|
||||
init(context: AccountContext, controller: ChatRecentActionsController, peer: EngineRawPeer, presentationData: PresentationData, pushController: @escaping (ViewController) -> Void, presentController: @escaping (ViewController, PresentationContextType, Any?) -> Void, getNavigationController: @escaping () -> NavigationController?) {
|
||||
self.context = context
|
||||
self.controller = controller
|
||||
self.peer = peer
|
||||
|
|
@ -158,7 +157,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
|||
self.panelButtonNode.addTarget(self, action: #selector(self.settingsButtonPressed), forControlEvents: .touchUpInside)
|
||||
self.panelInfoButtonNode.addTarget(self, action: #selector(self.infoButtonPressed), forControlEvents: .touchUpInside)
|
||||
|
||||
let (adminsDisposable, _) = self.context.peerChannelMemberCategoriesContextsManager.admins(engine: self.context.engine, postbox: self.context.account.postbox, network: self.context.account.network, accountPeerId: context.account.peerId, peerId: self.peer.id, searchQuery: nil, updated: { [weak self] state in
|
||||
let (adminsDisposable, _) = self.context.peerChannelMemberCategoriesContextsManager.admins(engine: self.context.engine, accountPeerId: context.account.peerId, peerId: self.peer.id, searchQuery: nil, updated: { [weak self] state in
|
||||
self?.adminsState = state
|
||||
})
|
||||
self.adminsDisposable = adminsDisposable
|
||||
|
|
@ -270,7 +269,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
|||
if let strongSelf = self {
|
||||
strongSelf.temporaryHiddenGalleryMediaDisposable.set((signal |> deliverOnMainQueue).startStrict(next: { messageId in
|
||||
if let strongSelf = self, let controllerInteraction = strongSelf.controllerInteraction {
|
||||
var messageIdAndMedia: [MessageId: [Media]] = [:]
|
||||
var messageIdAndMedia: [EngineMessage.Id: [EngineRawMedia]] = [:]
|
||||
|
||||
if let messageId = messageId {
|
||||
messageIdAndMedia[messageId] = [media]
|
||||
|
|
@ -345,7 +344,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
|||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
let resolveSignal: Signal<Peer?, NoError>
|
||||
let resolveSignal: Signal<EngineRawPeer?, NoError>
|
||||
if let peerName = peerName {
|
||||
resolveSignal = strongSelf.context.engine.peers.resolvePeerByName(name: peerName, referrer: nil)
|
||||
|> mapToSignal { result -> Signal<EnginePeer?, NoError> in
|
||||
|
|
@ -354,7 +353,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
|||
}
|
||||
return .single(result)
|
||||
}
|
||||
|> mapToSignal { peer -> Signal<Peer?, NoError> in
|
||||
|> mapToSignal { peer -> Signal<EngineRawPeer?, NoError> in
|
||||
return .single(peer?._asPeer())
|
||||
}
|
||||
} else {
|
||||
|
|
@ -730,10 +729,10 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
|||
|
||||
let toggledDeletedMessageIds = previousExpandedDeletedMessages.symmetricDifference(expandedDeletedMessages)
|
||||
|
||||
var searchResultsState: (String, [MessageIndex])?
|
||||
var searchResultsState: (String, [EngineMessage.Index])?
|
||||
if update.3, let query = self?.filter.query {
|
||||
searchResultsState = (query, processedView.compactMap { entry in
|
||||
return entry.entry.event.action.messageId.flatMap { MessageIndex(id: $0, timestamp: entry.entry.event.date) }
|
||||
return entry.entry.event.action.messageId.flatMap { EngineMessage.Index(id: $0, timestamp: entry.entry.event.date) }
|
||||
})
|
||||
} else {
|
||||
searchResultsState = nil
|
||||
|
|
@ -754,7 +753,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
|||
let mediaManager = self.context.sharedContext.mediaManager
|
||||
self.galleryHiddenMesageAndMediaDisposable.set(mediaManager.galleryHiddenMediaManager.hiddenIds().startStrict(next: { [weak self] ids in
|
||||
if let strongSelf = self, let controllerInteraction = strongSelf.controllerInteraction {
|
||||
var messageIdAndMedia: [MessageId: [Media]] = [:]
|
||||
var messageIdAndMedia: [EngineMessage.Id: [EngineRawMedia]] = [:]
|
||||
|
||||
for id in ids {
|
||||
if case let .chat(accountId, messageId, media) = id, accountId == strongSelf.context.account.id {
|
||||
|
|
@ -968,13 +967,13 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
|||
|
||||
func updateItemNodesSearchTextHighlightStates() {
|
||||
var searchString: String?
|
||||
var resultsMessageIndices: [MessageIndex]? = nil
|
||||
var resultsMessageIndices: [EngineMessage.Index]? = nil
|
||||
if let (query, indices) = self.searchResultsState {
|
||||
searchString = query
|
||||
resultsMessageIndices = indices
|
||||
}
|
||||
if searchString != self.controllerInteraction?.searchTextHighightState?.0 || resultsMessageIndices != self.controllerInteraction?.searchTextHighightState?.1 {
|
||||
var searchTextHighightState: (String, [MessageIndex])?
|
||||
var searchTextHighightState: (String, [EngineMessage.Index])?
|
||||
if let searchString = searchString, let resultsMessageIndices = resultsMessageIndices {
|
||||
searchTextHighightState = (searchString, resultsMessageIndices)
|
||||
}
|
||||
|
|
@ -987,7 +986,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
|||
}
|
||||
}
|
||||
|
||||
func updateFilter(events: AdminLogEventsFlags, adminPeerIds: [PeerId]?) {
|
||||
func updateFilter(events: AdminLogEventsFlags, adminPeerIds: [EnginePeer.Id]?) {
|
||||
self.filter = self.filter.withEvents(events).withAdminPeerIds(adminPeerIds)
|
||||
self.eventLogContext.setFilter(self.filter)
|
||||
}
|
||||
|
|
@ -1007,7 +1006,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
|||
return false
|
||||
}), .window(.root), nil)
|
||||
} else {
|
||||
let peerSignal: Signal<Peer?, NoError> = .single(peer._asPeer())
|
||||
let peerSignal: Signal<EngineRawPeer?, NoError> = .single(peer._asPeer())
|
||||
self.navigationActionDisposable.set((peerSignal |> take(1) |> deliverOnMainQueue).startStrict(next: { [weak self] peer in
|
||||
if let strongSelf = self, let peer = peer {
|
||||
if peer is TelegramChannel, let navigationController = strongSelf.getNavigationController() {
|
||||
|
|
@ -1041,7 +1040,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
|||
}))
|
||||
}
|
||||
|
||||
private func openMessageContextMenu(message: Message, selectAll: Bool, node: ASDisplayNode, frame: CGRect, recognizer: TapLongTapOrDoubleTapGestureRecognizer? = nil, gesture: ContextGesture? = nil, location: CGPoint? = nil) {
|
||||
private func openMessageContextMenu(message: EngineRawMessage, selectAll: Bool, node: ASDisplayNode, frame: CGRect, recognizer: TapLongTapOrDoubleTapGestureRecognizer? = nil, gesture: ContextGesture? = nil, location: CGPoint? = nil) {
|
||||
guard let controller = self.controller else {
|
||||
return
|
||||
}
|
||||
|
|
@ -1313,7 +1312,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
|||
if let photoRepresentation = invite.photoRepresentation {
|
||||
photo.append(photoRepresentation)
|
||||
}
|
||||
let channel = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(0)), accessHash: .genericPublic(0), title: invite.title, username: nil, photo: photo, creationDate: 0, version: 0, participationStatus: .left, info: .broadcast(TelegramChannelBroadcastInfo(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil, usernames: [], storiesHidden: nil, nameColor: invite.nameColor, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, emojiStatus: nil, approximateBoostLevel: nil, subscriptionUntilDate: nil, verificationIconFileId: nil, sendPaidMessageStars: nil, linkedMonoforumId: nil)
|
||||
let channel = TelegramChannel(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudChannel, id: EnginePeer.Id.Id._internalFromInt64Value(0)), accessHash: .genericPublic(0), title: invite.title, username: nil, photo: photo, creationDate: 0, version: 0, participationStatus: .left, info: .broadcast(TelegramChannelBroadcastInfo(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil, usernames: [], storiesHidden: nil, nameColor: invite.nameColor, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, emojiStatus: nil, approximateBoostLevel: nil, subscriptionUntilDate: nil, verificationIconFileId: nil, sendPaidMessageStars: nil, linkedMonoforumId: nil)
|
||||
let invoice = TelegramMediaInvoice(title: "", description: "", photo: nil, receiptMessageId: nil, currency: "XTR", totalAmount: subscriptionPricing.amount.value, startParam: "", extendedMedia: nil, subscriptionPeriod: nil, flags: [], version: 0)
|
||||
|
||||
inputData.set(.single(BotCheckoutController.InputData(
|
||||
|
|
@ -1549,14 +1548,14 @@ final class ChatRecentActionsMessageContextExtractedContentSource: ContextExtrac
|
|||
let blurBackground: Bool = true
|
||||
|
||||
private weak var controllerNode: ChatRecentActionsControllerNode?
|
||||
private let message: Message
|
||||
private let message: EngineRawMessage
|
||||
private let selectAll: Bool
|
||||
|
||||
var shouldBeDismissed: Signal<Bool, NoError> {
|
||||
return .single(false)
|
||||
}
|
||||
|
||||
init(controllerNode: ChatRecentActionsControllerNode, message: Message, selectAll: Bool) {
|
||||
init(controllerNode: ChatRecentActionsControllerNode, message: EngineRawMessage, selectAll: Bool) {
|
||||
self.controllerNode = controllerNode
|
||||
self.message = message
|
||||
self.selectAll = selectAll
|
||||
|
|
@ -1618,7 +1617,7 @@ final class ChatMessageContextLocationContentSource: ContextLocationContentSourc
|
|||
}
|
||||
|
||||
extension AdminLogEventAction {
|
||||
var messageId: MessageId? {
|
||||
var messageId: EngineMessage.Id? {
|
||||
switch self {
|
||||
case let .editMessage(_, new):
|
||||
return new.id
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ swift_library(
|
|||
deps = [
|
||||
"//submodules/AsyncDisplayKit",
|
||||
"//submodules/TelegramCore",
|
||||
"//submodules/Postbox",
|
||||
"//submodules/SSignalKit/SwiftSignalKit",
|
||||
"//submodules/Display",
|
||||
"//submodules/TelegramPresentationData",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import Display
|
||||
import TelegramPresentationData
|
||||
|
|
@ -23,7 +22,7 @@ import AppBundle
|
|||
import ComponentFlow
|
||||
import AlertComponent
|
||||
|
||||
func textStringForForwardedMessage(_ message: Message, strings: PresentationStrings) -> (text: String, entities: [MessageTextEntity], isMedia: Bool) {
|
||||
func textStringForForwardedMessage(_ message: EngineRawMessage, strings: PresentationStrings) -> (text: String, entities: [MessageTextEntity], isMedia: Bool) {
|
||||
for media in message.media {
|
||||
switch media {
|
||||
case _ as TelegramMediaImage:
|
||||
|
|
@ -89,8 +88,8 @@ func textStringForForwardedMessage(_ message: Message, strings: PresentationStri
|
|||
|
||||
public final class ForwardAccessoryPanelNode: AccessoryPanelNode {
|
||||
private let messageDisposable = MetaDisposable()
|
||||
public let messageIds: [MessageId]
|
||||
private var messages: [Message] = []
|
||||
public let messageIds: [EngineMessage.Id]
|
||||
private var messages: [EngineRawMessage] = []
|
||||
|
||||
let closeButton: HighlightableButtonNode
|
||||
let lineNode: ASImageNode
|
||||
|
|
@ -110,7 +109,7 @@ public final class ForwardAccessoryPanelNode: AccessoryPanelNode {
|
|||
|
||||
private var validLayout: (size: CGSize, inset: CGFloat, interfaceState: ChatPresentationInterfaceState)?
|
||||
|
||||
public init(context: AccountContext, messageIds: [MessageId], theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize, nameDisplayOrder: PresentationPersonNameOrder, forwardOptionsState: ChatInterfaceForwardOptionsState?, animationCache: AnimationCache?, animationRenderer: MultiAnimationRenderer?) {
|
||||
public init(context: AccountContext, messageIds: [EngineMessage.Id], theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize, nameDisplayOrder: PresentationPersonNameOrder, forwardOptionsState: ChatInterfaceForwardOptionsState?, animationCache: AnimationCache?, animationRenderer: MultiAnimationRenderer?) {
|
||||
self.context = context
|
||||
self.messageIds = messageIds
|
||||
self.theme = theme
|
||||
|
|
@ -165,7 +164,10 @@ public final class ForwardAccessoryPanelNode: AccessoryPanelNode {
|
|||
)
|
||||
}
|
||||
|
||||
self.messageDisposable.set((context.account.postbox.messagesAtIds(messageIds)
|
||||
self.messageDisposable.set((context.engine.data.get(EngineDataMap(messageIds.map(TelegramEngine.EngineData.Item.Messages.Message.init)))
|
||||
|> map { messageMap -> [EngineRawMessage] in
|
||||
return messageIds.compactMap { messageMap[$0]??._asMessage() }
|
||||
}
|
||||
|> deliverOnMainQueue).start(next: { [weak self] messages in
|
||||
if let strongSelf = self {
|
||||
if messages.isEmpty {
|
||||
|
|
@ -295,7 +297,7 @@ public final class ForwardAccessoryPanelNode: AccessoryPanelNode {
|
|||
}
|
||||
|
||||
var authors = ""
|
||||
var uniquePeerIds = Set<PeerId>()
|
||||
var uniquePeerIds = Set<EnginePeer.Id>()
|
||||
var title = ""
|
||||
var text = NSMutableAttributedString(string: "")
|
||||
|
||||
|
|
@ -325,7 +327,7 @@ public final class ForwardAccessoryPanelNode: AccessoryPanelNode {
|
|||
case let .CustomEmoji(_, fileId):
|
||||
let range = NSRange(location: entity.range.lowerBound, length: entity.range.upperBound - entity.range.lowerBound)
|
||||
if range.lowerBound >= 0 && range.upperBound <= additionalText.length {
|
||||
additionalText.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: fileId, file: messages[0].associatedMedia[MediaId(namespace: Namespaces.Media.CloudFile, id: fileId)] as? TelegramMediaFile), range: range)
|
||||
additionalText.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: fileId, file: messages[0].associatedMedia[EngineMedia.Id(namespace: Namespaces.Media.CloudFile, id: fileId)] as? TelegramMediaFile), range: range)
|
||||
}
|
||||
default:
|
||||
break
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ swift_library(
|
|||
deps = [
|
||||
"//submodules/AsyncDisplayKit",
|
||||
"//submodules/Display",
|
||||
"//submodules/Postbox",
|
||||
"//submodules/TelegramCore",
|
||||
"//submodules/SSignalKit/SwiftSignalKit",
|
||||
"//submodules/ComponentFlow",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import AsyncDisplayKit
|
|||
import Display
|
||||
import ComponentFlow
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TextFormat
|
||||
import TelegramPresentationData
|
||||
|
|
@ -218,19 +217,13 @@ private final class QuickShareScreenComponent: Component {
|
|||
if case let .peers(peers) = recentPeers, !peers.isEmpty {
|
||||
return .single(peers.map(EnginePeer.init))
|
||||
} else {
|
||||
return component.context.account.stateManager.postbox.tailChatListView(
|
||||
groupId: .root,
|
||||
count: 20,
|
||||
summaryComponents: ChatListEntrySummaryComponents()
|
||||
)
|
||||
return component.context.engine.messages.chatList(group: .root, count: 20)
|
||||
|> take(1)
|
||||
|> map { view -> [EnginePeer] in
|
||||
|> map { chatList -> [EnginePeer] in
|
||||
var peers: [EnginePeer] = []
|
||||
for entry in view.0.entries.reversed() {
|
||||
if case let .MessageEntry(entryData) = entry {
|
||||
if let user = entryData.renderedPeer.chatMainPeer as? TelegramUser, user.isGenericUser && user.id != component.context.account.peerId && !user.id.isSecretChat {
|
||||
peers.append(EnginePeer(user))
|
||||
}
|
||||
for item in chatList.items.reversed() {
|
||||
if case let .user(user) = item.renderedPeer.chatMainPeer, user.isGenericUser && user.id != component.context.account.peerId && !user.id.isSecretChat {
|
||||
peers.append(.user(user))
|
||||
}
|
||||
}
|
||||
return peers
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ swift_library(
|
|||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit",
|
||||
"//submodules/TelegramCore",
|
||||
"//submodules/Postbox",
|
||||
"//submodules/AccountContext",
|
||||
"//submodules/ReactionSelectionNode",
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import Foundation
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import AccountContext
|
||||
import ReactionSelectionNode
|
||||
|
||||
|
|
@ -10,7 +9,7 @@ public enum AllowedReactions {
|
|||
case all
|
||||
}
|
||||
|
||||
public func peerMessageAllowedReactions(context: AccountContext, message: Message, ignoreDefault: Bool = false) -> Signal<(allowedReactions: AllowedReactions?, areStarsEnabled: Bool), NoError> {
|
||||
public func peerMessageAllowedReactions(context: AccountContext, message: EngineRawMessage, ignoreDefault: Bool = false) -> Signal<(allowedReactions: AllowedReactions?, areStarsEnabled: Bool), NoError> {
|
||||
if message.id.peerId == context.account.peerId {
|
||||
return .single((.all, false))
|
||||
}
|
||||
|
|
@ -106,18 +105,11 @@ public func tagMessageReactions(context: AccountContext, subPeerId: EnginePeer.I
|
|||
|
||||
return combineLatest(
|
||||
context.engine.stickers.availableReactions(),
|
||||
context.account.postbox.itemCollectionsView(orderedItemListCollectionIds: [Namespaces.OrderedItemList.CloudDefaultTagReactions], namespaces: [ItemCollectionId.Namespace.max - 1], aroundIndex: nil, count: 10000000),
|
||||
context.engine.data.subscribe(TelegramEngine.EngineData.Item.OrderedLists.ListItems(collectionId: Namespaces.OrderedItemList.CloudDefaultTagReactions)),
|
||||
topTags
|
||||
)
|
||||
|> take(1)
|
||||
|> map { availableReactions, view, topTags -> [ReactionItem] in
|
||||
var defaultTagReactions: OrderedItemListView?
|
||||
for orderedView in view.orderedItemListsViews {
|
||||
if orderedView.collectionId == Namespaces.OrderedItemList.CloudDefaultTagReactions {
|
||||
defaultTagReactions = orderedView
|
||||
}
|
||||
}
|
||||
|
||||
|> map { availableReactions, defaultTagReactionItems, topTags -> [ReactionItem] in
|
||||
var result: [ReactionItem] = []
|
||||
var existingIds = Set<MessageReaction.Reaction>()
|
||||
|
||||
|
|
@ -176,8 +168,8 @@ public func tagMessageReactions(context: AccountContext, subPeerId: EnginePeer.I
|
|||
}
|
||||
}
|
||||
|
||||
if let defaultTagReactions {
|
||||
for item in defaultTagReactions.items {
|
||||
do {
|
||||
for item in defaultTagReactionItems {
|
||||
guard let topReaction = item.contents.get(RecentReactionItem.self) else {
|
||||
continue
|
||||
}
|
||||
|
|
@ -260,7 +252,7 @@ public func tagMessageReactions(context: AccountContext, subPeerId: EnginePeer.I
|
|||
}
|
||||
}
|
||||
|
||||
public func topMessageReactions(context: AccountContext, message: Message, subPeerId: EnginePeer.Id?, ignoreDefault: Bool = false) -> Signal<[ReactionItem], NoError> {
|
||||
public func topMessageReactions(context: AccountContext, message: EngineRawMessage, subPeerId: EnginePeer.Id?, ignoreDefault: Bool = false) -> Signal<[ReactionItem], NoError> {
|
||||
if message.id.peerId == context.account.peerId {
|
||||
var loadTags = false
|
||||
if let effectiveReactionsAttribute = message.effectiveReactionsAttribute(isTags: message.areReactionsTags(accountPeerId: context.account.peerId)) {
|
||||
|
|
@ -279,13 +271,9 @@ public func topMessageReactions(context: AccountContext, message: Message, subPe
|
|||
}
|
||||
}
|
||||
|
||||
let viewKey: PostboxViewKey = .orderedItemList(id: Namespaces.OrderedItemList.CloudTopReactions)
|
||||
let topReactions = context.account.postbox.combinedView(keys: [viewKey])
|
||||
|> map { views -> [RecentReactionItem] in
|
||||
guard let view = views.views[viewKey] as? OrderedItemListView else {
|
||||
return []
|
||||
}
|
||||
return view.items.compactMap { item -> RecentReactionItem? in
|
||||
let topReactions = context.engine.data.subscribe(TelegramEngine.EngineData.Item.OrderedLists.ListItems(collectionId: Namespaces.OrderedItemList.CloudTopReactions))
|
||||
|> map { items -> [RecentReactionItem] in
|
||||
return items.compactMap { item -> RecentReactionItem? in
|
||||
return item.contents.get(RecentReactionItem.self)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import ButtonComponent
|
|||
import ComponentFlow
|
||||
import EdgeEffect
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import PresentationDataUtils
|
||||
|
|
@ -132,7 +131,7 @@ private final class StickerSearchPackTopPanelItemComponent: Component {
|
|||
|
||||
final class View: UIView {
|
||||
private var itemLayer: InlineStickerItemLayer?
|
||||
private var itemFileId: MediaId?
|
||||
private var itemFileId: EngineMedia.Id?
|
||||
private var titleView: ComponentView<Empty>?
|
||||
private var component: StickerSearchPackTopPanelItemComponent?
|
||||
|
||||
|
|
@ -317,7 +316,7 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode {
|
|||
private var searchIsActive: Bool = false
|
||||
private var selectedPack: StickerPaneSearchPack?
|
||||
private var isPackPanelExpanded: Bool = true
|
||||
private var installedPackIds = Set<ItemCollectionId>()
|
||||
private var installedPackIds = Set<EngineItemCollectionId>()
|
||||
private var stickerSearchContext: StickerSearchContext?
|
||||
private var currentSearchStickerCount: Int = 0
|
||||
private var currentStickerCount: Int = 0
|
||||
|
|
@ -597,15 +596,11 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode {
|
|||
)
|
||||
}
|
||||
|
||||
let installedPackIds = context.account.postbox.combinedView(keys: [.itemCollectionInfos(namespaces: [Namespaces.ItemCollection.CloudStickerPacks])])
|
||||
|> map { view -> Set<ItemCollectionId> in
|
||||
var installedPacks = Set<ItemCollectionId>()
|
||||
if let stickerPacksView = view.views[.itemCollectionInfos(namespaces: [Namespaces.ItemCollection.CloudStickerPacks])] as? ItemCollectionInfosView {
|
||||
if let packsEntries = stickerPacksView.entriesByNamespace[Namespaces.ItemCollection.CloudStickerPacks] {
|
||||
for entry in packsEntries {
|
||||
installedPacks.insert(entry.id)
|
||||
}
|
||||
}
|
||||
let installedPackIds = context.engine.data.subscribe(TelegramEngine.EngineData.Item.ItemCollections.InstalledPackInfos(namespace: Namespaces.ItemCollection.CloudStickerPacks))
|
||||
|> map { entries -> Set<EngineItemCollectionId> in
|
||||
var installedPacks = Set<EngineItemCollectionId>()
|
||||
for entry in entries {
|
||||
installedPacks.insert(entry.id)
|
||||
}
|
||||
return installedPacks
|
||||
}
|
||||
|
|
@ -713,7 +708,7 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode {
|
|||
private func entries(stickers: [FoundStickerItem]) -> [StickerSearchEntry] {
|
||||
var entries: [StickerSearchEntry] = []
|
||||
var index = 0
|
||||
var existingStickerIds = Set<MediaId>()
|
||||
var existingStickerIds = Set<EngineMedia.Id>()
|
||||
for sticker in stickers {
|
||||
if let id = sticker.file.id, !existingStickerIds.contains(id) {
|
||||
entries.append(.sticker(index: index, code: nil, stickerItem: sticker, theme: self.theme))
|
||||
|
|
@ -727,7 +722,7 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode {
|
|||
|
||||
private func packs(from packs: FoundStickerSets) -> [StickerPaneSearchPack] {
|
||||
var result: [StickerPaneSearchPack] = []
|
||||
var existingIds = Set<ItemCollectionId>()
|
||||
var existingIds = Set<EngineItemCollectionId>()
|
||||
for (collectionId, info, _, installed) in packs.infos {
|
||||
guard !existingIds.contains(collectionId), let info = info as? StickerPackCollectionInfo else {
|
||||
continue
|
||||
|
|
@ -748,7 +743,7 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode {
|
|||
|
||||
private func entries(packItems: [StickerPackItem]) -> [StickerSearchEntry] {
|
||||
var entries: [StickerSearchEntry] = []
|
||||
var existingStickerIds = Set<MediaId>()
|
||||
var existingStickerIds = Set<EngineMedia.Id>()
|
||||
var index = 0
|
||||
for item in packItems {
|
||||
let file = item.file._parse()
|
||||
|
|
@ -786,7 +781,7 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode {
|
|||
return !selectedPack.installed && !self.installedPackIds.contains(selectedPack.info.id)
|
||||
}
|
||||
|
||||
func setPackInstalledState(id: ItemCollectionId, installed: Bool, transition: ContainedViewLayoutTransition = .animated(duration: 0.2, curve: .easeInOut)) {
|
||||
func setPackInstalledState(id: EngineItemCollectionId, installed: Bool, transition: ContainedViewLayoutTransition = .animated(duration: 0.2, curve: .easeInOut)) {
|
||||
if installed {
|
||||
self.installedPackIds.insert(id)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ swift_library(
|
|||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/LegacyComponents:LegacyComponents",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import LegacyComponents
|
||||
|
|
@ -29,15 +28,15 @@ private let subtitleFont = Font.regular(13.0)
|
|||
|
||||
public enum ChatTitleContent: Equatable {
|
||||
public struct PeerData: Equatable {
|
||||
public var peerId: PeerId
|
||||
public var peer: Peer?
|
||||
public var peerId: EnginePeer.Id
|
||||
public var peer: EngineRawPeer?
|
||||
public var isContact: Bool
|
||||
public var isSavedMessages: Bool
|
||||
public var notificationSettings: TelegramPeerNotificationSettings?
|
||||
public var peerPresences: [PeerId: PeerPresence]
|
||||
public var cachedData: CachedPeerData?
|
||||
|
||||
public init(peerId: PeerId, peer: Peer?, isContact: Bool, isSavedMessages: Bool, notificationSettings: TelegramPeerNotificationSettings?, peerPresences: [PeerId: PeerPresence], cachedData: CachedPeerData?) {
|
||||
public var peerPresences: [EnginePeer.Id: EngineRawPeerPresence]
|
||||
public var cachedData: EngineCachedPeerData?
|
||||
|
||||
public init(peerId: EnginePeer.Id, peer: EngineRawPeer?, isContact: Bool, isSavedMessages: Bool, notificationSettings: TelegramPeerNotificationSettings?, peerPresences: [EnginePeer.Id: EngineRawPeerPresence], cachedData: EngineCachedPeerData?) {
|
||||
self.peerId = peerId
|
||||
self.peer = peer
|
||||
self.isContact = isContact
|
||||
|
|
@ -47,7 +46,7 @@ public enum ChatTitleContent: Equatable {
|
|||
self.cachedData = cachedData
|
||||
}
|
||||
|
||||
public init(peerView: PeerView) {
|
||||
public init(peerView: EngineRawPeerView) {
|
||||
self.init(peerId: peerView.peerId, peer: peerViewMainPeer(peerView), isContact: peerView.peerIsContact, isSavedMessages: false, notificationSettings: peerView.notificationSettings as? TelegramPeerNotificationSettings, peerPresences: peerView.peerPresences, cachedData: peerView.cachedData)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import UIKit
|
|||
import Display
|
||||
import AccountContext
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
import ComponentFlow
|
||||
|
|
@ -238,26 +237,19 @@ final class StickerAttachmentScreenComponent: Component {
|
|||
return
|
||||
}
|
||||
|
||||
let viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedEmojiPacks)
|
||||
let _ = (combineLatest(
|
||||
context.account.postbox.itemCollectionsView(orderedItemListCollectionIds: [], namespaces: [Namespaces.ItemCollection.CloudEmojiPacks], aroundIndex: nil, count: 10000000),
|
||||
context.account.postbox.combinedView(keys: [viewKey])
|
||||
context.engine.data.subscribe(TelegramEngine.EngineData.Item.ItemCollections.InstalledPackIds(namespace: Namespaces.ItemCollection.CloudEmojiPacks)),
|
||||
context.engine.data.subscribe(TelegramEngine.EngineData.Item.OrderedLists.ListItems(collectionId: Namespaces.OrderedItemList.CloudFeaturedEmojiPacks))
|
||||
)
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] emojiPacksView, views in
|
||||
guard let view = views.views[viewKey] as? OrderedItemListView else {
|
||||
return
|
||||
}
|
||||
|> deliverOnMainQueue).start(next: { [weak self] installedIds, items in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
|
||||
var installedCollectionIds = Set<ItemCollectionId>()
|
||||
for (id, _, _) in emojiPacksView.collectionInfos {
|
||||
installedCollectionIds.insert(id)
|
||||
}
|
||||
|
||||
let stickerPacks = view.items.map({ $0.contents.get(FeaturedStickerPackItem.self)! }).filter({
|
||||
|
||||
let installedCollectionIds = Set(installedIds)
|
||||
|
||||
let stickerPacks = items.map({ $0.contents.get(FeaturedStickerPackItem.self)! }).filter({
|
||||
!installedCollectionIds.contains($0.info.id)
|
||||
})
|
||||
|
||||
|
|
@ -289,18 +281,14 @@ final class StickerAttachmentScreenComponent: Component {
|
|||
openSearch: {
|
||||
},
|
||||
addGroupAction: { [weak self] groupId, isPremiumLocked, _ in
|
||||
guard let self, let component = self.component, let collectionId = groupId.base as? ItemCollectionId else {
|
||||
guard let self, let component = self.component, let collectionId = groupId.base as? EngineItemCollectionId else {
|
||||
return
|
||||
}
|
||||
let context = component.context
|
||||
let viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedEmojiPacks)
|
||||
let _ = (context.account.postbox.combinedView(keys: [viewKey])
|
||||
let _ = (context.engine.data.subscribe(TelegramEngine.EngineData.Item.OrderedLists.ListItems(collectionId: Namespaces.OrderedItemList.CloudFeaturedEmojiPacks))
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { views in
|
||||
guard let view = views.views[viewKey] as? OrderedItemListView else {
|
||||
return
|
||||
}
|
||||
for featuredStickerPack in view.items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
|> deliverOnMainQueue).start(next: { items in
|
||||
for featuredStickerPack in items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
if featuredStickerPack.info.id == collectionId {
|
||||
let _ = (context.engine.stickers.loadedStickerPack(reference: .id(id: featuredStickerPack.info.id.id, accessHash: featuredStickerPack.info.accessHash), forceActualized: false)
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
|
|
@ -466,7 +454,7 @@ final class StickerAttachmentScreenComponent: Component {
|
|||
appendUnicodeEmoji()
|
||||
}
|
||||
|
||||
var existingIds = Set<MediaId>()
|
||||
var existingIds = Set<EngineMedia.Id>()
|
||||
for itemFile in foundEmoji.items {
|
||||
if existingIds.contains(itemFile.fileId) {
|
||||
continue
|
||||
|
|
@ -532,7 +520,7 @@ final class StickerAttachmentScreenComponent: Component {
|
|||
|> mapToSignal { files, isFinalResult -> Signal<(items: [EmojiPagerContentComponent.ItemGroup], isFinalResult: Bool), NoError> in
|
||||
var items: [EmojiPagerContentComponent.Item] = []
|
||||
|
||||
var existingIds = Set<MediaId>()
|
||||
var existingIds = Set<EngineMedia.Id>()
|
||||
for itemFile in files {
|
||||
if existingIds.contains(itemFile.fileId) {
|
||||
continue
|
||||
|
|
@ -649,14 +637,13 @@ final class StickerAttachmentScreenComponent: Component {
|
|||
let context = component.context
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
if groupId == AnyHashable("featuredTop") {
|
||||
let viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedStickerPacks)
|
||||
let _ = (context.account.postbox.combinedView(keys: [viewKey])
|
||||
let _ = (context.engine.data.subscribe(TelegramEngine.EngineData.Item.OrderedLists.ListItems(collectionId: Namespaces.OrderedItemList.CloudFeaturedStickerPacks))
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] views in
|
||||
guard let self, let controller = self.environment?.controller(), let view = views.views[viewKey] as? OrderedItemListView else {
|
||||
|> deliverOnMainQueue).start(next: { [weak self] items in
|
||||
guard let self, let controller = self.environment?.controller() else {
|
||||
return
|
||||
}
|
||||
for featuredStickerPack in view.items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
for featuredStickerPack in items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
if featuredStickerPack.topItems.contains(where: { $0.file.fileId == file.fileId }) {
|
||||
controller.push(FeaturedStickersScreen(
|
||||
context: context,
|
||||
|
|
@ -670,7 +657,7 @@ final class StickerAttachmentScreenComponent: Component {
|
|||
return true
|
||||
}
|
||||
))
|
||||
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -699,18 +686,14 @@ final class StickerAttachmentScreenComponent: Component {
|
|||
}
|
||||
},
|
||||
addGroupAction: { [weak self] groupId, isPremiumLocked, _ in
|
||||
guard let strongSelf = self, let component = strongSelf.component, let collectionId = groupId.base as? ItemCollectionId else {
|
||||
guard let strongSelf = self, let component = strongSelf.component, let collectionId = groupId.base as? EngineItemCollectionId else {
|
||||
return
|
||||
}
|
||||
let context = component.context
|
||||
let viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedStickerPacks)
|
||||
let _ = (context.account.postbox.combinedView(keys: [viewKey])
|
||||
let _ = (context.engine.data.subscribe(TelegramEngine.EngineData.Item.OrderedLists.ListItems(collectionId: Namespaces.OrderedItemList.CloudFeaturedStickerPacks))
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { views in
|
||||
guard let view = views.views[viewKey] as? OrderedItemListView else {
|
||||
return
|
||||
}
|
||||
for featuredStickerPack in view.items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
|> deliverOnMainQueue).start(next: { items in
|
||||
for featuredStickerPack in items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
if featuredStickerPack.info.id == collectionId {
|
||||
let _ = (context.engine.stickers.loadedStickerPack(reference: .id(id: featuredStickerPack.info.id.id, accessHash: featuredStickerPack.info.accessHash), forceActualized: false)
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
|
|
@ -756,15 +739,11 @@ final class StickerAttachmentScreenComponent: Component {
|
|||
])])
|
||||
context.sharedContext.mainWindow?.presentInGlobalOverlay(actionSheet)
|
||||
} else if groupId == AnyHashable("featuredTop") {
|
||||
let viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedStickerPacks)
|
||||
let _ = (context.account.postbox.combinedView(keys: [viewKey])
|
||||
let _ = (context.engine.data.subscribe(TelegramEngine.EngineData.Item.OrderedLists.ListItems(collectionId: Namespaces.OrderedItemList.CloudFeaturedStickerPacks))
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { views in
|
||||
guard let view = views.views[viewKey] as? OrderedItemListView else {
|
||||
return
|
||||
}
|
||||
|> deliverOnMainQueue).start(next: { items in
|
||||
var stickerPackIds: [Int64] = []
|
||||
for featuredStickerPack in view.items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
for featuredStickerPack in items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
stickerPackIds.append(featuredStickerPack.info.id.id)
|
||||
}
|
||||
let _ = ApplicationSpecificNotice.setDismissedTrendingStickerPacks(accountManager: context.sharedContext.accountManager, values: stickerPackIds).start()
|
||||
|
|
@ -808,7 +787,7 @@ final class StickerAttachmentScreenComponent: Component {
|
|||
|> mapToSignal { files -> Signal<(items: [EmojiPagerContentComponent.ItemGroup], isFinalResult: Bool), NoError> in
|
||||
var items: [EmojiPagerContentComponent.Item] = []
|
||||
|
||||
var existingIds = Set<MediaId>()
|
||||
var existingIds = Set<EngineMedia.Id>()
|
||||
for item in files.items {
|
||||
let itemFile = item.file
|
||||
if existingIds.contains(itemFile.fileId) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import MultilineTextComponent
|
|||
import EmojiStatusComponent
|
||||
import PremiumUI
|
||||
import ProgressNavigationButtonNode
|
||||
import Postbox
|
||||
import SwitchComponent
|
||||
|
||||
private final class TitleFieldComponent: Component {
|
||||
|
|
@ -898,21 +897,17 @@ private final class ForumCreateTopicScreenComponent: CombinedComponent {
|
|||
openSearch: {
|
||||
},
|
||||
addGroupAction: { groupId, isPremiumLocked, _ in
|
||||
guard let collectionId = groupId.base as? ItemCollectionId else {
|
||||
guard let collectionId = groupId.base as? EngineItemCollectionId else {
|
||||
return
|
||||
}
|
||||
|
||||
let viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedEmojiPacks)
|
||||
let _ = (accountContext.account.postbox.combinedView(keys: [viewKey])
|
||||
|
||||
let _ = (accountContext.engine.data.subscribe(TelegramEngine.EngineData.Item.Collections.FeaturedEmojiPacks())
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { views in
|
||||
guard let view = views.views[viewKey] as? OrderedItemListView else {
|
||||
return
|
||||
}
|
||||
for featuredEmojiPack in view.items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
||||
|> deliverOnMainQueue).start(next: { items in
|
||||
for featuredEmojiPack in items {
|
||||
if featuredEmojiPack.info.id == collectionId {
|
||||
let _ = accountContext.engine.stickers.addStickerPackInteractively(info: featuredEmojiPack.info._parse(), items: featuredEmojiPack.topItems).start()
|
||||
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import Display
|
|||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
import ItemListUI
|
||||
|
|
@ -220,21 +219,21 @@ final class ChatGiftPreviewItemNode: ListViewItemNode {
|
|||
var insets: UIEdgeInsets
|
||||
let separatorHeight = UIScreenPixel
|
||||
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(1))
|
||||
let peerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudChannel, id: EnginePeer.Id.Id._internalFromInt64Value(1))
|
||||
let chatPeerId = item.chatPeerId ?? peerId
|
||||
|
||||
var items: [ListViewItem] = []
|
||||
for _ in 0 ..< 1 {
|
||||
let authorPeerId = item.context.account.peerId
|
||||
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
let messages = SimpleDictionary<MessageId, Message>()
|
||||
var peers = EngineSimpleDictionary<EnginePeer.Id, EngineRawPeer>()
|
||||
let messages = EngineSimpleDictionary<EngineMessage.Id, EngineRawMessage>()
|
||||
|
||||
for peer in item.peers {
|
||||
peers[peer.id] = peer._asPeer()
|
||||
}
|
||||
|
||||
let media: [Media]
|
||||
let media: [EngineRawMedia]
|
||||
switch item.subject {
|
||||
case let .premium(months, amount, currency):
|
||||
media = [
|
||||
|
|
@ -250,7 +249,7 @@ final class ChatGiftPreviewItemNode: ListViewItemNode {
|
|||
]
|
||||
}
|
||||
|
||||
let message = Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: chatPeerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[authorPeerId], text: "", attributes: [], media: media, peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message = EngineRawMessage(stableId: 1, stableVersion: 0, id: EngineMessage.Id(peerId: chatPeerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[authorPeerId], text: "", attributes: [], media: media, peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
items.append(item.context.sharedContext.makeChatMessagePreviewItem(context: item.context, messages: [message], theme: item.componentTheme, strings: item.strings, wallpaper: item.wallpaper, fontSize: item.fontSize, chatBubbleCorners: item.chatBubbleCorners, dateTimeFormat: item.dateTimeFormat, nameOrder: item.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: currentBackgroundNode, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
|
|
@ -37,7 +36,7 @@ private enum GroupStickerPackSection: Int32 {
|
|||
|
||||
private enum GroupStickerPackEntryId: Hashable {
|
||||
case index(Int32)
|
||||
case pack(ItemCollectionId)
|
||||
case pack(EngineItemCollectionId)
|
||||
|
||||
static func ==(lhs: GroupStickerPackEntryId, rhs: GroupStickerPackEntryId) -> Bool {
|
||||
switch lhs {
|
||||
|
|
@ -265,7 +264,7 @@ private struct GroupStickerPackSetupControllerState: Equatable {
|
|||
var searchingPacks: Bool
|
||||
}
|
||||
|
||||
private func groupStickerPackSetupControllerEntries(context: AccountContext, presentationData: PresentationData, searchText: String, view: CombinedView, initialData: InitialStickerPackData?, searchState: GroupStickerPackSearchState, stickerSettings: StickerSettings, isEmoji: Bool) -> [GroupStickerPackEntry] {
|
||||
private func groupStickerPackSetupControllerEntries(context: AccountContext, presentationData: PresentationData, searchText: String, packsEntries: [EngineRawItemCollectionInfoEntry], initialData: InitialStickerPackData?, searchState: GroupStickerPackSearchState, stickerSettings: StickerSettings, isEmoji: Bool) -> [GroupStickerPackEntry] {
|
||||
if initialData == nil {
|
||||
return []
|
||||
}
|
||||
|
|
@ -284,39 +283,34 @@ private func groupStickerPackSetupControllerEntries(context: AccountContext, pre
|
|||
}
|
||||
entries.append(.searchInfo(presentationData.theme, isEmoji ? presentationData.strings.Group_Emoji_Info : presentationData.strings.Channel_Stickers_CreateYourOwn))
|
||||
|
||||
let namespace = isEmoji ? Namespaces.ItemCollection.CloudEmojiPacks : Namespaces.ItemCollection.CloudStickerPacks
|
||||
if let stickerPacksView = view.views[.itemCollectionInfos(namespaces: [namespace])] as? ItemCollectionInfosView {
|
||||
if let packsEntries = stickerPacksView.entriesByNamespace[namespace] {
|
||||
if !packsEntries.isEmpty {
|
||||
entries.append(.packsTitle(presentationData.theme, isEmoji ? presentationData.strings.Group_Emoji_YourEmoji : presentationData.strings.Channel_Stickers_YourStickers))
|
||||
if !packsEntries.isEmpty {
|
||||
entries.append(.packsTitle(presentationData.theme, isEmoji ? presentationData.strings.Group_Emoji_YourEmoji : presentationData.strings.Channel_Stickers_YourStickers))
|
||||
}
|
||||
|
||||
var index: Int32 = 0
|
||||
for entry in packsEntries {
|
||||
if let info = entry.info as? StickerPackCollectionInfo {
|
||||
var selected = false
|
||||
if case let .found(found) = searchState {
|
||||
selected = found.info.id == info.id
|
||||
}
|
||||
|
||||
var index: Int32 = 0
|
||||
for entry in packsEntries {
|
||||
if let info = entry.info as? StickerPackCollectionInfo {
|
||||
var selected = false
|
||||
if case let .found(found) = searchState {
|
||||
selected = found.info.id == info.id
|
||||
}
|
||||
let count = info.count == 0 ? entry.count : info.count
|
||||
|
||||
let thumbnail: StickerPackItem?
|
||||
if let thumbnailRep = info.thumbnail {
|
||||
thumbnail = StickerPackItem(index: ItemCollectionItemIndex(index: 0, id: 0), file: TelegramMediaFile(fileId: MediaId(namespace: 0, id: 0), partialReference: nil, resource: thumbnailRep.resource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: info.immediateThumbnailData, mimeType: "", size: nil, attributes: [], alternativeRepresentations: []), indexKeys: [])
|
||||
} else {
|
||||
thumbnail = entry.firstItem as? StickerPackItem
|
||||
}
|
||||
entries.append(.pack(index, presentationData.theme, presentationData.strings, info, thumbnail, isEmoji ? presentationData.strings.StickerPack_EmojiCount(count) : presentationData.strings.StickerPack_StickerCount(count), context.sharedContext.energyUsageSettings.loopStickers, selected))
|
||||
index += 1
|
||||
}
|
||||
let count = info.count == 0 ? entry.count : info.count
|
||||
|
||||
let thumbnail: StickerPackItem?
|
||||
if let thumbnailRep = info.thumbnail {
|
||||
thumbnail = StickerPackItem(index: EngineItemCollectionItemIndex(index: 0, id: 0), file: TelegramMediaFile(fileId: EngineMedia.Id(namespace: 0, id: 0), partialReference: nil, resource: thumbnailRep.resource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: info.immediateThumbnailData, mimeType: "", size: nil, attributes: [], alternativeRepresentations: []), indexKeys: [])
|
||||
} else {
|
||||
thumbnail = entry.firstItem as? StickerPackItem
|
||||
}
|
||||
entries.append(.pack(index, presentationData.theme, presentationData.strings, info, thumbnail, isEmoji ? presentationData.strings.StickerPack_EmojiCount(count) : presentationData.strings.StickerPack_StickerCount(count), context.sharedContext.energyUsageSettings.loopStickers, selected))
|
||||
index += 1
|
||||
}
|
||||
}
|
||||
|
||||
return entries
|
||||
}
|
||||
|
||||
public func groupStickerPackSetupController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, peerId: PeerId, isEmoji: Bool = false, currentPackInfo: StickerPackCollectionInfo?, completion: ((StickerPackCollectionInfo?) -> Void)? = nil) -> ViewController {
|
||||
public func groupStickerPackSetupController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, peerId: EnginePeer.Id, isEmoji: Bool = false, currentPackInfo: StickerPackCollectionInfo?, completion: ((StickerPackCollectionInfo?) -> Void)? = nil) -> ViewController {
|
||||
let initialState = GroupStickerPackSetupControllerState(isSaving: false, searchingPacks: false)
|
||||
|
||||
let statePromise = ValuePromise(initialState, ignoreRepeated: true)
|
||||
|
|
@ -353,12 +347,12 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres
|
|||
}
|
||||
}
|
||||
|
||||
let stickerPacks = Promise<CombinedView>()
|
||||
stickerPacks.set(context.account.postbox.combinedView(keys: [.itemCollectionInfos(namespaces: [isEmoji ? Namespaces.ItemCollection.CloudEmojiPacks : Namespaces.ItemCollection.CloudStickerPacks])]))
|
||||
let stickerPacks = Promise<[EngineRawItemCollectionInfoEntry]>()
|
||||
stickerPacks.set(context.engine.data.subscribe(TelegramEngine.EngineData.Item.ItemCollections.InstalledPackInfos(namespace: isEmoji ? Namespaces.ItemCollection.CloudEmojiPacks : Namespaces.ItemCollection.CloudStickerPacks)))
|
||||
|
||||
let searchState = Promise<(String, GroupStickerPackSearchState)>()
|
||||
searchState.set(combineLatest(searchText.get(), initialData.get(), stickerPacks.get())
|
||||
|> mapToSignal { searchText, initialData, view -> Signal<(String, GroupStickerPackSearchState), NoError> in
|
||||
|> mapToSignal { searchText, initialData, packsEntries -> Signal<(String, GroupStickerPackSearchState), NoError> in
|
||||
if let initialData = initialData {
|
||||
if searchText.isEmpty {
|
||||
return .single((searchText, .none))
|
||||
|
|
@ -368,15 +362,10 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres
|
|||
}
|
||||
return .single((searchText, .found(StickerPackData(info: data.info, item: data.item))))
|
||||
} else {
|
||||
let namespace = isEmoji ? Namespaces.ItemCollection.CloudEmojiPacks : Namespaces.ItemCollection.CloudStickerPacks
|
||||
if let stickerPacksView = view.views[.itemCollectionInfos(namespaces: [namespace])] as? ItemCollectionInfosView {
|
||||
if let packsEntries = stickerPacksView.entriesByNamespace[namespace] {
|
||||
for entry in packsEntries {
|
||||
if let info = entry.info as? StickerPackCollectionInfo {
|
||||
if info.shortName.lowercased() == searchText.lowercased() {
|
||||
return .single((searchText, .found(StickerPackData(info: info, item: entry.firstItem as? StickerPackItem))))
|
||||
}
|
||||
}
|
||||
for entry in packsEntries {
|
||||
if let info = entry.info as? StickerPackCollectionInfo {
|
||||
if info.shortName.lowercased() == searchText.lowercased() {
|
||||
return .single((searchText, .found(StickerPackData(info: info, item: entry.firstItem as? StickerPackItem))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -405,7 +394,7 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres
|
|||
}
|
||||
})
|
||||
|
||||
var navigateToChatControllerImpl: ((PeerId) -> Void)?
|
||||
var navigateToChatControllerImpl: ((EnginePeer.Id) -> Void)?
|
||||
var dismissInputImpl: (() -> Void)?
|
||||
var dismissImpl: (() -> Void)?
|
||||
|
||||
|
|
@ -449,7 +438,7 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres
|
|||
|
||||
let presentationData = updatedPresentationData?.signal ?? context.sharedContext.presentationData
|
||||
let signal = combineLatest(presentationData, statePromise.get() |> deliverOnMainQueue, initialData.get() |> deliverOnMainQueue, stickerPacks.get() |> deliverOnMainQueue, searchState.get() |> deliverOnMainQueue, context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.stickerSettings]) |> deliverOnMainQueue)
|
||||
|> map { presentationData, state, initialData, view, searchState, sharedData -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
||||
|> map { presentationData, state, initialData, packsEntries, searchState, sharedData -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
||||
var stickerSettings = StickerSettings.defaultSettings
|
||||
if let value = sharedData.entries[ApplicationSpecificSharedDataKeys.stickerSettings]?.get(StickerSettings.self) {
|
||||
stickerSettings = value
|
||||
|
|
@ -539,7 +528,7 @@ public func groupStickerPackSetupController(context: AccountContext, updatedPres
|
|||
emptyStateItem = ItemListLoadingIndicatorEmptyStateItem(theme: presentationData.theme)
|
||||
}
|
||||
|
||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: groupStickerPackSetupControllerEntries(context: context, presentationData: presentationData, searchText: searchState.0, view: view, initialData: initialData, searchState: searchState.1, stickerSettings: stickerSettings, isEmoji: isEmoji), style: .blocks, emptyStateItem: emptyStateItem, searchItem: searchItem, animateChanges: hasData && hadData)
|
||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: groupStickerPackSetupControllerEntries(context: context, presentationData: presentationData, searchText: searchState.0, packsEntries: packsEntries, initialData: initialData, searchState: searchState.1, stickerSettings: stickerSettings, isEmoji: isEmoji), style: .blocks, emptyStateItem: emptyStateItem, searchItem: searchItem, animateChanges: hasData && hadData)
|
||||
return (controllerState, (listState, arguments))
|
||||
} |> afterDisposed {
|
||||
actionsDisposable.dispose()
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import AsyncDisplayKit
|
|||
import Display
|
||||
import ComponentFlow
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import Markdown
|
||||
import TextFormat
|
||||
|
|
@ -486,14 +485,14 @@ private final class CreateLinkSheetComponent: CombinedComponent {
|
|||
}
|
||||
}
|
||||
|
||||
var attributes: [MessageAttribute] = []
|
||||
var attributes: [EngineMessage.Attribute] = []
|
||||
attributes.append(TextEntitiesMessageAttribute(entities: [.init(range: 0 ..< (text as NSString).length, type: .Url)]))
|
||||
if !self.dismissed {
|
||||
attributes.append(WebpagePreviewMessageAttribute(leadingPreview: !self.positionBelowText, forceLargeMedia: self.largeMedia ?? webpageHasLargeMedia, isManuallyAdded: false, isSafe: true))
|
||||
}
|
||||
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1))
|
||||
let message = Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: nil, text: text, attributes: attributes, media: effectiveMedia.flatMap { [$0] } ?? [], peers: SimpleDictionary(), associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
|
||||
let peerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(1))
|
||||
let message = EngineRawMessage(stableId: 1, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: nil, text: text, attributes: attributes, media: effectiveMedia.flatMap { [$0] } ?? [], peers: EngineSimpleDictionary(), associatedMessages: EngineSimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
|
||||
|
||||
let completion = controller.completion
|
||||
|
|
|
|||
|
|
@ -9044,13 +9044,9 @@ func hasFirstResponder(_ view: UIView) -> Bool {
|
|||
}
|
||||
|
||||
private func allowedStoryReactions(context: AccountContext) -> Signal<[ReactionItem], NoError> {
|
||||
let viewKey: PostboxViewKey = .orderedItemList(id: Namespaces.OrderedItemList.CloudTopReactions)
|
||||
let topReactions = context.account.postbox.combinedView(keys: [viewKey])
|
||||
|> map { views -> [RecentReactionItem] in
|
||||
guard let view = views.views[viewKey] as? OrderedItemListView else {
|
||||
return []
|
||||
}
|
||||
return view.items.compactMap { item -> RecentReactionItem? in
|
||||
let topReactions = context.engine.data.subscribe(TelegramEngine.EngineData.Item.OrderedLists.ListItems(collectionId: Namespaces.OrderedItemList.CloudTopReactions))
|
||||
|> map { items -> [RecentReactionItem] in
|
||||
return items.compactMap { item -> RecentReactionItem? in
|
||||
return item.contents.get(RecentReactionItem.self)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramUIPreferences
|
||||
import AccountContext
|
||||
|
|
@ -10,10 +9,10 @@ import MusicAlbumArtResources
|
|||
import TextFormat
|
||||
|
||||
private enum PeerMessagesMediaPlaylistLoadAnchor {
|
||||
case messageId(MessageId)
|
||||
case index(MessageIndex)
|
||||
|
||||
var id: MessageId {
|
||||
case messageId(EngineMessage.Id)
|
||||
case index(EngineMessage.Index)
|
||||
|
||||
var id: EngineMessage.Id {
|
||||
switch self {
|
||||
case let .messageId(id):
|
||||
return id
|
||||
|
|
@ -33,7 +32,7 @@ struct MessageMediaPlaylistItemStableId: Hashable {
|
|||
let stableId: UInt32
|
||||
}
|
||||
|
||||
private func extractFileMedia(_ message: Message) -> TelegramMediaFile? {
|
||||
private func extractFileMedia(_ message: EngineRawMessage) -> TelegramMediaFile? {
|
||||
var file: TelegramMediaFile?
|
||||
for media in message.media {
|
||||
if let media = media as? TelegramMediaFile {
|
||||
|
|
@ -52,10 +51,10 @@ private func extractFileMedia(_ message: Message) -> TelegramMediaFile? {
|
|||
|
||||
public final class MessageMediaPlaylistItem: SharedMediaPlaylistItem {
|
||||
public let id: SharedMediaPlaylistItemId
|
||||
public let message: Message
|
||||
public let message: EngineRawMessage
|
||||
public let isSavedMusic: Bool
|
||||
|
||||
public init(message: Message, isSavedMusic: Bool) {
|
||||
|
||||
public init(message: EngineRawMessage, isSavedMusic: Bool) {
|
||||
self.id = PeerMessagesMediaPlaylistItemId(messageId: message.id, messageIndex: message.index)
|
||||
self.message = message
|
||||
self.isSavedMusic = isSavedMusic
|
||||
|
|
@ -162,11 +161,11 @@ private enum NavigatedMessageFromViewPosition {
|
|||
case exact
|
||||
}
|
||||
|
||||
private func aroundMessagesFromMessages(_ messages: [Message], centralIndex: MessageIndex) -> [Message] {
|
||||
private func aroundMessagesFromMessages(_ messages: [EngineRawMessage], centralIndex: EngineMessage.Index) -> [EngineRawMessage] {
|
||||
guard let index = messages.firstIndex(where: { $0.index.id == centralIndex.id }) else {
|
||||
return []
|
||||
}
|
||||
var result: [Message] = []
|
||||
var result: [EngineRawMessage] = []
|
||||
if index != 0 {
|
||||
for i in (0 ..< index).reversed() {
|
||||
result.append(messages[i])
|
||||
|
|
@ -182,7 +181,7 @@ private func aroundMessagesFromMessages(_ messages: [Message], centralIndex: Mes
|
|||
return result
|
||||
}
|
||||
|
||||
private func aroundMessagesFromView(view: MessageHistoryView, centralIndex: MessageIndex) -> [Message] {
|
||||
private func aroundMessagesFromView(view: EngineRawMessageHistoryView, centralIndex: EngineMessage.Index) -> [EngineRawMessage] {
|
||||
let filteredEntries = view.entries.filter { entry in
|
||||
if entry.message.minAutoremoveOrClearTimeout == viewOnceTimeout {
|
||||
return false
|
||||
|
|
@ -194,7 +193,7 @@ private func aroundMessagesFromView(view: MessageHistoryView, centralIndex: Mess
|
|||
guard let index = filteredEntries.firstIndex(where: { $0.index.id == centralIndex.id }) else {
|
||||
return []
|
||||
}
|
||||
var result: [Message] = []
|
||||
var result: [EngineRawMessage] = []
|
||||
if index != 0 {
|
||||
for i in (0 ..< index).reversed() {
|
||||
result.append(filteredEntries[i].message)
|
||||
|
|
@ -210,7 +209,7 @@ private func aroundMessagesFromView(view: MessageHistoryView, centralIndex: Mess
|
|||
return result
|
||||
}
|
||||
|
||||
private func navigatedMessageFromMessages(_ messages: [Message], anchorIndex: MessageIndex, position: NavigatedMessageFromViewPosition) -> (message: Message, around: [Message], exact: Bool)? {
|
||||
private func navigatedMessageFromMessages(_ messages: [EngineRawMessage], anchorIndex: EngineMessage.Index, position: NavigatedMessageFromViewPosition) -> (message: EngineRawMessage, around: [EngineRawMessage], exact: Bool)? {
|
||||
var index = 0
|
||||
for message in messages {
|
||||
if message.index.id == anchorIndex.id {
|
||||
|
|
@ -249,7 +248,7 @@ private func navigatedMessageFromMessages(_ messages: [Message], anchorIndex: Me
|
|||
}
|
||||
}
|
||||
|
||||
private func navigatedMessageFromView(_ view: MessageHistoryView, anchorIndex: MessageIndex, position: NavigatedMessageFromViewPosition, reversed: Bool) -> (message: Message, around: [Message], exact: Bool)? {
|
||||
private func navigatedMessageFromView(_ view: EngineRawMessageHistoryView, anchorIndex: EngineMessage.Index, position: NavigatedMessageFromViewPosition, reversed: Bool) -> (message: EngineRawMessage, around: [EngineRawMessage], exact: Bool)? {
|
||||
var index = 0
|
||||
|
||||
let filteredEntries = view.entries.filter { entry in
|
||||
|
|
@ -348,10 +347,10 @@ private func navigatedMessageFromView(_ view: MessageHistoryView, anchorIndex: M
|
|||
}
|
||||
|
||||
private struct PlaybackStack {
|
||||
var ids: [MessageId] = []
|
||||
var set: Set<MessageId> = []
|
||||
var ids: [EngineMessage.Id] = []
|
||||
var set: Set<EngineMessage.Id> = []
|
||||
|
||||
mutating func resetToId(_ id: MessageId) {
|
||||
mutating func resetToId(_ id: EngineMessage.Id) {
|
||||
if self.set.contains(id) {
|
||||
if let index = self.ids.firstIndex(of: id) {
|
||||
for i in (index + 1) ..< self.ids.count {
|
||||
|
|
@ -369,7 +368,7 @@ private struct PlaybackStack {
|
|||
}
|
||||
}
|
||||
|
||||
mutating func push(_ id: MessageId) {
|
||||
mutating func push(_ id: EngineMessage.Id) {
|
||||
if self.set.contains(id) {
|
||||
if let index = self.ids.firstIndex(of: id) {
|
||||
self.ids.remove(at: index)
|
||||
|
|
@ -379,7 +378,7 @@ private struct PlaybackStack {
|
|||
self.set.insert(id)
|
||||
}
|
||||
|
||||
mutating func pop() -> MessageId? {
|
||||
mutating func pop() -> EngineMessage.Id? {
|
||||
if !self.ids.isEmpty {
|
||||
let id = self.ids.removeLast()
|
||||
self.set.remove(id)
|
||||
|
|
@ -411,8 +410,8 @@ public final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||
|
||||
private var playbackStack = PlaybackStack()
|
||||
|
||||
private var currentItem: (current: Message, around: [Message])?
|
||||
private var currentlyObservedMessageId: MessageId?
|
||||
private var currentItem: (current: EngineRawMessage, around: [EngineRawMessage])?
|
||||
private var currentlyObservedMessageId: EngineMessage.Id?
|
||||
private let currentlyObservedMessageDisposable = MetaDisposable()
|
||||
private var loadingItem: Bool = false
|
||||
private var loadingMore: Bool = false
|
||||
|
|
@ -564,7 +563,7 @@ public final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||
self.loadingItem = true
|
||||
self.updateState()
|
||||
|
||||
let namespaces: MessageIdNamespaces
|
||||
let namespaces: EngineMessageIdNamespaces
|
||||
if Namespaces.Message.allScheduled.contains(anchor.id.namespace) {
|
||||
namespaces = .just(Namespaces.Message.allScheduled)
|
||||
} else if Namespaces.Message.allQuickReply.contains(anchor.id.namespace) {
|
||||
|
|
@ -579,13 +578,13 @@ public final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||
case let .messages(chatLocation, tagMask, _):
|
||||
let historySignal = self.context.account.postbox.messageAtId(messageId)
|
||||
|> take(1)
|
||||
|> mapToSignal { message -> Signal<(Message, [Message])?, NoError> in
|
||||
|> mapToSignal { message -> Signal<(EngineRawMessage, [EngineRawMessage])?, NoError> in
|
||||
guard let message = message else {
|
||||
return .single(nil)
|
||||
}
|
||||
|
||||
return self.context.account.postbox.aroundMessageHistoryViewForLocation(self.context.chatLocationInput(for: chatLocation, contextHolder: self.chatLocationContextHolder ?? Atomic<ChatLocationContextHolder?>(value: nil)), anchor: .index(message.index), ignoreMessagesInTimestampRange: nil, ignoreMessageIds: Set(), count: 10, fixedCombinedReadStates: nil, topTaggedMessageIdNamespaces: [], tag: .tag(tagMask), appendMessagesFromTheSameGroup: false, namespaces: namespaces, orderStatistics: [])
|
||||
|> mapToSignal { view -> Signal<(Message, [Message])?, NoError> in
|
||||
|> mapToSignal { view -> Signal<(EngineRawMessage, [EngineRawMessage])?, NoError> in
|
||||
if let (message, aroundMessages, _) = navigatedMessageFromView(view.0, anchorIndex: message.index, position: .exact, reversed: reversed) {
|
||||
return .single((message, aroundMessages))
|
||||
} else {
|
||||
|
|
@ -658,7 +657,7 @@ public final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||
case let .index(index):
|
||||
switch self.messagesLocation.effectiveLocation(context: self.context) {
|
||||
case let .messages(chatLocation, tagMask, _):
|
||||
var inputIndex: Signal<MessageIndex?, NoError>?
|
||||
var inputIndex: Signal<EngineMessage.Index?, NoError>?
|
||||
let looping = self.looping
|
||||
switch self.order {
|
||||
case .regular, .reversed:
|
||||
|
|
@ -693,12 +692,12 @@ public final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||
}
|
||||
}
|
||||
let historySignal = (inputIndex ?? .single(nil))
|
||||
|> mapToSignal { inputIndex -> Signal<(Message, [Message])?, NoError> in
|
||||
|> mapToSignal { inputIndex -> Signal<(EngineRawMessage, [EngineRawMessage])?, NoError> in
|
||||
guard let inputIndex = inputIndex else {
|
||||
return .single(nil)
|
||||
}
|
||||
return self.context.account.postbox.aroundMessageHistoryViewForLocation(self.context.chatLocationInput(for: chatLocation, contextHolder: self.chatLocationContextHolder ?? Atomic<ChatLocationContextHolder?>(value: nil)), anchor: .index(inputIndex), ignoreMessagesInTimestampRange: nil, ignoreMessageIds: Set(), count: 10, fixedCombinedReadStates: nil, topTaggedMessageIdNamespaces: [], tag: .tag(tagMask), appendMessagesFromTheSameGroup: false, namespaces: namespaces, orderStatistics: [])
|
||||
|> mapToSignal { view -> Signal<(Message, [Message])?, NoError> in
|
||||
|> mapToSignal { view -> Signal<(EngineRawMessage, [EngineRawMessage])?, NoError> in
|
||||
let position: NavigatedMessageFromViewPosition
|
||||
switch navigation {
|
||||
case .later:
|
||||
|
|
@ -721,14 +720,14 @@ public final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||
}
|
||||
|
||||
if case .all = looping {
|
||||
let viewIndex: HistoryViewInputAnchor
|
||||
let viewIndex: EngineHistoryViewInputAnchor
|
||||
if case .earlier = navigation {
|
||||
viewIndex = .upperBound
|
||||
} else {
|
||||
viewIndex = .lowerBound
|
||||
}
|
||||
return self.context.account.postbox.aroundMessageHistoryViewForLocation(self.context.chatLocationInput(for: chatLocation, contextHolder: self.chatLocationContextHolder ?? Atomic<ChatLocationContextHolder?>(value: nil)), anchor: viewIndex, ignoreMessagesInTimestampRange: nil, ignoreMessageIds: Set(), count: 10, fixedCombinedReadStates: nil, topTaggedMessageIdNamespaces: [], tag: .tag(tagMask), appendMessagesFromTheSameGroup: false, namespaces: namespaces, orderStatistics: [])
|
||||
|> mapToSignal { view -> Signal<(Message, [Message])?, NoError> in
|
||||
|> mapToSignal { view -> Signal<(EngineRawMessage, [EngineRawMessage])?, NoError> in
|
||||
let position: NavigatedMessageFromViewPosition
|
||||
switch navigation {
|
||||
case .later, .random:
|
||||
|
|
@ -736,7 +735,7 @@ public final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||
case .earlier:
|
||||
position = .later
|
||||
}
|
||||
if let (message, aroundMessages, _) = navigatedMessageFromView(view.0, anchorIndex: MessageIndex.absoluteLowerBound(), position: position, reversed: reversed) {
|
||||
if let (message, aroundMessages, _) = navigatedMessageFromView(view.0, anchorIndex: EngineMessage.Index.absoluteLowerBound(), position: position, reversed: reversed) {
|
||||
return .single((message, aroundMessages))
|
||||
} else {
|
||||
return .single(nil)
|
||||
|
|
@ -791,7 +790,7 @@ public final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||
case .savedMusic:
|
||||
fatalError()
|
||||
case let .custom(messages, _, _, loadMore, _):
|
||||
let inputIndex: Signal<MessageIndex, NoError>
|
||||
let inputIndex: Signal<EngineMessage.Index, NoError>
|
||||
let looping = self.looping
|
||||
switch self.order {
|
||||
case .regular, .reversed:
|
||||
|
|
@ -800,7 +799,7 @@ public final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||
var playbackStack = self.playbackStack
|
||||
inputIndex = messages
|
||||
|> take(1)
|
||||
|> map { messages, _, _ -> MessageIndex in
|
||||
|> map { messages, _, _ -> EngineMessage.Index in
|
||||
if case let .random(previous) = navigation, previous {
|
||||
let _ = playbackStack.pop()
|
||||
while true {
|
||||
|
|
@ -817,10 +816,10 @@ public final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||
}
|
||||
}
|
||||
let historySignal = inputIndex
|
||||
|> mapToSignal { inputIndex -> Signal<((Message, [Message])?, Int, Bool), NoError> in
|
||||
|> mapToSignal { inputIndex -> Signal<((EngineRawMessage, [EngineRawMessage])?, Int, Bool), NoError> in
|
||||
return messages
|
||||
|> take(1)
|
||||
|> mapToSignal { messages, _, hasMore -> Signal<((Message, [Message])?, Int, Bool), NoError> in
|
||||
|> mapToSignal { messages, _, hasMore -> Signal<((EngineRawMessage, [EngineRawMessage])?, Int, Bool), NoError> in
|
||||
let position: NavigatedMessageFromViewPosition
|
||||
switch navigation {
|
||||
case .later:
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ swift_library(
|
|||
"//submodules/Components/ViewControllerComponent",
|
||||
"//submodules/SSignalKit/SwiftSignalKit",
|
||||
"//submodules/TelegramCore",
|
||||
"//submodules/Postbox",
|
||||
"//submodules/AccountContext",
|
||||
"//submodules/TelegramUI/Components/EntityKeyboard",
|
||||
"//submodules/TelegramUI/Components/SwitchComponent",
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import AppBundle
|
|||
import ViewControllerComponent
|
||||
import AccountContext
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import EntityKeyboard
|
||||
import MultilineTextComponent
|
||||
|
|
@ -698,14 +697,14 @@ final class PeerAllowedReactionsScreenComponent: Component {
|
|||
let remoteSignal = emojiSearchContext.state
|
||||
|
||||
return combineLatest(
|
||||
context.account.postbox.itemCollectionsView(orderedItemListCollectionIds: [], namespaces: [Namespaces.ItemCollection.CloudEmojiPacks], aroundIndex: nil, count: 10000000) |> take(1),
|
||||
context.engine.itemCollections.allItems(namespace: Namespaces.ItemCollection.CloudEmojiPacks) |> take(1),
|
||||
context.engine.stickers.availableReactions() |> take(1),
|
||||
hasPremium |> take(1),
|
||||
remotePacksSignal,
|
||||
remoteSignal,
|
||||
localPacksSignal
|
||||
)
|
||||
|> map { view, availableReactions, hasPremium, foundPacks, foundEmoji, foundLocalPacks -> (groups: [EmojiPagerContentComponent.ItemGroup], canLoadMore: Bool, isSearching: Bool, searchContext: EmojiSearchContext?) in
|
||||
|> map { rawItems, availableReactions, hasPremium, foundPacks, foundEmoji, foundLocalPacks -> (groups: [EmojiPagerContentComponent.ItemGroup], canLoadMore: Bool, isSearching: Bool, searchContext: EmojiSearchContext?) in
|
||||
var result: [(String, TelegramMediaFile.Accessor?, String)] = []
|
||||
|
||||
var allEmoticons: [String: String] = [:]
|
||||
|
|
@ -730,8 +729,8 @@ final class PeerAllowedReactionsScreenComponent: Component {
|
|||
}
|
||||
}
|
||||
|
||||
for entry in view.entries {
|
||||
guard let item = entry.item as? StickerPackItem else {
|
||||
for rawItem in rawItems {
|
||||
guard let item = rawItem as? StickerPackItem else {
|
||||
continue
|
||||
}
|
||||
if !item.file.isPremiumEmoji {
|
||||
|
|
@ -747,7 +746,7 @@ final class PeerAllowedReactionsScreenComponent: Component {
|
|||
|
||||
var items: [EmojiPagerContentComponent.Item] = []
|
||||
|
||||
var existingIds = Set<MediaId>()
|
||||
var existingIds = Set<EngineMedia.Id>()
|
||||
for item in result {
|
||||
if let itemFile = item.1 {
|
||||
if existingIds.contains(itemFile.fileId) {
|
||||
|
|
@ -790,7 +789,7 @@ final class PeerAllowedReactionsScreenComponent: Component {
|
|||
combinedSets = foundLocalPacks
|
||||
combinedSets = combinedSets.merge(with: foundPacks.sets)
|
||||
|
||||
var existingCollectionIds = Set<ItemCollectionId>()
|
||||
var existingCollectionIds = Set<EngineItemCollectionId>()
|
||||
for (collectionId, info, _, _) in combinedSets.infos {
|
||||
if !existingCollectionIds.contains(collectionId) {
|
||||
existingCollectionIds.insert(collectionId)
|
||||
|
|
@ -876,7 +875,7 @@ final class PeerAllowedReactionsScreenComponent: Component {
|
|||
|> mapToSignal { files, isFinalResult -> Signal<(items: [EmojiPagerContentComponent.ItemGroup], isFinalResult: Bool), NoError> in
|
||||
var items: [EmojiPagerContentComponent.Item] = []
|
||||
|
||||
var existingIds = Set<MediaId>()
|
||||
var existingIds = Set<EngineMedia.Id>()
|
||||
for itemFile in files {
|
||||
if existingIds.contains(itemFile.fileId) {
|
||||
continue
|
||||
|
|
@ -1818,10 +1817,10 @@ public class PeerAllowedReactionsScreen: ViewControllerComponentContainer {
|
|||
public static func content(context: AccountContext, peerId: EnginePeer.Id) -> Signal<Content, NoError> {
|
||||
return combineLatest(
|
||||
context.engine.stickers.availableReactions(),
|
||||
context.account.postbox.combinedView(keys: [.cachedPeerData(peerId: peerId)])
|
||||
context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.CachedData(id: peerId))
|
||||
)
|
||||
|> mapToSignal { availableReactions, combinedView -> Signal<Content, NoError> in
|
||||
guard let cachedDataView = combinedView.views[.cachedPeerData(peerId: peerId)] as? CachedPeerDataView, let cachedData = cachedDataView.cachedPeerData as? CachedChannelData else {
|
||||
|> mapToSignal { availableReactions, cachedPeerData -> Signal<Content, NoError> in
|
||||
guard let cachedData = cachedPeerData as? CachedChannelData else {
|
||||
return .complete()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import UIKit
|
|||
import Display
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import AccountContext
|
||||
import ContextUI
|
||||
|
|
@ -25,17 +24,17 @@ private let mediaBadgeBackgroundColor = UIColor(white: 0.0, alpha: 0.6)
|
|||
private let mediaBadgeTextColor = UIColor.white
|
||||
|
||||
private final class VisualMediaItemInteraction {
|
||||
let openMessage: (Message) -> Void
|
||||
let openMessageContextActions: (Message, ASDisplayNode, CGRect, ContextGesture?) -> Void
|
||||
let toggleSelection: (MessageId, Bool) -> Void
|
||||
|
||||
var hiddenMedia: [MessageId: [Media]] = [:]
|
||||
var selectedMessageIds: Set<MessageId>?
|
||||
|
||||
let openMessage: (EngineRawMessage) -> Void
|
||||
let openMessageContextActions: (EngineRawMessage, ASDisplayNode, CGRect, ContextGesture?) -> Void
|
||||
let toggleSelection: (EngineMessage.Id, Bool) -> Void
|
||||
|
||||
var hiddenMedia: [EngineMessage.Id: [EngineRawMedia]] = [:]
|
||||
var selectedMessageIds: Set<EngineMessage.Id>?
|
||||
|
||||
init(
|
||||
openMessage: @escaping (Message) -> Void,
|
||||
openMessageContextActions: @escaping (Message, ASDisplayNode, CGRect, ContextGesture?) -> Void,
|
||||
toggleSelection: @escaping (MessageId, Bool) -> Void
|
||||
openMessage: @escaping (EngineRawMessage) -> Void,
|
||||
openMessageContextActions: @escaping (EngineRawMessage, ASDisplayNode, CGRect, ContextGesture?) -> Void,
|
||||
toggleSelection: @escaping (EngineMessage.Id, Bool) -> Void
|
||||
) {
|
||||
self.openMessage = openMessage
|
||||
self.openMessageContextActions = openMessageContextActions
|
||||
|
|
@ -58,9 +57,9 @@ private final class VisualMediaItemNode: ASDisplayNode {
|
|||
|
||||
private let fetchStatusDisposable = MetaDisposable()
|
||||
private let fetchDisposable = MetaDisposable()
|
||||
private var resourceStatus: MediaResourceStatus?
|
||||
|
||||
private var item: (VisualMediaItem, Media?, CGSize, CGSize?)?
|
||||
private var resourceStatus: EngineMediaResourceStatus?
|
||||
|
||||
private var item: (VisualMediaItem, EngineRawMedia?, CGSize, CGSize?)?
|
||||
private var theme: PresentationTheme?
|
||||
|
||||
private var hasVisibility: Bool = false
|
||||
|
|
@ -118,7 +117,7 @@ private final class VisualMediaItemNode: ASDisplayNode {
|
|||
if let (gesture, _) = recognizer.lastRecognizedGestureAndLocation {
|
||||
if case .tap = gesture {
|
||||
if let (item, _, _, _) = self.item {
|
||||
var media: Media?
|
||||
var media: EngineRawMedia?
|
||||
for value in item.message.media {
|
||||
if let image = value as? TelegramMediaImage {
|
||||
media = image
|
||||
|
|
@ -150,8 +149,8 @@ private final class VisualMediaItemNode: ASDisplayNode {
|
|||
guard let message = self.item?.0.message else {
|
||||
return
|
||||
}
|
||||
|
||||
var media: Media?
|
||||
|
||||
var media: EngineRawMedia?
|
||||
for value in message.media {
|
||||
if let image = value as? TelegramMediaImage {
|
||||
media = image
|
||||
|
|
@ -183,7 +182,7 @@ private final class VisualMediaItemNode: ASDisplayNode {
|
|||
return
|
||||
}
|
||||
self.theme = theme
|
||||
var media: Media?
|
||||
var media: EngineRawMedia?
|
||||
for value in item.message.media {
|
||||
if let image = value as? TelegramMediaImage {
|
||||
media = image
|
||||
|
|
@ -417,11 +416,11 @@ private final class VisualMediaItemNode: ASDisplayNode {
|
|||
}
|
||||
|
||||
private final class VisualMediaItem {
|
||||
let message: Message
|
||||
let message: EngineRawMessage
|
||||
let dimensions: CGSize
|
||||
let aspectRatio: CGFloat
|
||||
|
||||
init(message: Message) {
|
||||
|
||||
init(message: EngineRawMessage) {
|
||||
self.message = message
|
||||
|
||||
var aspectRatio: CGFloat = 1.0
|
||||
|
|
@ -488,7 +487,7 @@ private final class FloatingHeaderNode: ASDisplayNode {
|
|||
}
|
||||
}
|
||||
|
||||
private func tagMaskForType(_ type: PeerInfoGifPaneNode.ContentType) -> MessageTags {
|
||||
private func tagMaskForType(_ type: PeerInfoGifPaneNode.ContentType) -> EngineMessage.Tags {
|
||||
switch type {
|
||||
case .photoOrVideo:
|
||||
return .photoOrVideo
|
||||
|
|
@ -616,7 +615,7 @@ final class PeerInfoGifPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScrollViewDe
|
|||
}
|
||||
|
||||
private let context: AccountContext
|
||||
private let peerId: PeerId
|
||||
private let peerId: EnginePeer.Id
|
||||
private let chatLocation: ChatLocation
|
||||
private let chatLocationContextHolder: Atomic<ChatLocationContextHolder?>
|
||||
private let chatControllerInteraction: ChatControllerInteraction
|
||||
|
|
@ -651,7 +650,7 @@ final class PeerInfoGifPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScrollViewDe
|
|||
private var visibleMediaItems: [UInt32: VisualMediaItemNode] = [:]
|
||||
|
||||
private var numberOfItemsToRequest: Int = 50
|
||||
private var currentView: MessageHistoryView?
|
||||
private var currentView: EngineRawMessageHistoryView?
|
||||
private var isRequestingView: Bool = false
|
||||
private var isFirstHistoryView: Bool = true
|
||||
|
||||
|
|
@ -667,7 +666,7 @@ final class PeerInfoGifPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScrollViewDe
|
|||
return 0.0
|
||||
}
|
||||
|
||||
init(context: AccountContext, chatControllerInteraction: ChatControllerInteraction, peerId: PeerId, chatLocation: ChatLocation, chatLocationContextHolder: Atomic<ChatLocationContextHolder?>, contentType: ContentType) {
|
||||
init(context: AccountContext, chatControllerInteraction: ChatControllerInteraction, peerId: EnginePeer.Id, chatLocation: ChatLocation, chatLocationContextHolder: Atomic<ChatLocationContextHolder?>, contentType: ContentType) {
|
||||
self.context = context
|
||||
self.peerId = peerId
|
||||
self.chatLocation = chatLocation
|
||||
|
|
@ -714,7 +713,7 @@ final class PeerInfoGifPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScrollViewDe
|
|||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
var hiddenMedia: [MessageId: [Media]] = [:]
|
||||
var hiddenMedia: [EngineMessage.Id: [EngineRawMedia]] = [:]
|
||||
for id in ids {
|
||||
if case let .chat(accountId, messageId, media) = id, accountId == strongSelf.context.account.id {
|
||||
hiddenMedia[messageId] = [media]
|
||||
|
|
@ -781,7 +780,7 @@ final class PeerInfoGifPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScrollViewDe
|
|||
}))
|
||||
}
|
||||
|
||||
private func updateHistory(view: MessageHistoryView, updateType: ViewUpdateType) {
|
||||
private func updateHistory(view: EngineRawMessageHistoryView, updateType: EngineViewUpdateType) {
|
||||
self.currentView = view
|
||||
|
||||
switch updateType {
|
||||
|
|
@ -988,7 +987,7 @@ final class PeerInfoGifPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScrollViewDe
|
|||
|
||||
let (minVisibleIndex, maxVisibleIndex) = itemsLayout.visibleRange(rect: visibleRect)
|
||||
|
||||
var headerItem: Message?
|
||||
var headerItem: EngineRawMessage?
|
||||
|
||||
var validIds = Set<UInt32>()
|
||||
if minVisibleIndex <= maxVisibleIndex {
|
||||
|
|
|
|||
|
|
@ -1936,7 +1936,7 @@ func peerInfoScreenData(
|
|||
return (nil, value)
|
||||
}
|
||||
} else {
|
||||
return context.peerChannelMemberCategoriesContextsManager.recentOnlineSmall(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId)
|
||||
return context.peerChannelMemberCategoriesContextsManager.recentOnlineSmall(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId)
|
||||
|> map { value -> (total: Int32?, recent: Int32?) in
|
||||
return (value.total, value.recent)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ private final class PeerInfoMembersContextImpl {
|
|||
self.pushState()
|
||||
|
||||
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
let (disposable, control) = context.peerChannelMemberCategoriesContextsManager.recent(engine: context.engine, postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId, requestUpdate: true, updated: { [weak self] state in
|
||||
let (disposable, control) = context.peerChannelMemberCategoriesContextsManager.recent(engine: context.engine, accountPeerId: context.account.peerId, peerId: peerId, requestUpdate: true, updated: { [weak self] state in
|
||||
queue.async {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import UIKit
|
|||
import Display
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import PresentationDataUtils
|
||||
import AccountContext
|
||||
|
|
@ -56,7 +55,7 @@ private final class VisualMediaItemInteraction {
|
|||
let openItemContextActions: (EngineStoryItem, ASDisplayNode, CGRect, ContextGesture?) -> Void
|
||||
let toggleSelection: (Int32, Bool) -> Void
|
||||
|
||||
var hiddenStories = Set<StoryId>()
|
||||
var hiddenStories = Set<EngineStoryId>()
|
||||
var selectedIds: Set<Int32>?
|
||||
|
||||
init(
|
||||
|
|
@ -71,7 +70,7 @@ private final class VisualMediaItemInteraction {
|
|||
}
|
||||
|
||||
private final class VisualMediaHoleAnchor: SparseItemGrid.HoleAnchor {
|
||||
let storyId: StoryId
|
||||
let storyId: EngineStoryId
|
||||
override var id: AnyHashable {
|
||||
return AnyHashable(self.storyId)
|
||||
}
|
||||
|
|
@ -86,7 +85,7 @@ private final class VisualMediaHoleAnchor: SparseItemGrid.HoleAnchor {
|
|||
return self.localMonthTimestamp
|
||||
}
|
||||
|
||||
init(index: Int, storyId: StoryId, localMonthTimestamp: Int32) {
|
||||
init(index: Int, storyId: EngineStoryId, localMonthTimestamp: Int32) {
|
||||
self.indexValue = index
|
||||
self.storyId = storyId
|
||||
self.localMonthTimestamp = localMonthTimestamp
|
||||
|
|
@ -103,7 +102,7 @@ private final class VisualMediaItem: SparseItemGrid.Item {
|
|||
}
|
||||
let localMonthTimestamp: Int32
|
||||
let peer: PeerReference
|
||||
let storyId: StoryId
|
||||
let storyId: EngineStoryId
|
||||
let story: EngineStoryItem
|
||||
let authorPeer: EnginePeer?
|
||||
let isPinned: Bool
|
||||
|
|
@ -122,7 +121,7 @@ private final class VisualMediaItem: SparseItemGrid.Item {
|
|||
return VisualMediaHoleAnchor(index: self.index, storyId: self.storyId, localMonthTimestamp: self.localMonthTimestamp)
|
||||
}
|
||||
|
||||
init(index: Int, peer: PeerReference, storyId: StoryId, story: EngineStoryItem, authorPeer: EnginePeer?, isPinned: Bool, localMonthTimestamp: Int32, isReorderable: Bool, isEnabled: Bool) {
|
||||
init(index: Int, peer: PeerReference, storyId: EngineStoryId, story: EngineStoryItem, authorPeer: EnginePeer?, isPinned: Bool, localMonthTimestamp: Int32, isReorderable: Bool, isEnabled: Bool) {
|
||||
self.indexValue = index
|
||||
self.peer = peer
|
||||
self.storyId = storyId
|
||||
|
|
@ -855,7 +854,7 @@ private final class ItemLayer: CALayer, SparseItemGridLayer {
|
|||
binding.bindLayers(items: [item], layers: [displayItem], size: size, insets: insets, synchronous: .none)
|
||||
} else {
|
||||
if let layer = displayItem.layer as? ItemLayer {
|
||||
var selectedMedia: Media?
|
||||
var selectedMedia: EngineRawMedia?
|
||||
if let image = item.story.media._asMedia() as? TelegramMediaImage {
|
||||
selectedMedia = image
|
||||
} else if let file = item.story.media._asMedia() as? TelegramMediaFile {
|
||||
|
|
@ -1124,7 +1123,7 @@ private final class SparseItemGridBindingImpl: SparseItemGridBinding {
|
|||
var updateShimmerLayersImpl: ((SparseItemGridDisplayItem) -> Void)?
|
||||
var reorderIfPossibleImpl: ((SparseItemGrid.Item, Int) -> Void)?
|
||||
|
||||
var revealedSpoilerMessageIds = Set<MessageId>()
|
||||
var revealedSpoilerMessageIds = Set<EngineMessage.Id>()
|
||||
|
||||
private var shimmerImages: [CGFloat: UIImage] = [:]
|
||||
|
||||
|
|
@ -1211,7 +1210,7 @@ private final class SparseItemGridBindingImpl: SparseItemGridBinding {
|
|||
let hasSpoiler = false
|
||||
layer.updateHasSpoiler(hasSpoiler: hasSpoiler)
|
||||
|
||||
var selectedMedia: Media?
|
||||
var selectedMedia: EngineRawMedia?
|
||||
if let image = story.media._asMedia() as? TelegramMediaImage {
|
||||
selectedMedia = image
|
||||
} else if let file = story.media._asMedia() as? TelegramMediaFile {
|
||||
|
|
@ -1322,7 +1321,7 @@ private final class SparseItemGridBindingImpl: SparseItemGridBinding {
|
|||
}
|
||||
}
|
||||
|
||||
func updateLayerData(story: EngineStoryItem, item: VisualMediaItem, selectedMedia: Media, layer: ItemLayer, synchronous: SparseItemGrid.Synchronous) {
|
||||
func updateLayerData(story: EngineStoryItem, item: VisualMediaItem, selectedMedia: EngineRawMedia, layer: ItemLayer, synchronous: SparseItemGrid.Synchronous) {
|
||||
var viewCount: Int32?
|
||||
if let value = story.views?.seenCount {
|
||||
viewCount = Int32(value)
|
||||
|
|
@ -1587,7 +1586,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr
|
|||
private let directMediaImageCache: DirectMediaImageCache
|
||||
private var items: SparseItemGrid.Items?
|
||||
private var pinnedIds: Set<Int32> = Set()
|
||||
private var reorderedIds: [StoryId]?
|
||||
private var reorderedIds: [EngineStoryId]?
|
||||
private var itemCount: Int?
|
||||
private var didUpdateItemsOnce: Bool = false
|
||||
private var itemTabId: AnyHashable?
|
||||
|
|
@ -2556,7 +2555,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr
|
|||
if let story = folderPreview.item {
|
||||
var imageSignal: Signal<UIImage?, NoError>?
|
||||
|
||||
var selectedMedia: Media?
|
||||
var selectedMedia: EngineRawMedia?
|
||||
if let image = story.media._asMedia() as? TelegramMediaImage {
|
||||
selectedMedia = image
|
||||
} else if let file = story.media._asMedia() as? TelegramMediaFile {
|
||||
|
|
@ -2771,7 +2770,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr
|
|||
}
|
||||
|
||||
let shareController = self.context.sharedContext.makeShareController(context: self.context, params: ShareControllerParams(
|
||||
subject: .media(.story(peer: peerReference, id: item.id, media: TelegramMediaStory(storyId: StoryId(peerId: peer.id, id: item.id), isMention: false)), nil),
|
||||
subject: .media(.story(peer: peerReference, id: item.id, media: TelegramMediaStory(storyId: EngineStoryId(peerId: peer.id, id: item.id), isMention: false)), nil),
|
||||
externalShare: false
|
||||
))
|
||||
self.parentController?.present(shareController, in: .window(.root))
|
||||
|
|
@ -3038,7 +3037,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr
|
|||
if let reorderedIds = self.reorderedIds {
|
||||
var fixedStateItems: [StoryListContext.State.Item] = []
|
||||
|
||||
var seenIds = Set<StoryId>()
|
||||
var seenIds = Set<EngineStoryId>()
|
||||
for id in reorderedIds {
|
||||
if let index = stateItems.firstIndex(where: { $0.id == id }) {
|
||||
seenIds.insert(id)
|
||||
|
|
@ -3100,7 +3099,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr
|
|||
))
|
||||
}
|
||||
if mappedItems.count < state.totalCount, let lastItem = state.items.last, let _ = state.loadMoreToken {
|
||||
mappedHoles.append(VisualMediaHoleAnchor(index: mappedItems.count, storyId: StoryId(peerId: context.account.peerId, id: Int32.max), localMonthTimestamp: Month(localTimestamp: lastItem.storyItem.timestamp + timezoneOffset).packedValue))
|
||||
mappedHoles.append(VisualMediaHoleAnchor(index: mappedItems.count, storyId: EngineStoryId(peerId: context.account.peerId, id: Int32.max), localMonthTimestamp: Month(localTimestamp: lastItem.storyItem.timestamp + timezoneOffset).packedValue))
|
||||
}
|
||||
totalCount = state.totalCount
|
||||
totalCount = max(mappedItems.count, totalCount)
|
||||
|
|
@ -3262,7 +3261,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr
|
|||
return
|
||||
}
|
||||
|
||||
var ids = items.items.compactMap { item -> StoryId? in
|
||||
var ids = items.items.compactMap { item -> EngineStoryId? in
|
||||
return (item as? VisualMediaItem)?.storyId
|
||||
}
|
||||
|
||||
|
|
@ -3605,9 +3604,9 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr
|
|||
controller?.dismissAnimated()
|
||||
}
|
||||
|
||||
var mappedMedia: [Media] = []
|
||||
var mappedMedia: [EngineRawMedia] = []
|
||||
if let items = self.items {
|
||||
mappedMedia = items.items.compactMap { item -> Media? in
|
||||
mappedMedia = items.items.compactMap { item -> EngineRawMedia? in
|
||||
guard let item = item as? VisualMediaItem else {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -5223,9 +5222,9 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr
|
|||
return
|
||||
}
|
||||
|
||||
var mappedMedia: [Media] = []
|
||||
var mappedMedia: [EngineRawMedia] = []
|
||||
if let items = self.items {
|
||||
mappedMedia = items.items.compactMap { item -> Media? in
|
||||
mappedMedia = items.items.compactMap { item -> EngineRawMedia? in
|
||||
guard let item = item as? VisualMediaItem else {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -5321,7 +5320,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr
|
|||
self.reorderedIds = nil
|
||||
if case .botPreview = self.scope, let listSource = self.listSource as? BotPreviewStoryListContext {
|
||||
if let items = self.items {
|
||||
var reorderedMedia: [Media] = []
|
||||
var reorderedMedia: [EngineRawMedia] = []
|
||||
|
||||
for id in reorderedIds {
|
||||
if let item = items.items.first(where: { ($0 as? VisualMediaItem)?.storyId == id }) as? VisualMediaItem {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import Display
|
|||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
import ItemListUI
|
||||
|
|
@ -20,9 +19,14 @@ public final class RankChatPreviewItem: ListViewItem, ItemListItem, ListItemComp
|
|||
if lhs.text != rhs.text {
|
||||
return false
|
||||
}
|
||||
if areMediaArraysEqual(lhs.media, rhs.media) {
|
||||
if lhs.media.count != rhs.media.count {
|
||||
return false
|
||||
}
|
||||
for i in 0 ..< lhs.media.count {
|
||||
if !lhs.media[i].isEqual(to: rhs.media[i]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if lhs.rank != rhs.rank {
|
||||
return false
|
||||
}
|
||||
|
|
@ -32,11 +36,11 @@ public final class RankChatPreviewItem: ListViewItem, ItemListItem, ListItemComp
|
|||
let peer: EnginePeer
|
||||
let text: String
|
||||
let entities: TextEntitiesMessageAttribute?
|
||||
let media: [Media]
|
||||
let media: [EngineRawMedia]
|
||||
let rank: String
|
||||
let rankRole: ChatRankInfoScreenRole
|
||||
|
||||
public init(peer: EnginePeer, text: String, entities: TextEntitiesMessageAttribute?, media: [Media], rank: String, rankRole: ChatRankInfoScreenRole) {
|
||||
public init(peer: EnginePeer, text: String, entities: TextEntitiesMessageAttribute?, media: [EngineRawMedia], rank: String, rankRole: ChatRankInfoScreenRole) {
|
||||
self.peer = peer
|
||||
self.text = text
|
||||
self.entities = entities
|
||||
|
|
@ -234,29 +238,29 @@ final class RankChatPreviewItemNode: ListViewItemNode {
|
|||
for messageItem in item.messageItems.reversed() {
|
||||
var userPeer = messageItem.peer._asPeer()
|
||||
|
||||
let updatedId = PeerId.Id._internalFromInt64Value(userPeer.id.id._internalGetInt64Value() - 7)
|
||||
let authorPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: updatedId)
|
||||
let groupPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(0))
|
||||
let groupPeer = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(0)), accessHash: nil, title: "", username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, emojiStatus: nil, approximateBoostLevel: nil, subscriptionUntilDate: nil, verificationIconFileId: nil, sendPaidMessageStars: nil, linkedMonoforumId: nil)
|
||||
let updatedId = EnginePeer.Id.Id._internalFromInt64Value(userPeer.id.id._internalGetInt64Value() - 7)
|
||||
let authorPeerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: updatedId)
|
||||
let groupPeerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudChannel, id: EnginePeer.Id.Id._internalFromInt64Value(0))
|
||||
let groupPeer = TelegramChannel(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudChannel, id: EnginePeer.Id.Id._internalFromInt64Value(0)), accessHash: nil, title: "", username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, emojiStatus: nil, approximateBoostLevel: nil, subscriptionUntilDate: nil, verificationIconFileId: nil, sendPaidMessageStars: nil, linkedMonoforumId: nil)
|
||||
|
||||
|
||||
if let user = userPeer as? TelegramUser {
|
||||
userPeer = TelegramUser(id: authorPeerId, accessHash: user.accessHash, firstName: user.firstName, lastName: user.lastName, username: "", phone: user.phone, photo: user.photo, botInfo: user.botInfo, restrictionInfo: user.restrictionInfo, flags: user.flags, emojiStatus: user.emojiStatus, usernames: user.usernames, storiesHidden: user.storiesHidden, nameColor: user.nameColor, backgroundEmojiId: user.backgroundEmojiId, profileColor: user.profileColor, profileBackgroundEmojiId: user.profileBackgroundEmojiId, subscriberCount: user.subscriberCount, verificationIconFileId: user.verificationIconFileId)
|
||||
}
|
||||
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
let messages = SimpleDictionary<MessageId, Message>()
|
||||
var peers = EngineSimpleDictionary<EnginePeer.Id, EngineRawPeer>()
|
||||
let messages = EngineSimpleDictionary<EngineMessage.Id, EngineRawMessage>()
|
||||
|
||||
peers[authorPeerId] = userPeer
|
||||
peers[groupPeerId] = groupPeer
|
||||
|
||||
let media = messageItem.media
|
||||
var attributes: [MessageAttribute] = []
|
||||
var attributes: [EngineMessage.Attribute] = []
|
||||
if let entities = messageItem.entities {
|
||||
attributes.append(entities)
|
||||
}
|
||||
|
||||
let message = Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: groupPeerId, namespace: Namespaces.Message.Local, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 20460, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[authorPeerId], text: messageItem.text, attributes: attributes, media: media, peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message = EngineRawMessage(stableId: 1, stableVersion: 0, id: EngineMessage.Id(peerId: groupPeerId, namespace: Namespaces.Message.Local, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 20460, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[authorPeerId], text: messageItem.text, attributes: attributes, media: media, peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
items.append(item.context.sharedContext.makeChatMessagePreviewItem(context: item.context, messages: [message], theme: item.componentTheme, strings: item.strings, wallpaper: item.wallpaper, fontSize: item.fontSize, chatBubbleCorners: item.chatBubbleCorners, dateTimeFormat: item.dateTimeFormat, nameOrder: item.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: currentBackgroundNode, availableReactions: nil, accountPeer: nil, isCentered: item.containerWidth != nil, isPreview: true, isStandalone: false, rank: messageItem.rank, rankRole: messageItem.rankRole))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
import Foundation
|
||||
import UIKit
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import AccountContext
|
||||
|
||||
final class AutomaticBusinessMessageSetupChatContents: ChatCustomContentsProtocol {
|
||||
private final class PendingMessageContext {
|
||||
let disposable = MetaDisposable()
|
||||
var message: Message?
|
||||
var message: EngineRawMessage?
|
||||
|
||||
init() {
|
||||
}
|
||||
|
|
@ -21,13 +20,13 @@ final class AutomaticBusinessMessageSetupChatContents: ChatCustomContentsProtoco
|
|||
private var shortcut: String
|
||||
private var shortcutId: Int32?
|
||||
|
||||
private(set) var mergedHistoryView: MessageHistoryView?
|
||||
private var sourceHistoryView: MessageHistoryView?
|
||||
|
||||
private(set) var mergedHistoryView: EngineRawMessageHistoryView?
|
||||
private var sourceHistoryView: EngineRawMessageHistoryView?
|
||||
|
||||
private var pendingMessages: [PendingMessageContext] = []
|
||||
private var historyViewDisposable: Disposable?
|
||||
private var pendingHistoryViewDisposable: Disposable?
|
||||
let historyViewStream = ValuePipe<(MessageHistoryView, ViewUpdateType)>()
|
||||
let historyViewStream = ValuePipe<(EngineRawMessageHistoryView, EngineViewUpdateType)>()
|
||||
private var nextUpdateIsHoleFill: Bool = false
|
||||
|
||||
init(queue: Queue, context: AccountContext, shortcut: String, shortcutId: Int32?) {
|
||||
|
|
@ -98,17 +97,17 @@ final class AutomaticBusinessMessageSetupChatContents: ChatCustomContentsProtoco
|
|||
}
|
||||
}
|
||||
|
||||
private func updateHistoryView(updateType: ViewUpdateType) {
|
||||
private func updateHistoryView(updateType: EngineViewUpdateType) {
|
||||
var entries = self.sourceHistoryView?.entries ?? []
|
||||
for pendingMessage in self.pendingMessages {
|
||||
if let message = pendingMessage.message {
|
||||
if !entries.contains(where: { $0.message.stableId == message.stableId }) {
|
||||
entries.append(MessageHistoryEntry(
|
||||
entries.append(EngineRawMessageHistoryEntry(
|
||||
message: message,
|
||||
isRead: true,
|
||||
location: nil,
|
||||
monthLocation: nil,
|
||||
attributes: MutableMessageHistoryEntryAttributes(
|
||||
attributes: EngineRawMutableMessageHistoryEntryAttributes(
|
||||
authorIsContact: false
|
||||
)
|
||||
))
|
||||
|
|
@ -116,8 +115,8 @@ final class AutomaticBusinessMessageSetupChatContents: ChatCustomContentsProtoco
|
|||
}
|
||||
}
|
||||
entries.sort(by: { $0.message.index < $1.message.index })
|
||||
|
||||
let mergedHistoryView = MessageHistoryView(tag: nil, namespaces: .just(Namespaces.Message.allQuickReply), entries: entries, holeEarlier: false, holeLater: false, isLoading: false)
|
||||
|
||||
let mergedHistoryView = EngineRawMessageHistoryView(tag: nil, namespaces: .just(Namespaces.Message.allQuickReply), entries: entries, holeEarlier: false, holeLater: false, isLoading: false)
|
||||
self.mergedHistoryView = mergedHistoryView
|
||||
|
||||
self.historyViewStream.putNext((mergedHistoryView, updateType))
|
||||
|
|
@ -184,7 +183,7 @@ final class AutomaticBusinessMessageSetupChatContents: ChatCustomContentsProtoco
|
|||
|
||||
var kind: ChatCustomContentsKind
|
||||
|
||||
var historyView: Signal<(MessageHistoryView, ViewUpdateType), NoError> {
|
||||
var historyView: Signal<(EngineRawMessageHistoryView, EngineViewUpdateType), NoError> {
|
||||
return self.impl.signalWith({ impl, subscriber in
|
||||
if let mergedHistoryView = impl.mergedHistoryView {
|
||||
subscriber.putNext((mergedHistoryView, .Initial))
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import Foundation
|
||||
import UIKit
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import AccountContext
|
||||
|
||||
|
|
@ -30,8 +29,8 @@ final class BusinessLinkChatContents: ChatCustomContentsProtocol {
|
|||
|
||||
var kind: ChatCustomContentsKind
|
||||
|
||||
var historyView: Signal<(MessageHistoryView, ViewUpdateType), NoError> {
|
||||
let view = MessageHistoryView(tag: nil, namespaces: .just(Namespaces.Message.allQuickReply), entries: [], holeEarlier: false, holeLater: false, isLoading: false)
|
||||
var historyView: Signal<(EngineRawMessageHistoryView, EngineViewUpdateType), NoError> {
|
||||
let view = EngineRawMessageHistoryView(tag: nil, namespaces: .just(Namespaces.Message.allQuickReply), entries: [], holeEarlier: false, holeLater: false, isLoading: false)
|
||||
|
||||
return .single((view, .Initial))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import UIKit
|
|||
import Display
|
||||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
|
|
@ -429,15 +428,11 @@ final class BusinessIntroSetupScreenComponent: Component {
|
|||
)
|
||||
}
|
||||
|
||||
let installedPackIds = context.account.postbox.combinedView(keys: [.itemCollectionInfos(namespaces: [Namespaces.ItemCollection.CloudStickerPacks])])
|
||||
|> map { view -> Set<ItemCollectionId> in
|
||||
var installedPacks = Set<ItemCollectionId>()
|
||||
if let stickerPacksView = view.views[.itemCollectionInfos(namespaces: [Namespaces.ItemCollection.CloudStickerPacks])] as? ItemCollectionInfosView {
|
||||
if let packsEntries = stickerPacksView.entriesByNamespace[Namespaces.ItemCollection.CloudStickerPacks] {
|
||||
for entry in packsEntries {
|
||||
installedPacks.insert(entry.id)
|
||||
}
|
||||
}
|
||||
let installedPackIds = context.engine.data.subscribe(TelegramEngine.EngineData.Item.ItemCollections.InstalledPackInfos(namespace: Namespaces.ItemCollection.CloudStickerPacks))
|
||||
|> map { entries -> Set<EngineItemCollectionId> in
|
||||
var installedPacks = Set<EngineItemCollectionId>()
|
||||
for entry in entries {
|
||||
installedPacks.insert(entry.id)
|
||||
}
|
||||
return installedPacks
|
||||
}
|
||||
|
|
@ -473,7 +468,7 @@ final class BusinessIntroSetupScreenComponent: Component {
|
|||
|
||||
var items: [EmojiPagerContentComponent.Item] = []
|
||||
|
||||
var existingIds = Set<MediaId>()
|
||||
var existingIds = Set<EngineMedia.Id>()
|
||||
for (_, entry) in foundItems {
|
||||
let itemFile = entry.file
|
||||
|
||||
|
|
@ -565,7 +560,7 @@ final class BusinessIntroSetupScreenComponent: Component {
|
|||
|> mapToSignal { files -> Signal<(items: [EmojiPagerContentComponent.ItemGroup], isFinalResult: Bool), NoError> in
|
||||
var items: [EmojiPagerContentComponent.Item] = []
|
||||
|
||||
var existingIds = Set<MediaId>()
|
||||
var existingIds = Set<EngineMedia.Id>()
|
||||
for item in files.items {
|
||||
let itemFile = item.file
|
||||
if existingIds.contains(itemFile.fileId) {
|
||||
|
|
@ -1020,7 +1015,7 @@ final class BusinessIntroSetupScreenComponent: Component {
|
|||
stickerSelectionControl = ComponentView()
|
||||
self.stickerSelectionControl = stickerSelectionControl
|
||||
}
|
||||
var selectedItems = Set<MediaId>()
|
||||
var selectedItems = Set<EngineMedia.Id>()
|
||||
if let stickerFile = self.stickerFile {
|
||||
selectedItems.insert(stickerFile.fileId)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import Display
|
|||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
import ItemListUI
|
||||
|
|
@ -215,32 +214,32 @@ final class PeerNameColorChatPreviewItemNode: ListViewItemNode {
|
|||
var insets: UIEdgeInsets
|
||||
let separatorHeight = UIScreenPixel
|
||||
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(1))
|
||||
let peerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudChannel, id: EnginePeer.Id.Id._internalFromInt64Value(1))
|
||||
|
||||
var items: [ListViewItem] = []
|
||||
for messageItem in item.messageItems.reversed() {
|
||||
let authorPeerId = messageItem.peerId
|
||||
let replyAuthorPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(10))
|
||||
let replyAuthorPeerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(10))
|
||||
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
var messages = SimpleDictionary<MessageId, Message>()
|
||||
var peers = EngineSimpleDictionary<EnginePeer.Id, EngineRawPeer>()
|
||||
var messages = EngineSimpleDictionary<EngineMessage.Id, EngineRawMessage>()
|
||||
|
||||
peers[authorPeerId] = TelegramUser(id: authorPeerId, accessHash: nil, firstName: messageItem.author, lastName: "", username: nil, phone: nil, photo: messageItem.photo, botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: messageItem.nameColor, backgroundEmojiId: messageItem.backgroundEmojiId, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
|
||||
|
||||
let replyMessageId = MessageId(peerId: peerId, namespace: 0, id: 3)
|
||||
let replyMessageId = EngineMessage.Id(peerId: peerId, namespace: 0, id: 3)
|
||||
if let (replyAuthor, text, replyColor) = messageItem.reply {
|
||||
peers[replyAuthorPeerId] = TelegramUser(id: authorPeerId, accessHash: nil, firstName: replyAuthor, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: replyColor, backgroundEmojiId: messageItem.backgroundEmojiId, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
|
||||
messages[replyMessageId] = Message(stableId: 3, stableVersion: 0, id: replyMessageId, globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[replyAuthorPeerId], text: text, attributes: [], media: [], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
messages[replyMessageId] = EngineRawMessage(stableId: 3, stableVersion: 0, id: replyMessageId, globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[replyAuthorPeerId], text: text, attributes: [], media: [], peers: peers, associatedMessages: EngineSimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
}
|
||||
|
||||
var media: [Media] = []
|
||||
var media: [EngineRawMedia] = []
|
||||
if let (site, title, text) = messageItem.linkPreview, params.width > 320.0 {
|
||||
media.append(TelegramMediaWebpage(webpageId: MediaId(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: "", displayUrl: "", hash: 0, type: nil, websiteName: site, title: title, text: text, embedUrl: nil, embedType: nil, embedSize: nil, duration: nil, author: nil, isMediaLargeByDefault: nil, imageIsVideoCover: false, image: nil, file: nil, story: nil, attributes: [], instantPage: nil))))
|
||||
media.append(TelegramMediaWebpage(webpageId: EngineMedia.Id(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: "", displayUrl: "", hash: 0, type: nil, websiteName: site, title: title, text: text, embedUrl: nil, embedType: nil, embedSize: nil, duration: nil, author: nil, isMediaLargeByDefault: nil, imageIsVideoCover: false, image: nil, file: nil, story: nil, attributes: [], instantPage: nil))))
|
||||
}
|
||||
|
||||
let message = Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: messageItem.outgoing ? [] : [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[authorPeerId], text: messageItem.text, attributes: messageItem.reply != nil ? [ReplyMessageAttribute(messageId: replyMessageId, threadMessageId: nil, quote: nil, isQuote: false, innerSubject: nil)] : [], media: media, peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message = EngineRawMessage(stableId: 1, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: messageItem.outgoing ? [] : [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[authorPeerId], text: messageItem.text, attributes: messageItem.reply != nil ? [ReplyMessageAttribute(messageId: replyMessageId, threadMessageId: nil, quote: nil, isQuote: false, innerSubject: nil)] : [], media: media, peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
items.append(item.context.sharedContext.makeChatMessagePreviewItem(context: item.context, messages: [message], theme: item.componentTheme, strings: item.strings, wallpaper: item.wallpaper, fontSize: item.fontSize, chatBubbleCorners: item.chatBubbleCorners, dateTimeFormat: item.dateTimeFormat, nameOrder: item.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: currentBackgroundNode, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import Display
|
|||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
import ItemListUI
|
||||
|
|
@ -27,10 +26,10 @@ class ReactionChatPreviewItem: ListViewItem, ItemListItem {
|
|||
let nameDisplayOrder: PresentationPersonNameOrder
|
||||
let availableReactions: AvailableReactions?
|
||||
let reaction: MessageReaction.Reaction?
|
||||
let accountPeer: Peer?
|
||||
let accountPeer: EngineRawPeer?
|
||||
let toggleReaction: () -> Void
|
||||
|
||||
init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, systemStyle: ItemListSystemStyle = .legacy, sectionId: ItemListSectionId, fontSize: PresentationFontSize, chatBubbleCorners: PresentationChatBubbleCorners, wallpaper: TelegramWallpaper, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, availableReactions: AvailableReactions?, reaction: MessageReaction.Reaction?, accountPeer: Peer?, toggleReaction: @escaping () -> Void) {
|
||||
init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, systemStyle: ItemListSystemStyle = .legacy, sectionId: ItemListSectionId, fontSize: PresentationFontSize, chatBubbleCorners: PresentationChatBubbleCorners, wallpaper: TelegramWallpaper, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, availableReactions: AvailableReactions?, reaction: MessageReaction.Reaction?, accountPeer: EngineRawPeer?, toggleReaction: @escaping () -> Void) {
|
||||
self.context = context
|
||||
self.theme = theme
|
||||
self.strings = strings
|
||||
|
|
@ -301,17 +300,17 @@ class ReactionChatPreviewItemNode: ListViewItemNode {
|
|||
let separatorHeight = UIScreenPixel
|
||||
let separatorRightInset: CGFloat = item.systemStyle == .glass ? 16.0 : 0.0
|
||||
|
||||
let userPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(2))
|
||||
let userPeerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(2))
|
||||
let chatPeerId = userPeerId
|
||||
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
let messages = SimpleDictionary<MessageId, Message>()
|
||||
var peers = EngineSimpleDictionary<EnginePeer.Id, EngineRawPeer>()
|
||||
let messages = EngineSimpleDictionary<EngineMessage.Id, EngineRawMessage>()
|
||||
|
||||
peers[userPeerId] = TelegramUser(id: userPeerId, accessHash: nil, firstName: item.strings.Settings_QuickReactionSetup_DemoMessageAuthor, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: .preset(.blue), backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
|
||||
let messageText = item.strings.Settings_QuickReactionSetup_DemoMessageText
|
||||
|
||||
var attributes: [MessageAttribute] = []
|
||||
var attributes: [EngineMessage.Attribute] = []
|
||||
if let reaction = item.reaction {
|
||||
var recentPeers: [ReactionsMessageAttribute.RecentPeer] = []
|
||||
if let accountPeer = item.accountPeer {
|
||||
|
|
@ -321,7 +320,7 @@ class ReactionChatPreviewItemNode: ListViewItemNode {
|
|||
attributes.append(ReactionsMessageAttribute(canViewList: false, isTags: false, reactions: [MessageReaction(value: reaction, count: 1, chosenOrder: 0)], recentPeers: recentPeers, topPeers: []))
|
||||
}
|
||||
|
||||
let messageItem = item.context.sharedContext.makeChatMessagePreviewItem(context: item.context, messages: [Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: chatPeerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[userPeerId], text: messageText, attributes: attributes, media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])], theme: item.theme, strings: item.strings, wallpaper: item.wallpaper, fontSize: item.fontSize, chatBubbleCorners: item.chatBubbleCorners, dateTimeFormat: item.dateTimeFormat, nameOrder: item.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: currentBackgroundNode, availableReactions: item.availableReactions, accountPeer: item.accountPeer, isCentered: true, isPreview: true, isStandalone: false, rank: nil, rankRole: nil)
|
||||
let messageItem = item.context.sharedContext.makeChatMessagePreviewItem(context: item.context, messages: [EngineRawMessage(stableId: 1, stableVersion: 0, id: EngineMessage.Id(peerId: chatPeerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[userPeerId], text: messageText, attributes: attributes, media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])], theme: item.theme, strings: item.strings, wallpaper: item.wallpaper, fontSize: item.fontSize, chatBubbleCorners: item.chatBubbleCorners, dateTimeFormat: item.dateTimeFormat, nameOrder: item.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: currentBackgroundNode, availableReactions: item.availableReactions, accountPeer: item.accountPeer, isCentered: true, isPreview: true, isStandalone: false, rank: nil, rankRole: nil)
|
||||
|
||||
var node: ListViewItemNode?
|
||||
if let current = currentNode {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import AsyncDisplayKit
|
||||
import TelegramCore
|
||||
|
|
@ -895,7 +894,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, ASScrollViewDelegate
|
|||
context: self.context,
|
||||
chatListLocation: .chatList(groupId: .root),
|
||||
filterData: nil,
|
||||
index: .chatList(ChatListIndex(pinningIndex: isPinned ? 0 : nil, messageIndex: MessageIndex(id: MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: 0), timestamp: timestamp))),
|
||||
index: .chatList(EngineChatListIndex(pinningIndex: isPinned ? 0 : nil, messageIndex: EngineMessage.Index(id: EngineMessage.Id(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: 0), timestamp: timestamp))),
|
||||
content: .peer(ChatListItemContent.PeerData(
|
||||
messages: [
|
||||
EngineMessage(
|
||||
|
|
@ -961,11 +960,11 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, ASScrollViewDelegate
|
|||
}
|
||||
|
||||
let selfPeer: EnginePeer = .user(TelegramUser(id: self.context.account.peerId, accessHash: nil, firstName: nil, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer1: EnginePeer = .user(TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer2: EnginePeer = .user(TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(2)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer3: EnginePeer = .channel(TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(3)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, emojiStatus: nil, approximateBoostLevel: nil, subscriptionUntilDate: nil, verificationIconFileId: nil, sendPaidMessageStars: nil, linkedMonoforumId: nil))
|
||||
let peer3Author: EnginePeer = .user(TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer4: EnginePeer = .user(TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer1: EnginePeer = .user(TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(1)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer2: EnginePeer = .user(TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(2)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer3: EnginePeer = .channel(TelegramChannel(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudChannel, id: EnginePeer.Id.Id._internalFromInt64Value(3)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, emojiStatus: nil, approximateBoostLevel: nil, subscriptionUntilDate: nil, verificationIconFileId: nil, sendPaidMessageStars: nil, linkedMonoforumId: nil))
|
||||
let peer3Author: EnginePeer = .user(TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
let peer4: EnginePeer = .user(TelegramUser(id: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil))
|
||||
|
||||
let timestamp = self.referenceTimestamp
|
||||
|
||||
|
|
@ -1049,43 +1048,43 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, ASScrollViewDelegate
|
|||
let headerItem = self.context.sharedContext.makeChatMessageDateHeaderItem(context: self.context, timestamp: self.referenceTimestamp, theme: self.theme, strings: self.presentationData.strings, wallpaper: self.wallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder)
|
||||
|
||||
var items: [ListViewItem] = []
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1))
|
||||
let peerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(1))
|
||||
let otherPeerId = self.context.account.peerId
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
var messages = SimpleDictionary<MessageId, Message>()
|
||||
var peers = EngineSimpleDictionary<EnginePeer.Id, EngineRawPeer>()
|
||||
var messages = EngineSimpleDictionary<EngineMessage.Id, EngineRawMessage>()
|
||||
peers[peerId] = TelegramUser(id: peerId, accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_Chat_2_ReplyName, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: .preset(.blue), backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
peers[otherPeerId] = TelegramUser(id: otherPeerId, accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_Chat_2_ReplyName, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: .preset(.blue), backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
|
||||
var sampleMessages: [Message] = []
|
||||
var sampleMessages: [EngineRawMessage] = []
|
||||
|
||||
let message1 = Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: otherPeerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_4_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message1 = EngineRawMessage(stableId:1, stableVersion: 0, id: EngineMessage.Id(peerId: otherPeerId, namespace: 0, id:1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_4_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
sampleMessages.append(message1)
|
||||
|
||||
let message2 = Message(stableId: 2, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 2), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66001, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_5_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message2 = EngineRawMessage(stableId:2, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id:2), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66001, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_5_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
sampleMessages.append(message2)
|
||||
|
||||
let message3 = Message(stableId: 3, stableVersion: 0, id: MessageId(peerId: otherPeerId, namespace: 0, id: 3), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66002, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_6_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message3 = EngineRawMessage(stableId:3, stableVersion: 0, id: EngineMessage.Id(peerId: otherPeerId, namespace: 0, id:3), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66002, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_6_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
sampleMessages.append(message3)
|
||||
|
||||
let message4 = Message(stableId: 4, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 4), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66003, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_7_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message4 = EngineRawMessage(stableId:4, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id:4), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66003, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_7_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
messages[message4.id] = message4
|
||||
sampleMessages.append(message4)
|
||||
|
||||
let message5 = Message(stableId: 5, stableVersion: 0, id: MessageId(peerId: otherPeerId, namespace: 0, id: 5), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66004, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_1_Text, attributes: [ReplyMessageAttribute(messageId: message4.id, threadMessageId: nil, quote: nil, isQuote: false, innerSubject: nil)], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message5 = EngineRawMessage(stableId:5, stableVersion: 0, id: EngineMessage.Id(peerId: otherPeerId, namespace: 0, id:5), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66004, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_1_Text, attributes: [ReplyMessageAttribute(messageId: message4.id, threadMessageId: nil, quote: nil, isQuote: false, innerSubject: nil)], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
messages[message5.id] = message5
|
||||
sampleMessages.append(message5)
|
||||
|
||||
let waveformBase64 = "DAAOAAkACQAGAAwADwAMABAADQAPABsAGAALAA0AGAAfABoAHgATABgAGQAYABQADAAVABEAHwANAA0ACQAWABkACQAOAAwACQAfAAAAGQAVAAAAEwATAAAACAAfAAAAHAAAABwAHwAAABcAGQAAABQADgAAABQAHwAAAB8AHwAAAAwADwAAAB8AEwAAABoAFwAAAB8AFAAAAAAAHwAAAAAAHgAAAAAAHwAAAAAAHwAAAAAAHwAAAAAAHwAAAAAAHwAAAAAAAAA="
|
||||
let voiceAttributes: [TelegramMediaFileAttribute] = [.Audio(isVoice: true, duration: 23, title: nil, performer: nil, waveform: Data(base64Encoded: waveformBase64)!)]
|
||||
let voiceMedia = TelegramMediaFile(fileId: MediaId(namespace: 0, id: 0), partialReference: nil, resource: LocalFileMediaResource(fileId: 0), previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "audio/ogg", size: 0, attributes: voiceAttributes, alternativeRepresentations: [])
|
||||
let voiceMedia = TelegramMediaFile(fileId: EngineMedia.Id(namespace: 0, id: 0), partialReference: nil, resource: LocalFileMediaResource(fileId: 0), previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "audio/ogg", size: 0, attributes: voiceAttributes, alternativeRepresentations: [])
|
||||
|
||||
let message6 = Message(stableId: 6, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 6), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66005, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: "", attributes: [], media: [voiceMedia], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message6 = EngineRawMessage(stableId:6, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id:6), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66005, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: "", attributes: [], media: [voiceMedia], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
sampleMessages.append(message6)
|
||||
|
||||
let message7 = Message(stableId: 7, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 7), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66006, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_2_Text, attributes: [ReplyMessageAttribute(messageId: message5.id, threadMessageId: nil, quote: nil, isQuote: false, innerSubject: nil)], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message7 = EngineRawMessage(stableId:7, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id:7), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66006, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_2_Text, attributes: [ReplyMessageAttribute(messageId: message5.id, threadMessageId: nil, quote: nil, isQuote: false, innerSubject: nil)], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
sampleMessages.append(message7)
|
||||
|
||||
let message8 = Message(stableId: 8, stableVersion: 0, id: MessageId(peerId: otherPeerId, namespace: 0, id: 8), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66007, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_3_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message8 = EngineRawMessage(stableId:8, stableVersion: 0, id: EngineMessage.Id(peerId: otherPeerId, namespace: 0, id:8), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66007, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_3_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
sampleMessages.append(message8)
|
||||
|
||||
items = sampleMessages.reversed().map { message in
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import QuickLook
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import AsyncDisplayKit
|
||||
import TelegramCore
|
||||
|
|
@ -25,14 +24,14 @@ public enum WallpaperListType {
|
|||
|
||||
public enum WallpaperListSource {
|
||||
case list(wallpapers: [TelegramWallpaper], central: TelegramWallpaper, type: WallpaperListType)
|
||||
case wallpaper(TelegramWallpaper, WallpaperPresentationOptions?, [UInt32], Int32?, Int32?, Message?)
|
||||
case slug(String, TelegramMediaFile?, WallpaperPresentationOptions?, [UInt32], Int32?, Int32?, Message?)
|
||||
case wallpaper(TelegramWallpaper, WallpaperPresentationOptions?, [UInt32], Int32?, Int32?, EngineRawMessage?)
|
||||
case slug(String, TelegramMediaFile?, WallpaperPresentationOptions?, [UInt32], Int32?, Int32?, EngineRawMessage?)
|
||||
case asset(PHAsset)
|
||||
case contextResult(ChatContextResult)
|
||||
case customColor(UInt32?)
|
||||
}
|
||||
|
||||
private func areMessagesEqual(_ lhsMessage: Message?, _ rhsMessage: Message?) -> Bool {
|
||||
private func areMessagesEqual(_ lhsMessage: EngineRawMessage?, _ rhsMessage: EngineRawMessage?) -> Bool {
|
||||
if lhsMessage == nil && rhsMessage == nil {
|
||||
return true
|
||||
}
|
||||
|
|
@ -49,7 +48,7 @@ private func areMessagesEqual(_ lhsMessage: Message?, _ rhsMessage: Message?) ->
|
|||
}
|
||||
|
||||
public enum WallpaperGalleryEntry: Equatable {
|
||||
case wallpaper(TelegramWallpaper, Message?)
|
||||
case wallpaper(TelegramWallpaper, EngineRawMessage?)
|
||||
case asset(PHAsset)
|
||||
case contextResult(ChatContextResult)
|
||||
|
||||
|
|
@ -551,7 +550,7 @@ public class WallpaperGalleryController: ViewController {
|
|||
let apply = strongSelf.apply
|
||||
if case .peer = strongSelf.mode {
|
||||
if case let .wallpaper(wallpaper, _) = entry, options.contains(.blur) {
|
||||
var resource: MediaResource?
|
||||
var resource: TelegramMediaResource?
|
||||
switch wallpaper {
|
||||
case let .file(file):
|
||||
resource = file.file.resource
|
||||
|
|
@ -589,7 +588,7 @@ public class WallpaperGalleryController: ViewController {
|
|||
|
||||
switch entry {
|
||||
case let .wallpaper(wallpaper, _):
|
||||
var resource: MediaResource?
|
||||
var resource: TelegramMediaResource?
|
||||
switch wallpaper {
|
||||
case let .file(file):
|
||||
resource = file.file.resource
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import UIKit
|
|||
import Display
|
||||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import LegacyComponents
|
||||
import TelegramPresentationData
|
||||
|
|
@ -78,7 +77,7 @@ class WallpaperGalleryItem: GalleryItem {
|
|||
private let progressDiameter: CGFloat = 50.0
|
||||
private let motionAmount: CGFloat = 32.0
|
||||
|
||||
private func reference(for resource: MediaResource, media: Media, message: Message?, slug: String?) -> MediaResourceReference {
|
||||
private func reference(for resource: TelegramMediaResource, media: EngineRawMedia, message: EngineRawMessage?, slug: String?) -> MediaResourceReference {
|
||||
if let message = message {
|
||||
return .media(media: .message(message: MessageReference(message), media: media), resource: resource)
|
||||
}
|
||||
|
|
@ -614,7 +613,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||
let imagePromise = Promise<UIImage?>()
|
||||
|
||||
let signal: Signal<(TransformImageArguments) -> DrawingContext?, NoError>
|
||||
let fetchSignal: Signal<FetchResourceSourceType, FetchResourceError>
|
||||
let fetchSignal: Signal<EngineFetchResourceSourceType, EngineFetchResourceError>
|
||||
let statusSignal: Signal<EngineMediaResource.FetchStatus, NoError>
|
||||
let subtitleSignal: Signal<String?, NoError>
|
||||
var actionSignal: Signal<UIBarButtonItem?, NoError> = .single(nil)
|
||||
|
|
@ -923,7 +922,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||
representations.append(TelegramMediaImageRepresentation(dimensions: PixelDimensions(thumbnailDimensions), resource: thumbnailResource, progressiveSizes: [], immediateThumbnailData: nil, hasVideo: false, isPersonal: false))
|
||||
}
|
||||
representations.append(TelegramMediaImageRepresentation(dimensions: PixelDimensions(imageDimensions), resource: imageResource, progressiveSizes: [], immediateThumbnailData: nil, hasVideo: false, isPersonal: false))
|
||||
let tmpImage = TelegramMediaImage(imageId: MediaId(namespace: 0, id: 0), representations: representations, immediateThumbnailData: nil, reference: nil, partialReference: nil, flags: [])
|
||||
let tmpImage = TelegramMediaImage(imageId: EngineMedia.Id(namespace: 0, id: 0), representations: representations, immediateThumbnailData: nil, reference: nil, partialReference: nil, flags: [])
|
||||
|
||||
signal = chatMessagePhoto(postbox: context.account.postbox, userLocation: .other, photoReference: .standalone(media: tmpImage))
|
||||
fetchSignal = context.engine.resources.fetch(reference: .media(media: .standalone(media: tmpImage), resource: imageResource), userLocation: .other, userContentType: .other)
|
||||
|
|
@ -1506,24 +1505,24 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||
}
|
||||
|
||||
var items: [ListViewItem] = []
|
||||
var peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1))
|
||||
var peerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(1))
|
||||
let otherPeerId = self.context.account.peerId
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
var messages = SimpleDictionary<MessageId, Message>()
|
||||
var peers = EngineSimpleDictionary<EnginePeer.Id, EngineRawPeer>()
|
||||
var messages = EngineSimpleDictionary<EngineMessage.Id, EngineRawMessage>()
|
||||
|
||||
let replyAuthor = self.presentationData.strings.Appearance_ThemePreview_Chat_2_ReplyName
|
||||
|
||||
var messageAuthor: Peer = TelegramUser(id: peerId, accessHash: nil, firstName: self.presentationData.strings.Appearance_PreviewReplyAuthor, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: .preset(.blue), backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
var messageAuthor: EngineRawPeer = TelegramUser(id: peerId, accessHash: nil, firstName: self.presentationData.strings.Appearance_PreviewReplyAuthor, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: .preset(.blue), backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
let otherAuthor = TelegramUser(id: otherPeerId, accessHash: nil, firstName: replyAuthor, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: .preset(.blue), backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil, verificationIconFileId: nil)
|
||||
peers[otherPeerId] = otherAuthor
|
||||
|
||||
var messageAttributes: [MessageAttribute] = []
|
||||
var messageAttributes: [EngineMessage.Attribute] = []
|
||||
if let mode = self.mode, case let .peer(peer, _) = mode, case .channel = peer {
|
||||
peerId = peer.id
|
||||
messageAuthor = peer._asPeer()
|
||||
|
||||
let replyMessageId = MessageId(peerId: peerId, namespace: 0, id: 3)
|
||||
messages[replyMessageId] = Message(stableId: 3, stableVersion: 0, id: replyMessageId, globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: messageAuthor, text: self.presentationData.strings.WallpaperPreview_ChannelReplyText, attributes: [], media: [], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let replyMessageId = EngineMessage.Id(peerId: peerId, namespace: 0, id: 3)
|
||||
messages[replyMessageId] = EngineRawMessage(stableId: 3, stableVersion: 0, id: replyMessageId, globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: messageAuthor, text: self.presentationData.strings.WallpaperPreview_ChannelReplyText, attributes: [], media: [], peers: peers, associatedMessages: EngineSimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
messageAttributes = [ReplyMessageAttribute(messageId: replyMessageId, threadMessageId: nil, quote: nil, isQuote: false, innerSubject: nil)]
|
||||
}
|
||||
|
||||
|
|
@ -1626,19 +1625,19 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||
let theme = self.presentationData.theme
|
||||
|
||||
if !bottomMessageText.isEmpty {
|
||||
let message1 = Message(stableId: 2, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 2), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66001, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: bottomMessageText, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message1 = EngineRawMessage(stableId: 2, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id: 2), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66001, flags: [], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[otherPeerId], text: bottomMessageText, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
items.append(self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, messages: [message1], theme: theme, strings: self.presentationData.strings, wallpaper: currentWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: self.nativeNode, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil))
|
||||
}
|
||||
|
||||
|
||||
let message2 = Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: topMessageText, attributes: messageAttributes, media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message2 = EngineRawMessage(stableId: 1, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: topMessageText, attributes: messageAttributes, media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
items.append(self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, messages: [message2], theme: theme, strings: self.presentationData.strings, wallpaper: currentWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: self.nativeNode, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil))
|
||||
|
||||
if let serviceMessageText {
|
||||
let attributedText = convertMarkdownToAttributes(NSAttributedString(string: serviceMessageText))
|
||||
let entities = generateChatInputTextEntities(attributedText)
|
||||
|
||||
let message3 = Message(stableId: 0, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 0), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66002, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: "", attributes: [], media: [TelegramMediaAction(action: .customText(text: attributedText.string, entities: entities, additionalAttributes: nil))], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
let message3 = EngineRawMessage(stableId: 0, stableVersion: 0, id: EngineMessage.Id(peerId: peerId, namespace: 0, id: 0), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66002, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[peerId], text: "", attributes: [], media: [TelegramMediaAction(action: .customText(text: attributedText.string, entities: entities, additionalAttributes: nil))], peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
items.append(self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, messages: [message3], theme: theme, strings: self.presentationData.strings, wallpaper: currentWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: self.nativeNode, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil))
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue