diff --git a/CLAUDE.md b/CLAUDE.md index d3dc959662..d3bb2d950c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -41,7 +41,7 @@ A gradual migration is underway to eliminate direct `import Postbox` from consum **Historical record:** Wave-by-wave outcomes, the running tally of Postbox-free modules, and full verbose forms of the guidance subsections below live in [`docs/superpowers/postbox-refactor-log.md`](docs/superpowers/postbox-refactor-log.md). Read that file when you need wave-specific context, a full worked example of a pattern, or the history of a particular module's migration. -Waves landed so far (as of 2026-05-02): 137 waves plus standalone cleanups. See the log file for per-wave detail; the list of still-open migration opportunities lives in the `project_postbox_refactor_next_wave.md` memory file. +Waves landed so far (as of 2026-05-04): 238 waves plus standalone cleanups. See the log file for per-wave detail; the list of still-open migration opportunities lives in the `project_postbox_refactor_next_wave.md` memory file. ### Rules that apply to every wave @@ -52,6 +52,7 @@ Waves landed so far (as of 2026-05-02): 137 waves plus standalone cleanups. See 5. **Abandonment protocol:** if a module can only be refactored by violating rule 2 or by editing a module outside the current wave's list, mark the task Abandoned with a recorded reason. Do NOT substitute a new module mid-wave. 6. Full project build per module. No unit tests exist in this project. 7. **TelegramCore never imports UIKit/Display.** `TelegramCore` is shared with the Telegram-Mac codebase; its Bazel `deps` and source files must not reference UIKit, Display, or any Apple-UI framework. UIKit-needing helpers (image scaling, rendering, etc.) stay in consumer-side submodules. +8. **Never substitute Postbox protocols (`Media`, `Peer`, `Message`) with `Any` / `AnyObject`** in code that previously used them. Type erasure throws away the domain semantics that the next reader expects. Use the matching engine wrapper (`EngineMedia`, `EnginePeer`, `EngineMessage`) — extending it as needed (e.g. add a missing case-init or convenience). If neither typealias nor wrapper covers the use site, restore the original Postbox import + type for now and flag the case for a future facade. Existing `Any`/`AnyObject` parameters predating the refactor are not in scope for this rule. ### Engine typealias cheat sheet (existing aliases) @@ -75,8 +76,31 @@ ItemCollectionId → EngineItemCollectionId (added 2026-04-20) FetchResourceSourceType → EngineFetchResourceSourceType (added 2026-04-20) FetchResourceError → EngineFetchResourceError (added 2026-04-20) StoryId → EngineStoryId (added 2026-05-02) +ChatListIndex → EngineChatListIndex (added 2026-05-03) +TempBoxFile → EngineTempBoxFile (added 2026-05-03) +ItemCollectionItemIndex → EngineItemCollectionItemIndex (added 2026-05-03) +ItemCollectionViewEntryIndex → EngineItemCollectionViewEntryIndex (added 2026-05-03) +ValueBoxEncryptionParameters → EngineValueBoxEncryptionParameters (added 2026-05-03) +MessageAndThreadId → EngineMessageAndThreadId (added 2026-05-03) +PeerStoryStats → EnginePeerStoryStats (added 2026-05-03) +MessageHistoryAnchorIndex → EngineMessageHistoryAnchorIndex (added 2026-05-03) +ChatListTotalUnreadStateCategory → EngineChatListTotalUnreadStateCategory (added 2026-05-03) +ChatListTotalUnreadStateStats → EngineChatListTotalUnreadStateStats (added 2026-05-03) +PeerSummaryCounterTags → EnginePeerSummaryCounterTags (added 2026-05-03) +ChatListTotalUnreadState → EngineChatListTotalUnreadState (added 2026-05-04) +ItemCacheEntryId → EngineItemCacheEntryId (added 2026-05-04) +HashFunctions → EngineHashFunctions (added 2026-05-04 wave 251) +CachedMediaResourceRepresentationResult → EngineCachedMediaResourceRepresentationResult (added 2026-05-04 wave 265) +MediaResourceDataFetchResult → EngineMediaResourceDataFetchResult (added 2026-05-04 wave 266) +MediaResourceDataFetchError → EngineMediaResourceDataFetchError (added 2026-05-04 wave 266) +MediaResourceStatus → EngineMediaResourceStatus (added 2026-05-04 wave 272) ``` +**Free-function thin forwarders in TelegramCore** (rule 3 allows): +- `engineFileSize(_ path:, useTotalFileAllocatedSize: Bool = false)` — forwards to Postbox's `fileSize(...)` (added 2026-05-04 wave 268) + +**TelegramEngineUnauthorized.resources facade**: `UnauthorizedResources.storeResourceData(id: EngineMediaResource.Id, data:, synchronous:)` — bridges to `account.postbox.mediaBox.storeResourceData` (added 2026-05-04 wave 271) + For the `MediaResource` Postbox protocol, prefer the TelegramCore subtype `TelegramMediaResource` when the consumer's usage allows (note: `EngineMediaResource` is a wrapper **class**, not a typealias, so it is not interchangeable with the protocol). ### MediaResource → EngineMediaResource consumer migration @@ -144,6 +168,7 @@ All mediaBox methods with clean signatures (no Postbox-protocol leaks, no comple | `copyResourceData(from:, to:, synchronous:)` | 25 | `MediaBox.copyResourceData(from:, to:, synchronous:)` | | `resourceRangesStatus(resource:)` | 26 | `MediaBox.resourceRangesStatus(_ resource:)` | | `removeCachedResources(ids:, force:, notify:)` | 26 | `MediaBox.removeCachedResources(_ ids:, force:, notify:)` | +| `clearCachedMediaResources(mediaResourceIds:)` | 223 | `_internal_clearCachedMediaResources` | **Facade-shape convention:** all of these take `EngineMediaResource.Id` or `EngineMediaResource` (never raw `MediaResourceId`/`MediaResource`). Return types either don't leak Postbox (`Void`, `String`, `String?`, `Signal, NoError>`, `Signal`) or wrap via TelegramCore type (`Signal`). diff --git a/Telegram/BroadcastUpload/BroadcastUploadExtension.swift b/Telegram/BroadcastUpload/BroadcastUploadExtension.swift index dd74867392..6482ba9bf2 100644 --- a/Telegram/BroadcastUpload/BroadcastUploadExtension.swift +++ b/Telegram/BroadcastUpload/BroadcastUploadExtension.swift @@ -6,7 +6,7 @@ import SwiftSignalKit import BuildConfig import BroadcastUploadHelpers import AudioToolbox -import Postbox +import TelegramCore import CoreMedia import AVFoundation @@ -332,7 +332,7 @@ private final class EmbeddedBroadcastUploadImpl: BroadcastUploadImpl { let rootPath = rootPathForBasePath(appGroupUrl.path) - TempBox.initializeShared(basePath: rootPath, processType: "share", launchSpecificId: Int64.random(in: Int64.min ... Int64.max)) + EngineTempBox.initializeShared(basePath: rootPath, processType: "share", launchSpecificId: Int64.random(in: Int64.min ... Int64.max)) let logsPath = rootPath + "/logs/broadcast-logs" let _ = try? FileManager.default.createDirectory(atPath: logsPath, withIntermediateDirectories: true, attributes: nil) diff --git a/Telegram/Share/ShareRootController.swift b/Telegram/Share/ShareRootController.swift index 919e1692c8..7e086fa344 100644 --- a/Telegram/Share/ShareRootController.swift +++ b/Telegram/Share/ShareRootController.swift @@ -3,7 +3,6 @@ import TelegramUI import BuildConfig import ShareExtensionContext import SwiftSignalKit -import Postbox import TelegramCore @objc(ShareRootController) @@ -56,10 +55,10 @@ class ShareRootController: UIViewController { appGroupPath: appGroupUrl.path, accountManager: accountManager, appLockContext: appLockContext, - encryptionParameters: ValueBoxEncryptionParameters( + encryptionParameters: EngineValueBoxEncryptionParameters( forceEncryptionIfNoSet: false, - key: ValueBoxEncryptionParameters.Key(data: encryptionParameters.0)!, - salt: ValueBoxEncryptionParameters.Salt(data: encryptionParameters.1)! + key: EngineValueBoxEncryptionParameters.Key(data: encryptionParameters.0)!, + salt: EngineValueBoxEncryptionParameters.Salt(data: encryptionParameters.1)! ), applicationBindings: applicationBindings, initialPresentationDataAndSettings: InitialPresentationDataAndSettings, diff --git a/submodules/AccountContext/Sources/AccountContext.swift b/submodules/AccountContext/Sources/AccountContext.swift index 2245bafe09..996f7705aa 100644 --- a/submodules/AccountContext/Sources/AccountContext.swift +++ b/submodules/AccountContext/Sources/AccountContext.swift @@ -162,14 +162,14 @@ public struct ChatAvailableMessageActionOptions: OptionSet { public struct ChatAvailableMessageActions { public var options: ChatAvailableMessageActionOptions - public var banAuthor: Peer? - public var banAuthors: [Peer] + public var banAuthor: EnginePeer? + public var banAuthors: [EnginePeer] public var disableDelete: Bool public var isCopyProtected: Bool public var setTag: Bool public var editTags: Set - - public init(options: ChatAvailableMessageActionOptions, banAuthor: Peer?, banAuthors: [Peer], disableDelete: Bool, isCopyProtected: Bool, setTag: Bool, editTags: Set) { + + public init(options: ChatAvailableMessageActionOptions, banAuthor: EnginePeer?, banAuthors: [EnginePeer], disableDelete: Bool, isCopyProtected: Bool, setTag: Bool, editTags: Set) { self.options = options self.banAuthor = banAuthor self.banAuthors = banAuthors @@ -735,7 +735,7 @@ public enum PeerInfoControllerMode { } case generic - case calls(messages: [Message]) + case calls(messages: [EngineMessage]) case nearbyPeer(distance: Int32) case group(sourceMessageId: MessageId) case reaction(MessageId) diff --git a/submodules/AccountContext/Sources/ChatController.swift b/submodules/AccountContext/Sources/ChatController.swift index 496e3c3b11..c4ad63952e 100644 --- a/submodules/AccountContext/Sources/ChatController.swift +++ b/submodules/AccountContext/Sources/ChatController.swift @@ -1117,7 +1117,7 @@ public protocol ChatController: ViewController { func activateSearch(domain: ChatSearchDomain, query: String) func activateInput(type: ChatControllerActivateInput) func beginClearHistory(type: InteractiveHistoryClearingType) - func presentReactionDeletionOptions(author: Peer, messageId: MessageId) + func presentReactionDeletionOptions(author: EnginePeer, messageId: EngineMessage.Id) func performScrollToTop() -> Bool func transferScrollingVelocity(_ velocity: CGFloat) @@ -1270,7 +1270,7 @@ public protocol ChatHistoryListNode: ListView { func scrollToEndOfHistory() func updateLayout(transition: ContainedViewLayoutTransition, updateSizeAndInsets: ListViewUpdateSizeAndInsets) - func messageInCurrentHistoryView(_ id: MessageId) -> Message? + func messageInCurrentHistoryView(_ id: EngineMessage.Id) -> EngineMessage? var contentPositionChanged: (ListViewVisibleContentOffset) -> Void { get set } } diff --git a/submodules/AccountContext/Sources/ChatHistoryLocation.swift b/submodules/AccountContext/Sources/ChatHistoryLocation.swift index 2ace788c81..795a0ee6f7 100644 --- a/submodules/AccountContext/Sources/ChatHistoryLocation.swift +++ b/submodules/AccountContext/Sources/ChatHistoryLocation.swift @@ -1,11 +1,10 @@ import Foundation -import Postbox import Display import TelegramCore public enum ChatHistoryInitialSearchLocation: Equatable { - case index(MessageIndex) - case id(MessageId) + case index(EngineMessage.Index) + case id(EngineMessage.Id) } public struct MessageHistoryScrollToSubject: Equatable { @@ -19,12 +18,12 @@ public struct MessageHistoryScrollToSubject: Equatable { } } - public var index: MessageHistoryAnchorIndex + public var index: EngineMessageHistoryAnchorIndex public var quote: Quote? public var subject: EngineMessageReplyInnerSubject? public var setupReply: Bool - public init(index: MessageHistoryAnchorIndex, quote: Quote? = nil, subject: EngineMessageReplyInnerSubject? = nil, setupReply: Bool = false) { + public init(index: EngineMessageHistoryAnchorIndex, quote: Quote? = nil, subject: EngineMessageReplyInnerSubject? = nil, setupReply: Bool = false) { self.index = index self.quote = quote self.subject = subject @@ -57,8 +56,8 @@ public struct MessageHistoryInitialSearchSubject: Equatable { public enum ChatHistoryLocation: Equatable { case Initial(count: Int) case InitialSearch(subject: MessageHistoryInitialSearchSubject, count: Int, highlight: Bool, setupReply: Bool) - case Navigation(index: MessageHistoryAnchorIndex, anchorIndex: MessageHistoryAnchorIndex, count: Int, highlight: Bool) - case Scroll(subject: MessageHistoryScrollToSubject, anchorIndex: MessageHistoryAnchorIndex, sourceIndex: MessageHistoryAnchorIndex, scrollPosition: ListViewScrollPosition, animated: Bool, highlight: Bool, setupReply: Bool) + case Navigation(index: EngineMessageHistoryAnchorIndex, anchorIndex: EngineMessageHistoryAnchorIndex, count: Int, highlight: Bool) + case Scroll(subject: MessageHistoryScrollToSubject, anchorIndex: EngineMessageHistoryAnchorIndex, sourceIndex: EngineMessageHistoryAnchorIndex, scrollPosition: ListViewScrollPosition, animated: Bool, highlight: Bool, setupReply: Bool) } public struct ChatHistoryLocationInput: Equatable { diff --git a/submodules/AccountContext/Sources/IsMediaStreamable.swift b/submodules/AccountContext/Sources/IsMediaStreamable.swift index 34e9a2a029..109f3c138c 100644 --- a/submodules/AccountContext/Sources/IsMediaStreamable.swift +++ b/submodules/AccountContext/Sources/IsMediaStreamable.swift @@ -1,10 +1,9 @@ import Foundation -import Postbox import TelegramCore private let minimalStreamableSize: Int = 384 * 1024 -public func isMediaStreamable(message: Message, media: TelegramMediaFile) -> Bool { +public func isMediaStreamable(message: EngineMessage, media: TelegramMediaFile) -> Bool { if message.containsSecretMedia { return false } @@ -51,7 +50,7 @@ public func isMediaStreamable(media: TelegramMediaFile) -> Bool { return false } -public func isMediaStreamable(resource: MediaResource) -> Bool { +public func isMediaStreamable(resource: TelegramMediaResource) -> Bool { if let size = resource.size, size >= minimalStreamableSize { return true } else { diff --git a/submodules/AccountContext/Sources/MediaManager.swift b/submodules/AccountContext/Sources/MediaManager.swift index 66c1bbec49..2af36d90ed 100644 --- a/submodules/AccountContext/Sources/MediaManager.swift +++ b/submodules/AccountContext/Sources/MediaManager.swift @@ -254,7 +254,7 @@ public enum GalleryHiddenMediaId: Hashable { } public protocol GalleryHiddenMediaTarget: AnyObject { - func getTransitionInfo(messageId: MessageId, media: Media) -> ((UIView) -> Void, ASDisplayNode, () -> (UIView?, UIView?))? + func getTransitionInfo(messageId: EngineMessage.Id, media: EngineMedia) -> ((UIView) -> Void, ASDisplayNode, () -> (UIView?, UIView?))? } public protocol GalleryHiddenMediaManager: AnyObject { @@ -263,7 +263,7 @@ public protocol GalleryHiddenMediaManager: AnyObject { func removeSource(_ index: Int) func addTarget(_ target: GalleryHiddenMediaTarget) func removeTarget(_ target: GalleryHiddenMediaTarget) - func findTarget(messageId: MessageId, media: Media) -> ((UIView) -> Void, ASDisplayNode, () -> (UIView?, UIView?))? + func findTarget(messageId: EngineMessage.Id, media: EngineMedia) -> ((UIView) -> Void, ASDisplayNode, () -> (UIView?, UIView?))? } public protocol UniversalVideoManager: AnyObject { diff --git a/submodules/AuthorizationUI/Sources/AuthorizationSequenceController.swift b/submodules/AuthorizationUI/Sources/AuthorizationSequenceController.swift index 1b4da5efdc..f1edb805dd 100644 --- a/submodules/AuthorizationUI/Sources/AuthorizationSequenceController.swift +++ b/submodules/AuthorizationUI/Sources/AuthorizationSequenceController.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import AsyncDisplayKit import Display -import Postbox import TelegramCore import SwiftSignalKit import MtProtoKit @@ -209,7 +208,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth |> deliverOnMainQueue).startStandalone(next: { [weak self] authorizationPushConfiguration in if let strongSelf = self { strongSelf.actionDisposable.set((sendAuthorizationCode(accountManager: strongSelf.sharedContext.accountManager, account: strongSelf.account, phoneNumber: number, apiId: strongSelf.apiId, apiHash: strongSelf.apiHash, pushNotificationConfiguration: authorizationPushConfiguration, firebaseSecretStream: strongSelf.sharedContext.firebaseSecretStream, syncContacts: syncContacts, disableAuthTokens: disableAuthTokens, forcedPasswordSetupNotice: { value in - guard let entry = CodableEntry(ApplicationSpecificCounterNotice(value: value)) else { + guard let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: value)) else { return nil } return (ApplicationSpecificNotice.forcedPasswordSetupKey(), entry) @@ -327,7 +326,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth passkey: passkey, foreignDatacenter: nil, forcedPasswordSetupNotice: { value in - guard let entry = CodableEntry(ApplicationSpecificCounterNotice(value: value)) else { + guard let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: value)) else { return nil } return (ApplicationSpecificNotice.forcedPasswordSetupKey(), entry) @@ -518,7 +517,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth })) } else { strongSelf.actionDisposable.set((authorizeWithCode(accountManager: strongSelf.sharedContext.accountManager, account: strongSelf.account, code: authorizationCode, termsOfService: termsOfService?.0, forcedPasswordSetupNotice: { value in - guard let entry = CodableEntry(ApplicationSpecificCounterNotice(value: value)) else { + guard let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: value)) else { return nil } return (ApplicationSpecificNotice.forcedPasswordSetupKey(), entry) @@ -857,7 +856,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth } else { self.actionDisposable.set( authorizeWithCode(accountManager: self.sharedContext.accountManager, account: self.account, code: .emailVerification(.appleToken(token)), termsOfService: nil, forcedPasswordSetupNotice: { value in - guard let entry = CodableEntry(ApplicationSpecificCounterNotice(value: value)) else { + guard let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: value)) else { return nil } return (ApplicationSpecificNotice.forcedPasswordSetupKey(), entry) @@ -1177,7 +1176,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth if stat(result.fileURL.path, &value) == 0 { if let data = try? Data(contentsOf: result.fileURL) { let resource = LocalFileMediaResource(fileId: Int64.random(in: Int64.min ... Int64.max)) - engine.account.postbox.mediaBox.storeResourceData(resource.id, data: data, synchronous: true) + engine.resources.storeResourceData(id: EngineMediaResource.Id(resource.id), data: data, synchronous: true) subscriber.putNext(EngineMediaResource(resource)) EngineTempBox.shared.dispose(tempFile) @@ -1208,7 +1207,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth } strongSelf.actionDisposable.set((signUpWithName(accountManager: strongSelf.sharedContext.accountManager, account: strongSelf.account, firstName: firstName, lastName: lastName, avatarData: avatarData, avatarVideo: avatarVideo, videoStartTimestamp: videoStartTimestamp, disableJoinNotifications: !announceSignUp, forcedPasswordSetupNotice: { value in - guard let entry = CodableEntry(ApplicationSpecificCounterNotice(value: value)) else { + guard let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: value)) else { return nil } return (ApplicationSpecificNotice.forcedPasswordSetupKey(), entry) diff --git a/submodules/BrowserUI/Sources/BrowserAddressListComponent.swift b/submodules/BrowserUI/Sources/BrowserAddressListComponent.swift index 23b1c03107..d92f3e29cd 100644 --- a/submodules/BrowserUI/Sources/BrowserAddressListComponent.swift +++ b/submodules/BrowserUI/Sources/BrowserAddressListComponent.swift @@ -4,7 +4,6 @@ import Display import AsyncDisplayKit import ComponentFlow import SwiftSignalKit -import Postbox import TelegramCore import AccountContext import TelegramPresentationData @@ -139,7 +138,7 @@ final class BrowserAddressListComponent: Component { struct State { let recent: [TelegramMediaWebpage] let isRecentExpanded: Bool - let bookmarks: [Message] + let bookmarks: [EngineMessage] } private let outerView = UIButton() @@ -367,17 +366,22 @@ final class BrowserAddressListComponent: Component { ) } else { var webPage: TelegramMediaWebpage? - var itemMessage: Message? - + var itemMessage: EngineMessage? + if section.id == 0 { webPage = state.recent[i] } else if section.id == 1 { let message = state.bookmarks[i] if let primaryUrl = getPrimaryUrl(message: message) { - if let media = message.media.first(where: { $0 is TelegramMediaWebpage }) as? TelegramMediaWebpage { - webPage = media + if let foundWebpage = message.engineMedia.compactMap({ engineMedia -> TelegramMediaWebpage? in + if case let .webpage(webpage) = engineMedia { + return webpage + } + return nil + }).first { + webPage = foundWebpage } else { - webPage = TelegramMediaWebpage(webpageId: MediaId(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: primaryUrl, displayUrl: "", hash: 0, type: nil, websiteName: "", title: message.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))) + webPage = TelegramMediaWebpage(webpageId: EngineMedia.Id(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: primaryUrl, displayUrl: "", hash: 0, type: nil, websiteName: "", title: message.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))) } itemMessage = message } else { @@ -523,9 +527,9 @@ final class BrowserAddressListComponent: Component { return } - var bookmarks: [Message] = [] + var bookmarks: [EngineMessage] = [] for entry in view.0.entries.reversed() { - bookmarks.append(entry.message) + bookmarks.append(EngineMessage(entry.message)) } let isFirstTime = self.stateValue == nil diff --git a/submodules/BrowserUI/Sources/BrowserAddressListItemComponent.swift b/submodules/BrowserUI/Sources/BrowserAddressListItemComponent.swift index 49c9ece448..ac05e5953e 100644 --- a/submodules/BrowserUI/Sources/BrowserAddressListItemComponent.swift +++ b/submodules/BrowserUI/Sources/BrowserAddressListItemComponent.swift @@ -3,7 +3,6 @@ import UIKit import Display import ComponentFlow import SwiftSignalKit -import Postbox import TelegramCore import MultilineTextComponent import TelegramPresentationData @@ -26,21 +25,21 @@ final class BrowserAddressListItemComponent: Component { let context: AccountContext let theme: PresentationTheme let webPage: TelegramMediaWebpage - var message: Message? + var message: EngineMessage? let hasNext: Bool let insets: UIEdgeInsets let action: () -> Void - let contextAction: ((TelegramMediaWebpage, Message?, ContextExtractedContentContainingView, ContextGesture) -> Void)? - + let contextAction: ((TelegramMediaWebpage, EngineMessage?, ContextExtractedContentContainingView, ContextGesture) -> Void)? + init( context: AccountContext, theme: PresentationTheme, webPage: TelegramMediaWebpage, - message: Message?, + message: EngineMessage?, hasNext: Bool, insets: UIEdgeInsets, action: @escaping () -> Void, - contextAction: ((TelegramMediaWebpage, Message?, ContextExtractedContentContainingView, ContextGesture) -> Void)? + contextAction: ((TelegramMediaWebpage, EngineMessage?, ContextExtractedContentContainingView, ContextGesture) -> Void)? ) { self.context = context self.theme = theme @@ -190,7 +189,7 @@ final class BrowserAddressListItemComponent: Component { if let image = content.image { if let representation = imageRepresentationLargerThan(image.representations, size: PixelDimensions(width: 80, height: 80)) { if let message = component.message { - iconImageReferenceAndRepresentation = (.message(message: MessageReference(message), media: image), representation) + iconImageReferenceAndRepresentation = (.message(message: MessageReference(message._asMessage()), media: image), representation) } else { iconImageReferenceAndRepresentation = (.standalone(media: image), representation) } @@ -198,7 +197,7 @@ final class BrowserAddressListItemComponent: Component { } else if let file = content.file { if let representation = smallestImageRepresentation(file.previewRepresentations) { if let message = component.message { - iconImageReferenceAndRepresentation = (.message(message: MessageReference(message), media: file), representation) + iconImageReferenceAndRepresentation = (.message(message: MessageReference(message._asMessage()), media: file), representation) } else { iconImageReferenceAndRepresentation = (.standalone(media: file), representation) } diff --git a/submodules/BrowserUI/Sources/BrowserBookmarksScreen.swift b/submodules/BrowserUI/Sources/BrowserBookmarksScreen.swift index 7b88fba51b..4967f82d46 100644 --- a/submodules/BrowserUI/Sources/BrowserBookmarksScreen.swift +++ b/submodules/BrowserUI/Sources/BrowserBookmarksScreen.swift @@ -4,7 +4,6 @@ import AccountContext import AsyncDisplayKit import Display import SwiftSignalKit -import Postbox import TelegramCore import TelegramPresentationData import PresentationDataUtils @@ -44,18 +43,18 @@ public final class BrowserBookmarksScreen: ViewController { self.controller = controller self.presentationData = presentationData - var openMessageImpl: ((Message) -> Bool)? - var openContextMenuImpl: ((Message, ASDisplayNode, CGRect, UIGestureRecognizer?) -> Void)? + var openMessageImpl: ((EngineMessage) -> Bool)? + var openContextMenuImpl: ((EngineMessage, ASDisplayNode, CGRect, UIGestureRecognizer?) -> Void)? self.controllerInteraction = ChatControllerInteraction(openMessage: { message, _ in if let openMessageImpl = openMessageImpl { - return openMessageImpl(message) + return openMessageImpl(EngineMessage(message)) } else { return false } }, openPeer: { _, _, _, _ in }, openPeerMention: { _, _ in }, openMessageContextMenu: { message, _, sourceView, rect, gesture, _ in - openContextMenuImpl?(message, sourceView, rect, gesture) + openContextMenuImpl?(EngineMessage(message), sourceView, rect, gesture) }, openMessageReactionContextMenu: { _, _, _, _ in }, updateMessageReaction: { _, _, _, _ in }, activateMessagePinch: { _ in @@ -89,7 +88,7 @@ public final class BrowserBookmarksScreen: ViewController { }, sendBotCommand: { _, _ in }, openInstantPage: { message, _ in if let openMessageImpl = openMessageImpl { - let _ = openMessageImpl(message) + let _ = openMessageImpl(EngineMessage(message)) } }, openWallpaper: { _ in }, openTheme: {_ in @@ -197,7 +196,7 @@ public final class BrowserBookmarksScreen: ViewController { }, automaticMediaDownloadSettings: MediaAutoDownloadSettings.defaultSettings, pollActionState: ChatInterfacePollActionState(), stickerSettings: ChatInterfaceStickerSettings(), presentationContext: ChatPresentationContext(context: context, backgroundNode: nil)) - let tagMask: MessageTags = .webPage + let tagMask: EngineMessage.Tags = .webPage let chatLocationContextHolder = Atomic(value: nil) self.historyNode = context.sharedContext.makeChatHistoryListNode( context: context, @@ -261,7 +260,13 @@ public final class BrowserBookmarksScreen: ViewController { let presentationData = self.context.sharedContext.currentPresentationData.with { $0 } var itemList: [ContextMenuItem] = [] - if let webPage = message.media.first(where: { $0 is TelegramMediaWebpage }) as? TelegramMediaWebpage, let url = webPage.content.url { + let foundWebpage = message.engineMedia.compactMap { engineMedia -> TelegramMediaWebpage? in + if case let .webpage(webpage) = engineMedia { + return webpage + } + return nil + }.first + if let webPage = foundWebpage, let url = webPage.content.url { itemList.append(.action(ContextMenuActionItem(text: presentationData.strings.WebBrowser_CopyLink, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Copy"), color: theme.contextMenu.primaryColor) }, action: { [weak self] _, f in @@ -299,7 +304,7 @@ public final class BrowserBookmarksScreen: ViewController { guard let (layout, navigationBarHeight, _) = self.validLayout, let navigationBar = self.controller?.navigationBar else { return } - let tagMask: MessageTags = .webPage + let tagMask: EngineMessage.Tags = .webPage self.searchDisplayController = SearchDisplayController(presentationData: self.presentationData, mode: .navigation, placeholder: self.presentationData.strings.Common_Search, hasBackground: true, contentNode: ChatHistorySearchContainerNode(context: self.context, peerId: self.context.account.peerId, threadId: nil, tagMask: tagMask, interfaceInteraction: self.controllerInteraction), cancel: { [weak self] in self?.controller?.deactivateSearch() diff --git a/submodules/BrowserUI/Sources/BrowserDocumentContent.swift b/submodules/BrowserUI/Sources/BrowserDocumentContent.swift index 841300360d..0de7e4c7eb 100644 --- a/submodules/BrowserUI/Sources/BrowserDocumentContent.swift +++ b/submodules/BrowserUI/Sources/BrowserDocumentContent.swift @@ -3,7 +3,6 @@ import UIKit import Display import ComponentFlow import TelegramCore -import Postbox import SwiftSignalKit import TelegramPresentationData import TelegramUIPreferences @@ -44,7 +43,7 @@ final class BrowserDocumentContent: UIView, BrowserContent, WKNavigationDelegate var presentInGlobalOverlay: (ViewController) -> Void = { _ in } var getNavigationController: () -> NavigationController? = { return nil } - private var tempFile: TempBoxFile? + private var tempFile: EngineTempBoxFile? init(context: AccountContext, presentationData: PresentationData, file: FileMediaReference) { self.context = context @@ -65,7 +64,7 @@ final class BrowserDocumentContent: UIView, BrowserContent, WKNavigationDelegate if let path = self.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(file.media.resource.id)) { var updatedPath = path if let fileName = file.media.fileName { - let tempFile = TempBox.shared.file(path: path, fileName: fileName) + let tempFile = EngineTempBox.shared.file(path: path, fileName: fileName) updatedPath = tempFile.path self.tempFile = tempFile title = fileName diff --git a/submodules/BrowserUI/Sources/BrowserPdfContent.swift b/submodules/BrowserUI/Sources/BrowserPdfContent.swift index 0f723e51ef..0537bb3715 100644 --- a/submodules/BrowserUI/Sources/BrowserPdfContent.swift +++ b/submodules/BrowserUI/Sources/BrowserPdfContent.swift @@ -3,7 +3,6 @@ import UIKit import Display import ComponentFlow import TelegramCore -import Postbox import SwiftSignalKit import TelegramPresentationData import TelegramUIPreferences @@ -51,7 +50,7 @@ final class BrowserPdfContent: UIView, BrowserContent, UIScrollViewDelegate, PDF var presentInGlobalOverlay: (ViewController) -> Void = { _ in } var getNavigationController: () -> NavigationController? = { return nil } - private var tempFile: TempBoxFile? + private var tempFile: EngineTempBoxFile? init(context: AccountContext, presentationData: PresentationData, file: FileMediaReference) { self.context = context @@ -85,7 +84,7 @@ final class BrowserPdfContent: UIView, BrowserContent, UIScrollViewDelegate, PDF if let path = self.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(file.media.resource.id)) { var updatedPath = path if let fileName = file.media.fileName { - let tempFile = TempBox.shared.file(path: path, fileName: fileName) + let tempFile = EngineTempBox.shared.file(path: path, fileName: fileName) updatedPath = tempFile.path self.tempFile = tempFile title = fileName diff --git a/submodules/BrowserUI/Sources/BrowserRecentlyVisited.swift b/submodules/BrowserUI/Sources/BrowserRecentlyVisited.swift index fc8bb321f9..608c19e745 100644 --- a/submodules/BrowserUI/Sources/BrowserRecentlyVisited.swift +++ b/submodules/BrowserUI/Sources/BrowserRecentlyVisited.swift @@ -1,23 +1,22 @@ import Foundation -import Postbox import TelegramCore import SwiftSignalKit import TelegramUIPreferences private struct RecentlyVisitedLinkItemId { - public let rawValue: MemoryBuffer + public let rawValue: EngineMemoryBuffer var value: String { return String(data: self.rawValue.makeData(), encoding: .utf8) ?? "" } - init(_ rawValue: MemoryBuffer) { + init(_ rawValue: EngineMemoryBuffer) { self.rawValue = rawValue } init?(_ value: String) { if let data = value.data(using: .utf8) { - self.rawValue = MemoryBuffer(data: data) + self.rawValue = EngineMemoryBuffer(data: data) } else { return nil } @@ -38,7 +37,7 @@ public final class RecentVisitedLinkItem: Codable { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) if let webPageData = try container.decodeIfPresent(Data.self, forKey: .webPage) { - self.webPage = PostboxDecoder(buffer: MemoryBuffer(data: webPageData)).decodeRootObject() as! TelegramMediaWebpage + self.webPage = EnginePostboxDecoder(buffer: EngineMemoryBuffer(data: webPageData)).decodeRootObject() as! TelegramMediaWebpage } else { fatalError() } @@ -47,7 +46,7 @@ public final class RecentVisitedLinkItem: Codable { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - let encoder = PostboxEncoder() + let encoder = EnginePostboxEncoder() encoder.encodeRootObject(self.webPage) let webPageData = encoder.makeData() try container.encode(webPageData, forKey: .webPage) diff --git a/submodules/BrowserUI/Sources/BrowserWebContent.swift b/submodules/BrowserUI/Sources/BrowserWebContent.swift index 835a5a9144..31353c2a99 100644 --- a/submodules/BrowserUI/Sources/BrowserWebContent.swift +++ b/submodules/BrowserUI/Sources/BrowserWebContent.swift @@ -3,7 +3,6 @@ import UIKit import Display import ComponentFlow import TelegramCore -import Postbox import SwiftSignalKit import TelegramPresentationData import TelegramUIPreferences @@ -236,7 +235,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU var getNavigationController: () -> NavigationController? = { return nil } var cancelInteractiveTransitionGestures: () -> Void = {} - private var tempFile: TempBoxFile? + private var tempFile: EngineTempBoxFile? private var disposeTrustedDomain: (() -> Void)? init(context: AccountContext, presentationData: PresentationData, url: String, preferredConfiguration: WKWebViewConfiguration? = nil) { @@ -321,7 +320,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU var request: URLRequest? if url.hasPrefix("file://") { var updatedPath = url - let tempFile = TempBox.shared.file(path: url.replacingOccurrences(of: "file://", with: ""), fileName: "file.xlsx") + let tempFile = EngineTempBox.shared.file(path: url.replacingOccurrences(of: "file://", with: ""), fileName: "file.xlsx") updatedPath = tempFile.path self.tempFile = tempFile @@ -536,7 +535,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU fileName = "default" } - let tempFile = TempBox.shared.file(path: path, fileName: fileName) + let tempFile = EngineTempBox.shared.file(path: path, fileName: fileName) let fileUrl = URL(fileURLWithPath: tempFile.path) let controller = legacyICloudFilePicker(theme: self.presentationData.theme, mode: .export, url: fileUrl, documentTypes: [], forceDarkTheme: false, dismissed: {}, completion: { _ in @@ -1042,7 +1041,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU } if let (path, fileName) = self.downloadArguments { - let tempFile = TempBox.shared.file(path: path, fileName: fileName) + let tempFile = EngineTempBox.shared.file(path: path, fileName: fileName) let url = URL(fileURLWithPath: tempFile.path) if fileName.hasSuffix(".pkpass") { @@ -1180,7 +1179,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU } self.instantPage = webPage self.instantPageResources = resources - let _ = (updatedRemoteWebpage(postbox: self.context.account.postbox, network: self.context.account.network, accountPeerId: self.context.account.peerId, webPage: WebpageReference(TelegramMediaWebpage(webpageId: MediaId(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: self._state.url, displayUrl: "", hash: 0, type: nil, websiteName: nil, title: nil, text: nil, embedUrl: nil, embedType: nil, embedSize: nil, duration: nil, author: nil, isMediaLargeByDefault: nil, imageIsVideoCover: false, image: nil, file: nil, story: nil, attributes: [], instantPage: nil))))) + let _ = (updatedRemoteWebpage(postbox: self.context.account.postbox, network: self.context.account.network, accountPeerId: self.context.account.peerId, webPage: WebpageReference(TelegramMediaWebpage(webpageId: EngineMedia.Id(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: self._state.url, displayUrl: "", hash: 0, type: nil, websiteName: nil, title: nil, text: nil, embedUrl: nil, embedType: nil, embedSize: nil, duration: nil, author: nil, isMediaLargeByDefault: nil, imageIsVideoCover: false, image: nil, file: nil, story: nil, attributes: [], instantPage: nil))))) |> deliverOnMainQueue).start(next: { [weak self] webPage in guard let self, let webPage, case let .Loaded(result) = webPage.content, let _ = result.instantPage else { return @@ -1215,7 +1214,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU let path = NSTemporaryDirectory() + NSUUID().uuidString let _ = try? data.write(to: URL(fileURLWithPath: path), options: .atomic) - let tempFile = TempBox.shared.file(path: path, fileName: "\(self._state.title).webarchive") + let tempFile = EngineTempBox.shared.file(path: path, fileName: "\(self._state.title).webarchive") let url = URL(fileURLWithPath: tempFile.path) let controller = legacyICloudFilePicker(theme: self.presentationData.theme, mode: .export, url: url, documentTypes: [], forceDarkTheme: false, dismissed: {}, completion: { _ in @@ -1354,7 +1353,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU fileName = "default" } - let tempFile = TempBox.shared.file(path: path, fileName: fileName) + let tempFile = EngineTempBox.shared.file(path: path, fileName: fileName) let fileUrl = URL(fileURLWithPath: tempFile.path) let controller = legacyICloudFilePicker(theme: self.presentationData.theme, mode: .export, url: fileUrl, documentTypes: [], forceDarkTheme: false, dismissed: {}, completion: { _ in @@ -1675,7 +1674,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU let resource = LocalFileMediaResource(fileId: Int64.random(in: Int64.min ... Int64.max)) self.context.engine.resources.storeResourceData(id: EngineMediaResource.Id(resource.id), data: imageData) image = TelegramMediaImage( - imageId: MediaId(namespace: Namespaces.Media.LocalImage, id: Int64.random(in: Int64.min ... Int64.max)), + imageId: EngineMedia.Id(namespace: Namespaces.Media.LocalImage, id: Int64.random(in: Int64.min ... Int64.max)), representations: [ TelegramMediaImageRepresentation( dimensions: PixelDimensions(width: Int32(favicon.size.width), height: Int32(favicon.size.height)), @@ -1693,7 +1692,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU ) } - let webPage = TelegramMediaWebpage(webpageId: MediaId(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent( + let webPage = TelegramMediaWebpage(webpageId: EngineMedia.Id(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent( url: self._state.url, displayUrl: self._state.url, hash: 0, diff --git a/submodules/BrowserUI/Sources/Utils.swift b/submodules/BrowserUI/Sources/Utils.swift index 3a479fde87..36de33b232 100644 --- a/submodules/BrowserUI/Sources/Utils.swift +++ b/submodules/BrowserUI/Sources/Utils.swift @@ -37,7 +37,7 @@ func fetchFavicon(context: AccountContext, url: String, size: CGSize) -> Signal< } } -func getPrimaryUrl(message: Message) -> String? { +func getPrimaryUrl(message: EngineMessage) -> String? { var primaryUrl: String? if let webPage = message.media.first(where: { $0 is TelegramMediaWebpage }) as? TelegramMediaWebpage, let url = webPage.content.url { primaryUrl = url diff --git a/submodules/CallListUI/Sources/CallListController.swift b/submodules/CallListUI/Sources/CallListController.swift index 991c81f67a..69e8defa35 100644 --- a/submodules/CallListUI/Sources/CallListController.swift +++ b/submodules/CallListUI/Sources/CallListController.swift @@ -372,7 +372,7 @@ public final class CallListController: TelegramBaseController { TelegramEngine.EngineData.Item.Peer.Peer(id: peerId) ) |> deliverOnMainQueue).startStandalone(next: { peer in - if let strongSelf = self, let peer = peer, let controller = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, updatedPresentationData: nil, peer: peer, mode: .calls(messages: messages.map({ $0._asMessage() })), avatarInitiallyExpanded: false, fromChat: false, requestsContext: nil) { + if let strongSelf = self, let peer = peer, let controller = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, updatedPresentationData: nil, peer: peer, mode: .calls(messages: messages), avatarInitiallyExpanded: false, fromChat: false, requestsContext: nil) { (strongSelf.navigationController as? NavigationController)?.pushViewController(controller) } }) diff --git a/submodules/ChatListUI/Sources/ChatListSearchMediaNode.swift b/submodules/ChatListUI/Sources/ChatListSearchMediaNode.swift index 6f0f69a246..d25137a6be 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchMediaNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchMediaNode.swift @@ -130,7 +130,7 @@ private final class VisualMediaItemNode: ASDisplayNode { if let media = media { if let file = media as? TelegramMediaFile { - if isMediaStreamable(message: message, media: file) { + if isMediaStreamable(message: EngineMessage(message), media: file) { self.interaction.openMessage(message) } else { self.progressPressed() @@ -226,7 +226,7 @@ private final class VisualMediaItemNode: ASDisplayNode { if let strongSelf = self, let _ = strongSelf.item { strongSelf.resourceStatus = status - let isStreamable = isMediaStreamable(message: message, media: file) + let isStreamable = isMediaStreamable(message: EngineMessage(message), media: file) var statusState: RadialStatusNodeState = .none if isStreamable || file.isAnimated { diff --git a/submodules/ChatListUI/Sources/Node/ChatListNode.swift b/submodules/ChatListUI/Sources/Node/ChatListNode.swift index 63c74cdd62..8213296e4b 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNode.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNode.swift @@ -2588,7 +2588,7 @@ public final class ChatListNode: ListViewImpl { } let presentationData = state.presentationData - return preparedChatListNodeViewTransition(from: previousView, to: processedView, reason: reason, previewing: previewing, disableAnimations: disableAnimations, account: context.account, scrollPosition: updatedScrollPosition, searchMode: searchMode, forceAllUpdated: forceAllUpdated) + return preparedChatListNodeViewTransition(from: previousView, to: processedView, reason: reason, previewing: previewing, disableAnimations: disableAnimations, scrollPosition: updatedScrollPosition, searchMode: searchMode, forceAllUpdated: forceAllUpdated) |> map({ mappedChatListNodeViewListTransition(context: context, nodeInteraction: nodeInteraction, location: location, isPremium: accountIsPremium, filterData: filterData, chatListFilters: chatListFilters, mode: mode, isPeerEnabled: isPeerEnabled, presentationData: presentationData, transition: $0) }) |> runOn(prepareOnMainQueue ? Queue.mainQueue() : viewProcessingQueue) } diff --git a/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift b/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift index d98fddcd84..f9c4efa872 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift @@ -1,6 +1,5 @@ import Foundation import UIKit -import Postbox import TelegramCore import TelegramPresentationData import MergeLists diff --git a/submodules/ChatListUI/Sources/Node/ChatListViewTransition.swift b/submodules/ChatListUI/Sources/Node/ChatListViewTransition.swift index 630edbf917..8de41fe517 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListViewTransition.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListViewTransition.swift @@ -1,5 +1,4 @@ import Foundation -import Postbox import TelegramCore import SwiftSignalKit import Display @@ -48,10 +47,10 @@ struct ChatListNodeViewTransition { } public enum ChatListNodeViewScrollPosition { - case index(index: ChatListIndex, position: ListViewScrollPosition, directionHint: ListViewScrollToItemDirectionHint, animated: Bool) + case index(index: EngineChatListIndex, position: ListViewScrollPosition, directionHint: ListViewScrollToItemDirectionHint, animated: Bool) } -func preparedChatListNodeViewTransition(from fromView: ChatListNodeView?, to toView: ChatListNodeView, reason: ChatListNodeViewTransitionReason, previewing: Bool, disableAnimations: Bool, account: Account, scrollPosition: ChatListNodeViewScrollPosition?, searchMode: Bool, forceAllUpdated: Bool) -> Signal { +func preparedChatListNodeViewTransition(from fromView: ChatListNodeView?, to toView: ChatListNodeView, reason: ChatListNodeViewTransitionReason, previewing: Bool, disableAnimations: Bool, scrollPosition: ChatListNodeViewScrollPosition?, searchMode: Bool, forceAllUpdated: Bool) -> Signal { return Signal { subscriber in let (deleteIndices, indicesAndItems, updateIndices) = mergeListsStableWithUpdates(leftList: fromView?.filteredEntries ?? [], rightList: toView.filteredEntries, allUpdated: forceAllUpdated) diff --git a/submodules/DebugSettingsUI/BUILD b/submodules/DebugSettingsUI/BUILD index 553c5023c8..f0e6a2859a 100644 --- a/submodules/DebugSettingsUI/BUILD +++ b/submodules/DebugSettingsUI/BUILD @@ -12,7 +12,6 @@ swift_library( deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/Display:Display", - "//submodules/Postbox:Postbox", "//submodules/TelegramCore:TelegramCore", "//submodules/MtProtoKit:MtProtoKit", "//submodules/TelegramPresentationData:TelegramPresentationData", diff --git a/submodules/DebugSettingsUI/Sources/DebugController.swift b/submodules/DebugSettingsUI/Sources/DebugController.swift index 76a88cf387..3fa40d32dc 100644 --- a/submodules/DebugSettingsUI/Sources/DebugController.swift +++ b/submodules/DebugSettingsUI/Sources/DebugController.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import Display import SwiftSignalKit -import Postbox import TelegramCore import MtProtoKit import MessageUI @@ -345,8 +344,8 @@ private enum DebugControllerEntry: ItemListNodeEntry { } } - let tempSource = TempBox.shared.tempFile(fileName: "Log.txt") - let tempZip = TempBox.shared.tempFile(fileName: "destination.zip") + let tempSource = EngineTempBox.shared.tempFile(fileName: "Log.txt") + let tempZip = EngineTempBox.shared.tempFile(fileName: "destination.zip") let _ = try? rawLogData.write(to: URL(fileURLWithPath: tempSource.path)) @@ -356,14 +355,14 @@ private enum DebugControllerEntry: ItemListNodeEntry { return } - TempBox.shared.dispose(tempSource) - TempBox.shared.dispose(tempZip) + EngineTempBox.shared.dispose(tempSource) + EngineTempBox.shared.dispose(tempZip) let id = Int64.random(in: Int64.min ... Int64.max) let fileResource = LocalFileMediaResource(fileId: id, size: Int64(gzippedData.count), isSecretRelated: false) context.engine.resources.storeResourceData(id: EngineMediaResource.Id(fileResource.id), data: gzippedData) - let file = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/text", size: Int64(gzippedData.count), attributes: [.FileName(fileName: "Log-iOS-Full.txt.zip")], alternativeRepresentations: []) + let file = TelegramMediaFile(fileId: EngineMedia.Id(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/text", size: Int64(gzippedData.count), attributes: [.FileName(fileName: "Log-iOS-Full.txt.zip")], alternativeRepresentations: []) let message: EnqueueMessage = .message(text: "", attributes: [], inlineStickers: [:], mediaReference: .standalone(media: file), threadId: nil, replyToMessageId: nil, replyToStoryId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: []) let _ = enqueueMessages(account: context.account, peerId: peerId, messages: [message]).start() @@ -443,7 +442,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { let fileResource = LocalFileMediaResource(fileId: id, size: Int64(logData.count), isSecretRelated: false) context.engine.resources.storeResourceData(id: EngineMediaResource.Id(fileResource.id), data: logData) - let file = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/text", size: Int64(logData.count), attributes: [.FileName(fileName: "Log-iOS-Short.txt")], alternativeRepresentations: []) + let file = TelegramMediaFile(fileId: EngineMedia.Id(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/text", size: Int64(logData.count), attributes: [.FileName(fileName: "Log-iOS-Short.txt")], alternativeRepresentations: []) let message: EnqueueMessage = .message(text: "", attributes: [], inlineStickers: [:], mediaReference: .standalone(media: file), threadId: nil, replyToMessageId: nil, replyToStoryId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: []) let _ = enqueueMessages(account: context.account, peerId: peerId, messages: [message]).start() @@ -511,8 +510,8 @@ private enum DebugControllerEntry: ItemListNodeEntry { } } - let tempSource = TempBox.shared.tempFile(fileName: "Log.txt") - let tempZip = TempBox.shared.tempFile(fileName: "destination.zip") + let tempSource = EngineTempBox.shared.tempFile(fileName: "Log.txt") + let tempZip = EngineTempBox.shared.tempFile(fileName: "destination.zip") let _ = try? rawLogData.write(to: URL(fileURLWithPath: tempSource.path)) @@ -522,14 +521,14 @@ private enum DebugControllerEntry: ItemListNodeEntry { return } - TempBox.shared.dispose(tempSource) - TempBox.shared.dispose(tempZip) + EngineTempBox.shared.dispose(tempSource) + EngineTempBox.shared.dispose(tempZip) let id = Int64.random(in: Int64.min ... Int64.max) let fileResource = LocalFileMediaResource(fileId: id, size: Int64(gzippedData.count), isSecretRelated: false) context.engine.resources.storeResourceData(id: EngineMediaResource.Id(fileResource.id), data: gzippedData) - let file = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/text", size: Int64(gzippedData.count), attributes: [.FileName(fileName: "Log-iOS-Full.txt.zip")], alternativeRepresentations: []) + let file = TelegramMediaFile(fileId: EngineMedia.Id(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/text", size: Int64(gzippedData.count), attributes: [.FileName(fileName: "Log-iOS-Full.txt.zip")], alternativeRepresentations: []) let message: EnqueueMessage = .message(text: "", attributes: [], inlineStickers: [:], mediaReference: .standalone(media: file), threadId: nil, replyToMessageId: nil, replyToStoryId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: []) let _ = enqueueMessages(account: context.account, peerId: peerId, messages: [message]).start() @@ -595,8 +594,8 @@ private enum DebugControllerEntry: ItemListNodeEntry { } } - let tempSource = TempBox.shared.tempFile(fileName: "Log.txt") - let tempZip = TempBox.shared.tempFile(fileName: "destination.zip") + let tempSource = EngineTempBox.shared.tempFile(fileName: "Log.txt") + let tempZip = EngineTempBox.shared.tempFile(fileName: "destination.zip") let _ = try? rawLogData.write(to: URL(fileURLWithPath: tempSource.path)) @@ -606,14 +605,14 @@ private enum DebugControllerEntry: ItemListNodeEntry { return } - TempBox.shared.dispose(tempSource) - TempBox.shared.dispose(tempZip) + EngineTempBox.shared.dispose(tempSource) + EngineTempBox.shared.dispose(tempZip) let id = Int64.random(in: Int64.min ... Int64.max) let fileResource = LocalFileMediaResource(fileId: id, size: Int64(gzippedData.count), isSecretRelated: false) context.engine.resources.storeResourceData(id: EngineMediaResource.Id(fileResource.id), data: gzippedData) - let file = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/text", size: Int64(gzippedData.count), attributes: [.FileName(fileName: "Log-iOS-Full.txt.zip")], alternativeRepresentations: []) + let file = TelegramMediaFile(fileId: EngineMedia.Id(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/text", size: Int64(gzippedData.count), attributes: [.FileName(fileName: "Log-iOS-Full.txt.zip")], alternativeRepresentations: []) let message: EnqueueMessage = .message(text: "", attributes: [], inlineStickers: [:], mediaReference: .standalone(media: file), threadId: nil, replyToMessageId: nil, replyToStoryId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: []) let _ = enqueueMessages(account: context.account, peerId: peerId, messages: [message]).start() @@ -680,8 +679,8 @@ private enum DebugControllerEntry: ItemListNodeEntry { } } - let tempSource = TempBox.shared.tempFile(fileName: "Log.txt") - let tempZip = TempBox.shared.tempFile(fileName: "destination.zip") + let tempSource = EngineTempBox.shared.tempFile(fileName: "Log.txt") + let tempZip = EngineTempBox.shared.tempFile(fileName: "destination.zip") let _ = try? rawLogData.write(to: URL(fileURLWithPath: tempSource.path)) @@ -691,14 +690,14 @@ private enum DebugControllerEntry: ItemListNodeEntry { return } - TempBox.shared.dispose(tempSource) - TempBox.shared.dispose(tempZip) + EngineTempBox.shared.dispose(tempSource) + EngineTempBox.shared.dispose(tempZip) let id = Int64.random(in: Int64.min ... Int64.max) let fileResource = LocalFileMediaResource(fileId: id, size: Int64(gzippedData.count), isSecretRelated: false) context.engine.resources.storeResourceData(id: EngineMediaResource.Id(fileResource.id), data: gzippedData) - let file = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/text", size: Int64(gzippedData.count), attributes: [.FileName(fileName: "Log-iOS-Full.txt.zip")], alternativeRepresentations: []) + let file = TelegramMediaFile(fileId: EngineMedia.Id(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/text", size: Int64(gzippedData.count), attributes: [.FileName(fileName: "Log-iOS-Full.txt.zip")], alternativeRepresentations: []) let message: EnqueueMessage = .message(text: "", attributes: [], inlineStickers: [:], mediaReference: .standalone(media: file), threadId: nil, replyToMessageId: nil, replyToStoryId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: []) let _ = enqueueMessages(account: context.account, peerId: peerId, messages: [message]).start() @@ -751,7 +750,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { let messages = logs.map { (name, path) -> EnqueueMessage in let id = Int64.random(in: Int64.min ... Int64.max) - let file = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: LocalFileReferenceMediaResource(localFilePath: path, randomId: id), previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/text", size: nil, attributes: [.FileName(fileName: name)], alternativeRepresentations: []) + let file = TelegramMediaFile(fileId: EngineMedia.Id(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: LocalFileReferenceMediaResource(localFilePath: path, randomId: id), previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/text", size: nil, attributes: [.FileName(fileName: name)], alternativeRepresentations: []) return .message(text: "", attributes: [], inlineStickers: [:], mediaReference: .standalone(media: file), threadId: nil, replyToMessageId: nil, replyToStoryId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: []) } let _ = enqueueMessages(account: context.account, peerId: peerId, messages: messages).start() @@ -824,9 +823,9 @@ private enum DebugControllerEntry: ItemListNodeEntry { let lineFeed = "\n".data(using: .utf8)! - var tempSources: [TempBoxFile] = [] + var tempSources: [EngineTempBox.File] = [] for (type, logItems) in allLogs { - let tempSource = TempBox.shared.tempFile(fileName: "Log-\(type).txt") + let tempSource = EngineTempBox.shared.tempFile(fileName: "Log-\(type).txt") var rawLogData: Data = Data() for (name, path) in logItems { @@ -846,21 +845,21 @@ private enum DebugControllerEntry: ItemListNodeEntry { tempSources.append(tempSource) } - let tempZip = TempBox.shared.tempFile(fileName: "destination.zip") + let tempZip = EngineTempBox.shared.tempFile(fileName: "destination.zip") SSZipArchive.createZipFile(atPath: tempZip.path, withFilesAtPaths: tempSources.map(\.path)) guard let gzippedData = try? Data(contentsOf: URL(fileURLWithPath: tempZip.path)) else { return } - tempSources.forEach(TempBox.shared.dispose) - TempBox.shared.dispose(tempZip) + tempSources.forEach(EngineTempBox.shared.dispose) + EngineTempBox.shared.dispose(tempZip) let id = Int64.random(in: Int64.min ... Int64.max) let fileResource = LocalFileMediaResource(fileId: id, size: Int64(gzippedData.count), isSecretRelated: false) context.engine.resources.storeResourceData(id: EngineMediaResource.Id(fileResource.id), data: gzippedData) - let file = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/zip", size: Int64(gzippedData.count), attributes: [.FileName(fileName: "Log-iOS-All.txt.zip")], alternativeRepresentations: []) + let file = TelegramMediaFile(fileId: EngineMedia.Id(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/zip", size: Int64(gzippedData.count), attributes: [.FileName(fileName: "Log-iOS-All.txt.zip")], alternativeRepresentations: []) let message: EnqueueMessage = .message(text: "", attributes: [], inlineStickers: [:], mediaReference: .standalone(media: file), threadId: nil, replyToMessageId: nil, replyToStoryId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: []) let _ = enqueueMessages(account: context.account, peerId: peerId, messages: [message]).start() @@ -915,7 +914,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { let fileResource = LocalFileMediaResource(fileId: id, size: Int64(allStatsData.count), isSecretRelated: false) context.engine.resources.storeResourceData(id: EngineMediaResource.Id(fileResource.id), data: allStatsData) - let file = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/zip", size: Int64(allStatsData.count), attributes: [.FileName(fileName: "StorageReport.txt")], alternativeRepresentations: []) + let file = TelegramMediaFile(fileId: EngineMedia.Id(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/zip", size: Int64(allStatsData.count), attributes: [.FileName(fileName: "StorageReport.txt")], alternativeRepresentations: []) let message: EnqueueMessage = .message(text: "", attributes: [], inlineStickers: [:], mediaReference: .standalone(media: file), threadId: nil, replyToMessageId: nil, replyToStoryId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: []) let _ = enqueueMessages(account: context.account, peerId: peerId, messages: [message]).start() @@ -1244,7 +1243,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.chatListPhotos = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1254,7 +1253,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.knockoutWallpaper = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1264,7 +1263,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.experimentalCompatibility = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1274,7 +1273,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.enableDebugDataDisplay = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1284,7 +1283,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.fakeGlass = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1294,7 +1293,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.forceClearGlass = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1304,7 +1303,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.debugRipple = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1314,7 +1313,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.debugRichText = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1324,7 +1323,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.browserExperiment = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1334,7 +1333,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.allForumsHaveTabs = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1348,7 +1347,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { settings.accountReactionEffectOverrides.removeAll() settings.accountStickerEffectOverrides.removeAll() } - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1358,7 +1357,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.compressedEmojiCache = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1368,7 +1367,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.storiesJpegExperiment = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1378,7 +1377,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.checkSerializedData = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1388,7 +1387,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.disableQuickReaction = !value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1398,7 +1397,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.liveStreamV2 = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1408,7 +1407,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.experimentalCallMute = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1418,7 +1417,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.playerV2 = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1428,7 +1427,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.devRequests = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1438,7 +1437,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.enableUpdates = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1448,7 +1447,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.enablePWA = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1458,7 +1457,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.enableLocalTranslation = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1468,7 +1467,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.preferredVideoCodec = value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1478,7 +1477,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings settings.disableVideoAspectScaling = !value - return PreferencesEntry(settings) + return EnginePreferencesEntry(settings) }) }).start() }) @@ -1681,7 +1680,7 @@ public func debugController(sharedContext: SharedAccountContext, context: Accoun hasLegacyAppData = FileManager.default.fileExists(atPath: statusPath) } - let preferencesSignal: Signal + let preferencesSignal: Signal if let context = context { preferencesSignal = context.engine.data.subscribe(TelegramEngine.EngineData.Item.Configuration.ApplicationSpecificPreference(key: PreferencesKeys.networkSettings)) } else { @@ -1776,8 +1775,8 @@ public func triggerDebugSendLogsUI(context: AccountContext, additionalInfo: Stri rawLogData.append("\(additionalInfo)".data(using: .utf8)!) } - let tempSource = TempBox.shared.tempFile(fileName: "Log.txt") - let tempZip = TempBox.shared.tempFile(fileName: "destination.zip") + let tempSource = EngineTempBox.shared.tempFile(fileName: "Log.txt") + let tempZip = EngineTempBox.shared.tempFile(fileName: "destination.zip") let _ = try? rawLogData.write(to: URL(fileURLWithPath: tempSource.path)) @@ -1787,14 +1786,14 @@ public func triggerDebugSendLogsUI(context: AccountContext, additionalInfo: Stri return } - TempBox.shared.dispose(tempSource) - TempBox.shared.dispose(tempZip) + EngineTempBox.shared.dispose(tempSource) + EngineTempBox.shared.dispose(tempZip) let id = Int64.random(in: Int64.min ... Int64.max) let fileResource = LocalFileMediaResource(fileId: id, size: Int64(gzippedData.count), isSecretRelated: false) context.engine.resources.storeResourceData(id: EngineMediaResource.Id(fileResource.id), data: gzippedData) - let file = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/text", size: Int64(gzippedData.count), attributes: [.FileName(fileName: "Log-iOS-Full.txt.zip")], alternativeRepresentations: []) + let file = TelegramMediaFile(fileId: EngineMedia.Id(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/text", size: Int64(gzippedData.count), attributes: [.FileName(fileName: "Log-iOS-Full.txt.zip")], alternativeRepresentations: []) let message: EnqueueMessage = .message(text: "", attributes: [], inlineStickers: [:], mediaReference: .standalone(media: file), threadId: nil, replyToMessageId: nil, replyToStoryId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: []) let _ = enqueueMessages(account: context.account, peerId: peerId, messages: [message]).start() diff --git a/submodules/GalleryData/Sources/GalleryData.swift b/submodules/GalleryData/Sources/GalleryData.swift index c694af95f8..3e8e70523f 100644 --- a/submodules/GalleryData/Sources/GalleryData.swift +++ b/submodules/GalleryData/Sources/GalleryData.swift @@ -231,7 +231,7 @@ public func chatMessageGalleryControllerData( } } - let gallery = InstantPageGalleryController(context: context, userLocation: chatLocation?.peerId.flatMap(MediaResourceUserLocation.peer) ?? .other, webPage: webPage, message: message, entries: instantPageMedia, centralIndex: centralIndex, fromPlayingVideo: autoplayingVideo, landscape: landscape, timecode: timecode, replaceRootController: { [weak navigationController] controller, ready in + let gallery = InstantPageGalleryController(context: context, userLocation: chatLocation?.peerId.flatMap(MediaResourceUserLocation.peer) ?? .other, webPage: webPage, message: EngineMessage(message), entries: instantPageMedia, centralIndex: centralIndex, fromPlayingVideo: autoplayingVideo, landscape: landscape, timecode: timecode, replaceRootController: { [weak navigationController] controller, ready in if let navigationController = navigationController { navigationController.replaceTopController(controller, animated: false, ready: ready) } diff --git a/submodules/GalleryUI/Sources/ChatVideoGalleryItemScrubberView.swift b/submodules/GalleryUI/Sources/ChatVideoGalleryItemScrubberView.swift index 58f740c35b..ea0aaa8fa3 100644 --- a/submodules/GalleryUI/Sources/ChatVideoGalleryItemScrubberView.swift +++ b/submodules/GalleryUI/Sources/ChatVideoGalleryItemScrubberView.swift @@ -3,7 +3,6 @@ import UIKit import AsyncDisplayKit import SwiftSignalKit import TelegramCore -import Postbox import Display import UniversalMediaPlayer import TelegramPresentationData @@ -304,7 +303,7 @@ final class ChatVideoGalleryItemScrubberView: UIView { self.scrubberNode.bufferingStatus = status } - func setFetchStatusSignal(_ fetchStatus: Signal?, strings: PresentationStrings, decimalSeparator: String, fileSize: Int64?) { + func setFetchStatusSignal(_ fetchStatus: Signal?, strings: PresentationStrings, decimalSeparator: String, fileSize: Int64?) { let formatting = DataSizeStringFormatting(strings: strings, decimalSeparator: decimalSeparator) if let fileSize = fileSize { if let fetchStatus = fetchStatus { diff --git a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift index 32153dae56..ba222b9a7a 100644 --- a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift @@ -1651,10 +1651,10 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { } let status = messageMediaFileStatus(context: item.context, messageId: message.id, file: file) if !isWebpage && message.adAttribute == nil && !NativeVideoContent.isHLSVideo(file: file) { - scrubberView.setFetchStatusSignal(status, strings: self.presentationData.strings, decimalSeparator: self.presentationData.dateTimeFormat.decimalSeparator, fileSize: file.size) + scrubberView.setFetchStatusSignal(status |> map(EngineMediaResource.FetchStatus.init), strings: self.presentationData.strings, decimalSeparator: self.presentationData.dateTimeFormat.decimalSeparator, fileSize: file.size) } - self.requiresDownload = !isMediaStreamable(message: message, media: file) + self.requiresDownload = !isMediaStreamable(message: EngineMessage(message), media: file) mediaFileStatus = status |> map(Optional.init) self.fetchControls = FetchControls(fetch: { [weak self] in if let strongSelf = self { @@ -2150,7 +2150,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { } var isStreamable = false if let contentInfo = item.contentInfo, case let .message(message, _) = contentInfo { - isStreamable = isMediaStreamable(message: message, media: content.fileReference.media) + isStreamable = isMediaStreamable(message: EngineMessage(message), media: content.fileReference.media) } else { isStreamable = isMediaStreamable(media: content.fileReference.media) } @@ -3053,7 +3053,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { } overlayNode.canAttachContent = false }) - } else if let info = context.sharedContext.mediaManager.galleryHiddenMediaManager.findTarget(messageId: id, media: media) { + } else if let info = context.sharedContext.mediaManager.galleryHiddenMediaManager.findTarget(messageId: id, media: EngineMedia(media)) { return GalleryTransitionArguments(transitionNode: (info.1, info.1.bounds, { return info.2() }), addToTransitionSurface: info.0) diff --git a/submodules/InstantPageCache/BUILD b/submodules/InstantPageCache/BUILD index 0b2afced14..fa64e1b83f 100644 --- a/submodules/InstantPageCache/BUILD +++ b/submodules/InstantPageCache/BUILD @@ -11,7 +11,6 @@ swift_library( ], deps = [ "//submodules/TelegramCore:TelegramCore", - "//submodules/Postbox:Postbox", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/TelegramUIPreferences:TelegramUIPreferences", "//submodules/PersistentStringHash:PersistentStringHash", diff --git a/submodules/InstantPageCache/Sources/CachedInstantPages.swift b/submodules/InstantPageCache/Sources/CachedInstantPages.swift index 182e3d47bf..a263ad1cf6 100644 --- a/submodules/InstantPageCache/Sources/CachedInstantPages.swift +++ b/submodules/InstantPageCache/Sources/CachedInstantPages.swift @@ -2,40 +2,39 @@ import Foundation import UIKit import SwiftSignalKit import TelegramCore -import Postbox import TelegramUIPreferences import PersistentStringHash public final class CachedInstantPage: Codable { public let webPage: TelegramMediaWebpage public let timestamp: Int32 - + public init(webPage: TelegramMediaWebpage, timestamp: Int32) { self.webPage = webPage self.timestamp = timestamp } - + public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: StringCodingKey.self) - let webPageData = try container.decode(AdaptedPostboxDecoder.RawObjectData.self, forKey: "webpage") - self.webPage = TelegramMediaWebpage(decoder: PostboxDecoder(buffer: MemoryBuffer(data: webPageData.data))) + let webPageData = try container.decode(EngineAdaptedPostboxDecoder.RawObjectData.self, forKey: "webpage") + self.webPage = TelegramMediaWebpage(decoder: EnginePostboxDecoder(buffer: EngineMemoryBuffer(data: webPageData.data))) self.timestamp = try container.decode(Int32.self, forKey: "timestamp") } - + public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: StringCodingKey.self) - try container.encode(PostboxEncoder().encodeObjectToRawData(self.webPage), forKey: "webpage") + try container.encode(EnginePostboxEncoder().encodeObjectToRawData(self.webPage), forKey: "webpage") try container.encode(self.timestamp, forKey: "timestamp") } } public func cachedInstantPage(engine: TelegramEngine, url: String) -> Signal { - let key = ValueBoxKey(length: 8) + let key = EngineDataBuffer(length: 8) key.setInt64(0, value: Int64(bitPattern: url.persistentHashValue)) - + return engine.data.get(TelegramEngine.EngineData.Item.ItemCache.Item(collectionId: ApplicationSpecificItemCacheCollectionId.cachedInstantPages, id: key)) |> map { entry -> CachedInstantPage? in return entry?.get(CachedInstantPage.self) @@ -43,7 +42,7 @@ public func cachedInstantPage(engine: TelegramEngine, url: String) -> Signal Signal { - let key = ValueBoxKey(length: 8) + let key = EngineDataBuffer(length: 8) key.setInt64(0, value: Int64(bitPattern: url.persistentHashValue)) if let webPage = webPage { diff --git a/submodules/InstantPageUI/Sources/InstantPageController.swift b/submodules/InstantPageUI/Sources/InstantPageController.swift index 80cce10a66..02b499cf30 100644 --- a/submodules/InstantPageUI/Sources/InstantPageController.swift +++ b/submodules/InstantPageUI/Sources/InstantPageController.swift @@ -7,7 +7,7 @@ import TelegramPresentationData import TelegramUIPreferences import AccountContext -public func instantPageAndAnchor(message: Message) -> (TelegramMediaWebpage, String?)? { +public func instantPageAndAnchor(message: EngineMessage) -> (TelegramMediaWebpage, String?)? { for media in message.media { if let webpage = media as? TelegramMediaWebpage, case let .Loaded(content) = webpage.content { if let _ = content.instantPage { diff --git a/submodules/InstantPageUI/Sources/InstantPageGalleryController.swift b/submodules/InstantPageUI/Sources/InstantPageGalleryController.swift index 52b551f63d..f0d432adc1 100644 --- a/submodules/InstantPageUI/Sources/InstantPageGalleryController.swift +++ b/submodules/InstantPageUI/Sources/InstantPageGalleryController.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import Display import QuickLook -import Postbox import SwiftSignalKit import AsyncDisplayKit import TelegramCore @@ -29,13 +28,13 @@ public struct InstantPageGalleryEntryLocation: Equatable { public struct InstantPageGalleryEntry: Equatable { public let index: Int32 - public let pageId: MediaId + public let pageId: EngineMedia.Id public let media: InstantPageMedia public let caption: RichText? public let credit: RichText? public let location: InstantPageGalleryEntryLocation? - public init(index: Int32, pageId: MediaId, media: InstantPageMedia, caption: RichText?, credit: RichText?, location: InstantPageGalleryEntryLocation?) { + public init(index: Int32, pageId: EngineMedia.Id, media: InstantPageMedia, caption: RichText?, credit: RichText?, location: InstantPageGalleryEntryLocation?) { self.index = index self.pageId = pageId self.media = media @@ -48,7 +47,7 @@ public struct InstantPageGalleryEntry: Equatable { return lhs.index == rhs.index && lhs.pageId == rhs.pageId && lhs.media == rhs.media && lhs.caption == rhs.caption && lhs.credit == rhs.credit && lhs.location == rhs.location } - func item(context: AccountContext, userLocation: MediaResourceUserLocation, webPage: TelegramMediaWebpage, message: Message?, presentationData: PresentationData, fromPlayingVideo: Bool, landscape: Bool, openUrl: @escaping (InstantPageUrlItem) -> Void, openUrlOptions: @escaping (InstantPageUrlItem) -> Void, getPreloadedResource: @escaping (String) -> Data?) -> GalleryItem { + func item(context: AccountContext, userLocation: MediaResourceUserLocation, webPage: TelegramMediaWebpage, message: EngineMessage?, presentationData: PresentationData, fromPlayingVideo: Bool, landscape: Bool, openUrl: @escaping (InstantPageUrlItem) -> Void, openUrlOptions: @escaping (InstantPageUrlItem) -> Void, getPreloadedResource: @escaping (String) -> Data?) -> GalleryItem { let caption: NSAttributedString let credit: NSAttributedString @@ -119,7 +118,7 @@ public struct InstantPageGalleryEntry: Equatable { if let dimensions = file.dimensions { representations.append(TelegramMediaImageRepresentation(dimensions: dimensions, resource: file.resource, progressiveSizes: [], immediateThumbnailData: nil, hasVideo: false, isPersonal: false)) } - let image = TelegramMediaImage(imageId: MediaId(namespace: 0, id: 0), representations: representations, immediateThumbnailData: file.immediateThumbnailData, reference: nil, partialReference: nil, flags: []) + let image = TelegramMediaImage(imageId: EngineMedia.Id(namespace: 0, id: 0), representations: representations, immediateThumbnailData: file.immediateThumbnailData, reference: nil, partialReference: nil, flags: []) return InstantImageGalleryItem(context: context, presentationData: presentationData, itemId: self.index, userLocation: userLocation, imageReference: .webPage(webPage: WebpageReference(webPage), media: image), caption: caption, credit: credit, location: self.location, openUrl: openUrl, openUrlOptions: openUrlOptions, getPreloadedResource: getPreloadedResource) } } else if case let .webpage(embedWebpage) = self.media.media, case let .Loaded(webpageContent) = embedWebpage.content { @@ -166,7 +165,7 @@ public class InstantPageGalleryController: ViewController, StandalonePresentable private let context: AccountContext private let userLocation: MediaResourceUserLocation private let webPage: TelegramMediaWebpage - private let message: Message? + private let message: EngineMessage? private var presentationData: PresentationData private let _ready = Promise() @@ -203,7 +202,7 @@ public class InstantPageGalleryController: ViewController, StandalonePresentable private var openUrlOptions: (InstantPageUrlItem) -> Void private let getPreloadedResource: (String) -> Data? - public init(context: AccountContext, userLocation: MediaResourceUserLocation, webPage: TelegramMediaWebpage, message: Message? = nil, entries: [InstantPageGalleryEntry], centralIndex: Int, fromPlayingVideo: Bool = false, landscape: Bool = false, timecode: Double? = nil, replaceRootController: @escaping (ViewController, Promise?) -> Void, baseNavigationController: NavigationController?, getPreloadedResource: @escaping (String) -> Data? = { _ in return nil }) { + public init(context: AccountContext, userLocation: MediaResourceUserLocation, webPage: TelegramMediaWebpage, message: EngineMessage? = nil, entries: [InstantPageGalleryEntry], centralIndex: Int, fromPlayingVideo: Bool = false, landscape: Bool = false, timecode: Double? = nil, replaceRootController: @escaping (ViewController, Promise?) -> Void, baseNavigationController: NavigationController?, getPreloadedResource: @escaping (String) -> Data? = { _ in return nil }) { self.context = context self.userLocation = userLocation self.webPage = webPage diff --git a/submodules/ItemListPeerItem/BUILD b/submodules/ItemListPeerItem/BUILD index b5fb4ad41c..464ec3f91b 100644 --- a/submodules/ItemListPeerItem/BUILD +++ b/submodules/ItemListPeerItem/BUILD @@ -14,7 +14,6 @@ swift_library( "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", "//submodules/TelegramCore:TelegramCore", - "//submodules/Postbox:Postbox", "//submodules/AvatarNode:AvatarNode", "//submodules/TelegramPresentationData:TelegramPresentationData", "//submodules/TelegramStringFormatting:TelegramStringFormatting", diff --git a/submodules/ItemListPeerItem/Sources/ItemListPeerItem.swift b/submodules/ItemListPeerItem/Sources/ItemListPeerItem.swift index 2d999a8023..11e9c2d5a2 100644 --- a/submodules/ItemListPeerItem/Sources/ItemListPeerItem.swift +++ b/submodules/ItemListPeerItem/Sources/ItemListPeerItem.swift @@ -4,7 +4,6 @@ import Display import AsyncDisplayKit import SwiftSignalKit import TelegramCore -import Postbox import TelegramPresentationData import TelegramUIPreferences import ItemListUI @@ -467,7 +466,7 @@ public final class ItemListPeerItem: ListViewItem, ItemListItem { let displayDecorations: Bool let displayBackground: Bool let disableInteractiveTransitionIfNecessary: Bool - let storyStats: PeerStoryStats? + let storyStats: EnginePeerStoryStats? let openStories: ((UIView) -> Void)? public init( @@ -511,7 +510,7 @@ public final class ItemListPeerItem: ListViewItem, ItemListItem { displayDecorations: Bool = true, displayBackground: Bool = true, disableInteractiveTransitionIfNecessary: Bool = false, - storyStats: PeerStoryStats? = nil, + storyStats: EnginePeerStoryStats? = nil, openStories: ((UIView) -> Void)? = nil ) { self.presentationData = presentationData @@ -599,7 +598,7 @@ public final class ItemListPeerItem: ListViewItem, ItemListItem { displayDecorations: Bool = true, displayBackground: Bool = true, disableInteractiveTransitionIfNecessary: Bool = false, - storyStats: PeerStoryStats? = nil, + storyStats: EnginePeerStoryStats? = nil, openStories: ((UIView) -> Void)? = nil ) { self.presentationData = presentationData diff --git a/submodules/LegacyMediaPickerUI/Sources/LegacyAttachmentMenu.swift b/submodules/LegacyMediaPickerUI/Sources/LegacyAttachmentMenu.swift index a8b9c9cb79..c3e477107c 100644 --- a/submodules/LegacyMediaPickerUI/Sources/LegacyAttachmentMenu.swift +++ b/submodules/LegacyMediaPickerUI/Sources/LegacyAttachmentMenu.swift @@ -3,7 +3,6 @@ import UIKit import LegacyComponents import Display import SwiftSignalKit -import Postbox import TelegramCore import TelegramPresentationData import DeviceAccess @@ -159,7 +158,7 @@ public func legacyStoryMediaEditor(context: AccountContext, item: TGMediaEditabl public func legacyMediaEditor( context: AccountContext, - peer: Peer, + peer: EnginePeer, threadTitle: String?, media: AnyMediaReference, mode: LegacyMediaEditorMode, @@ -201,7 +200,7 @@ public func legacyMediaEditor( if peer.id == context.account.peerId { recipientName = presentationData.strings.DialogList_SavedMessages } else { - recipientName = EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder) + recipientName = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder) } } @@ -299,7 +298,7 @@ public func legacyMediaEditor( public func legacyAttachmentMenu( context: AccountContext, - peer: Peer?, + peer: EnginePeer?, threadTitle: String?, chatLocation: ChatLocation, editMediaOptions: LegacyAttachmentMenuMediaEditing?, @@ -310,7 +309,7 @@ public func legacyAttachmentMenu( canSendPolls: Bool, updatedPresentationData: (initial: PresentationData, signal: Signal), parentController: LegacyController, - recentlyUsedInlineBots: [Peer], + recentlyUsedInlineBots: [EnginePeer], initialCaption: NSAttributedString, openGallery: @escaping () -> Void, openCamera: @escaping (TGAttachmentCameraView?, TGMenuSheetController?) -> Void, @@ -325,7 +324,7 @@ public func legacyAttachmentMenu( presentSchedulePicker: @escaping (Bool, @escaping (Int32, Bool) -> Void) -> Void, presentTimerPicker: @escaping (@escaping (Int32) -> Void) -> Void, sendMessagesWithSignals: @escaping ([Any]?, Bool, Int32, ((String) -> UIView?)?, @escaping () -> Void) -> Void, - selectRecentlyUsedInlineBot: @escaping (Peer) -> Void, + selectRecentlyUsedInlineBot: @escaping (EnginePeer) -> Void, getCaptionPanelView: @escaping () -> TGCaptionPanelView?, present: @escaping (ViewController, Any?) -> Void ) -> TGMenuSheetController { @@ -340,7 +339,7 @@ public func legacyAttachmentMenu( if peer.id == context.account.peerId { recipientName = presentationData.strings.DialogList_SavedMessages } else { - recipientName = EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder) + recipientName = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder) } } else { recipientName = "" @@ -384,7 +383,7 @@ public func legacyAttachmentMenu( var selectionLimit: Int32 = 100 var slowModeEnabled = false - if let channel = peer as? TelegramChannel, channel.isRestrictedBySlowmode { + if case let .channel(channel) = peer, channel.isRestrictedBySlowmode { slowModeEnabled = true selectionLimit = 10 } @@ -423,7 +422,7 @@ public func legacyAttachmentMenu( presentSelectionLimitExceeded() } if let peer, peer.id != context.account.peerId { - if peer is TelegramUser { + if case .user = peer { carouselItem.hasTimer = hasSchedule } carouselItem.hasSilentPosting = true @@ -573,7 +572,7 @@ public func legacyAttachmentMenu( let recipientName: String if let peer { - recipientName = EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder) + recipientName = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder) } else { recipientName = "" } @@ -615,13 +614,16 @@ public func legacyAttachmentMenu( var peerSupportsPolls = false if let peer { - if peer is TelegramGroup || peer is TelegramChannel { + switch peer { + case .legacyGroup, .channel: peerSupportsPolls = true - } else if let user = peer as? TelegramUser, let _ = user.botInfo { + case let .user(user) where user.botInfo != nil: peerSupportsPolls = true + default: + break } } - if let peer, peerSupportsPolls, canSendMessagesToPeer(EnginePeer(peer)) && canSendPolls { + if let peer, peerSupportsPolls, canSendMessagesToPeer(peer) && canSendPolls { let pollItem = TGMenuSheetButtonItemView(title: presentationData.strings.AttachmentMenu_Poll, type: TGMenuSheetButtonTypeDefault, fontSize: fontSize, action: { [weak controller] in controller?.dismiss(animated: true) openPoll() diff --git a/submodules/ListMessageItem/Sources/ListMessageHoleItem.swift b/submodules/ListMessageItem/Sources/ListMessageHoleItem.swift index f4960900a3..95850378d5 100644 --- a/submodules/ListMessageItem/Sources/ListMessageHoleItem.swift +++ b/submodules/ListMessageItem/Sources/ListMessageHoleItem.swift @@ -4,7 +4,6 @@ import AsyncDisplayKit import Display import TelegramCore import SwiftSignalKit -import Postbox final class ListMessageHoleItem: ListViewItem { public init() { @@ -103,7 +102,7 @@ final class ListMessageHoleItemNode: ListViewItemNode { } } - func transitionNode(id: MessageId, media: Media) -> ASDisplayNode? { + func transitionNode(id: EngineMessage.Id, media: EngineMedia) -> ASDisplayNode? { return nil } diff --git a/submodules/LocalMediaResources/Sources/FetchPhotoLibraryImageResource.swift b/submodules/LocalMediaResources/Sources/FetchPhotoLibraryImageResource.swift index f19199c1aa..fe3d654156 100644 --- a/submodules/LocalMediaResources/Sources/FetchPhotoLibraryImageResource.swift +++ b/submodules/LocalMediaResources/Sources/FetchPhotoLibraryImageResource.swift @@ -1,8 +1,8 @@ import Foundation import UIKit import Photos -import Postbox import SwiftSignalKit +import TelegramCore import ImageCompression import Accelerate.vImage import CoreImage @@ -104,7 +104,7 @@ extension UIImage.Orientation { private let fetchPhotoWorkers = ThreadPool(threadCount: 3, threadPriority: 0.2) -public func fetchPhotoLibraryResource(localIdentifier: String, width: Int32?, height: Int32?, format: MediaImageFormat?, quality: Int32?, hd: Bool, useExif: Bool) -> Signal { +public func fetchPhotoLibraryResource(localIdentifier: String, width: Int32?, height: Int32?, format: MediaImageFormat?, quality: Int32?, hd: Bool, useExif: Bool) -> Signal { return Signal { subscriber in let queue = ThreadPoolQueue(threadPool: fetchPhotoWorkers) @@ -178,9 +178,9 @@ public func fetchPhotoLibraryResource(localIdentifier: String, width: Int32?, he switch format { case .none, .jpeg: - 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 scaledImage = scaledImage, let data = compressImageToJPEG(scaledImage, quality: 0.6, tempFilePath: tempFile.path) { #if DEBUG diff --git a/submodules/MediaPickerUI/Sources/MediaPickerGridItem.swift b/submodules/MediaPickerUI/Sources/MediaPickerGridItem.swift index e7e9c914fb..5f04d5f4ca 100644 --- a/submodules/MediaPickerUI/Sources/MediaPickerGridItem.swift +++ b/submodules/MediaPickerUI/Sources/MediaPickerGridItem.swift @@ -4,7 +4,6 @@ import Display import TelegramCore import SwiftSignalKit import AsyncDisplayKit -import Postbox import AccountContext import TelegramPresentationData import TelegramStringFormatting diff --git a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift index 8e176c8f43..142ad3d7dc 100644 --- a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift +++ b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import Display import AsyncDisplayKit -import Postbox import TelegramCore import SwiftSignalKit import AccountContext diff --git a/submodules/MediaResources/Sources/CachedResourceRepresentations.swift b/submodules/MediaResources/Sources/CachedResourceRepresentations.swift index 9a606ab092..e18def94d7 100644 --- a/submodules/MediaResources/Sources/CachedResourceRepresentations.swift +++ b/submodules/MediaResources/Sources/CachedResourceRepresentations.swift @@ -1,6 +1,7 @@ import Foundation import UIKit import SwiftSignalKit +import Postbox public final class CachedStickerAJpegRepresentation: CachedMediaResourceRepresentation { public let size: CGSize? diff --git a/submodules/MediaResources/Sources/MediaPlaybackStoredState.swift b/submodules/MediaResources/Sources/MediaPlaybackStoredState.swift index bdb545a9e2..1bc2629737 100644 --- a/submodules/MediaResources/Sources/MediaPlaybackStoredState.swift +++ b/submodules/MediaResources/Sources/MediaPlaybackStoredState.swift @@ -3,7 +3,6 @@ import UIKit import SwiftSignalKit import TelegramCore import TelegramUIPreferences -import Postbox public final class MediaPlaybackStoredState: Codable { public let timestamp: Double @@ -47,7 +46,7 @@ public func mediaPlaybackStoredState(engine: TelegramEngine, messageId: EngineMe public func updateMediaPlaybackStoredStateInteractively(engine: TelegramEngine, messageId: EngineMessage.Id, state: MediaPlaybackStoredState?) -> Signal { return engine.messages.updateLocallyDerivedData(messageId: messageId, update: { data in var data = data - if let state, let entry = CodableEntry(state) { + if let state, let entry = EngineCodableEntry(state) { data["mps"] = entry } else { data.removeValue(forKey: "mps") diff --git a/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupActionSheetItem.swift b/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupActionSheetItem.swift index 2418f972f1..e4d23c55a5 100644 --- a/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupActionSheetItem.swift +++ b/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupActionSheetItem.swift @@ -3,7 +3,6 @@ import UIKit import AsyncDisplayKit import UIKit import Display -import Postbox import TelegramCore import TelegramPresentationData import TelegramUIPreferences @@ -12,12 +11,12 @@ import AccountContext final class ChannelDiscussionGroupActionSheetItem: ActionSheetItem { let context: AccountContext - let channelPeer: Peer - let groupPeer: Peer + let channelPeer: EnginePeer + let groupPeer: EnginePeer let strings: PresentationStrings let nameDisplayOrder: PresentationPersonNameOrder - - init(context: AccountContext, channelPeer: Peer, groupPeer: Peer, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder) { + + init(context: AccountContext, channelPeer: EnginePeer, groupPeer: EnginePeer, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder) { self.context = context self.channelPeer = channelPeer self.groupPeer = groupPeer @@ -43,7 +42,7 @@ private final class ChannelDiscussionGroupActionSheetItemNode: ActionSheetItemNo private let groupAvatarNode: AvatarNode private let textNode: ImmediateTextNode - init(theme: ActionSheetControllerTheme, context: AccountContext, channelPeer: Peer, groupPeer: Peer, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder) { + init(theme: ActionSheetControllerTheme, context: AccountContext, channelPeer: EnginePeer, groupPeer: EnginePeer, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder) { self.theme = theme self.channelAvatarNode = AvatarNode(font: avatarFont) @@ -65,14 +64,14 @@ private final class ChannelDiscussionGroupActionSheetItemNode: ActionSheetItemNo self.addSubnode(self.channelAvatarNode) self.addSubnode(self.textNode) - self.channelAvatarNode.setPeer(context: context, theme: (context.sharedContext.currentPresentationData.with { $0 }).theme, peer: EnginePeer(channelPeer)) - self.groupAvatarNode.setPeer(context: context, theme: (context.sharedContext.currentPresentationData.with { $0 }).theme, peer: EnginePeer(groupPeer)) - + self.channelAvatarNode.setPeer(context: context, theme: (context.sharedContext.currentPresentationData.with { $0 }).theme, peer: channelPeer) + self.groupAvatarNode.setPeer(context: context, theme: (context.sharedContext.currentPresentationData.with { $0 }).theme, peer: groupPeer) + let text: PresentationStrings.FormattedString - if let channelPeer = channelPeer as? TelegramChannel, let addressName = channelPeer.addressName, !addressName.isEmpty { - text = strings.Channel_DiscussionGroup_PublicChannelLink(EnginePeer(groupPeer).displayTitle(strings: strings, displayOrder: nameDisplayOrder), EnginePeer(channelPeer).displayTitle(strings: strings, displayOrder: nameDisplayOrder)) + if case let .channel(channel) = channelPeer, let addressName = channel.addressName, !addressName.isEmpty { + text = strings.Channel_DiscussionGroup_PublicChannelLink(groupPeer.displayTitle(strings: strings, displayOrder: nameDisplayOrder), channelPeer.displayTitle(strings: strings, displayOrder: nameDisplayOrder)) } else { - text = strings.Channel_DiscussionGroup_PrivateChannelLink(EnginePeer(groupPeer).displayTitle(strings: strings, displayOrder: nameDisplayOrder), EnginePeer(channelPeer).displayTitle(strings: strings, displayOrder: nameDisplayOrder)) + text = strings.Channel_DiscussionGroup_PrivateChannelLink(groupPeer.displayTitle(strings: strings, displayOrder: nameDisplayOrder), channelPeer.displayTitle(strings: strings, displayOrder: nameDisplayOrder)) } let textFont = Font.regular(floor(theme.baseFontSize * 14.0 / 17.0)) diff --git a/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupSetupController.swift b/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupSetupController.swift index 6f78a09e33..579db2640f 100644 --- a/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupSetupController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupSetupController.swift @@ -355,7 +355,7 @@ public func channelDiscussionGroupSetupController(context: AccountContext, updat let actionSheet = ActionSheetController(presentationData: presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ - ChannelDiscussionGroupActionSheetItem(context: context, channelPeer: channelPeer._asPeer(), groupPeer: groupPeer._asPeer(), strings: presentationData.strings, nameDisplayOrder: presentationData.nameDisplayOrder), + ChannelDiscussionGroupActionSheetItem(context: context, channelPeer: channelPeer, groupPeer: groupPeer, strings: presentationData.strings, nameDisplayOrder: presentationData.nameDisplayOrder), ActionSheetButtonItem(title: presentationData.strings.Channel_DiscussionGroup_LinkGroup, color: .accent, action: { [weak actionSheet] in actionSheet?.dismissAnimated() diff --git a/submodules/PeerInfoUI/Sources/ItemListCallListItem.swift b/submodules/PeerInfoUI/Sources/ItemListCallListItem.swift index c45e08ed99..0548e30b82 100644 --- a/submodules/PeerInfoUI/Sources/ItemListCallListItem.swift +++ b/submodules/PeerInfoUI/Sources/ItemListCallListItem.swift @@ -3,7 +3,6 @@ import UIKit import Display import AsyncDisplayKit import SwiftSignalKit -import Postbox import TelegramCore import TelegramPresentationData import ItemListUI @@ -14,12 +13,12 @@ import TextFormat public class ItemListCallListItem: ListViewItem, ItemListItem { let presentationData: ItemListPresentationData let dateTimeFormat: PresentationDateTimeFormat - let messages: [Message] + let messages: [EngineMessage] public let sectionId: ItemListSectionId let style: ItemListStyle let displayDecorations: Bool - - public init(presentationData: ItemListPresentationData, dateTimeFormat: PresentationDateTimeFormat, messages: [Message], sectionId: ItemListSectionId, style: ItemListStyle, displayDecorations: Bool = true) { + + public init(presentationData: ItemListPresentationData, dateTimeFormat: PresentationDateTimeFormat, messages: [EngineMessage], sectionId: ItemListSectionId, style: ItemListStyle, displayDecorations: Bool = true) { self.presentationData = presentationData self.dateTimeFormat = dateTimeFormat self.messages = messages @@ -62,7 +61,7 @@ public class ItemListCallListItem: ListViewItem, ItemListItem { } } -private func stringForCallType(message: Message, strings: PresentationStrings) -> String { +private func stringForCallType(message: EngineMessage, strings: PresentationStrings) -> String { var string = "" for media in message.media { switch media { diff --git a/submodules/PeerInfoUI/Sources/PeerAllowedReactionListController.swift b/submodules/PeerInfoUI/Sources/PeerAllowedReactionListController.swift index a07c119fb2..a673b6fb51 100644 --- a/submodules/PeerInfoUI/Sources/PeerAllowedReactionListController.swift +++ b/submodules/PeerInfoUI/Sources/PeerAllowedReactionListController.swift @@ -3,7 +3,6 @@ import UIKit import Display import AsyncDisplayKit import SwiftSignalKit -import Postbox import TelegramCore import TelegramPresentationData import TelegramUIPreferences @@ -274,14 +273,14 @@ private struct PeerAllowedReactionListControllerState: Equatable { private func peerAllowedReactionListControllerEntries( presentationData: PresentationData, availableReactions: AvailableReactions?, - peer: Peer?, - cachedData: CachedPeerData?, + peer: EnginePeer?, + cachedData: EngineCachedPeerData?, state: PeerAllowedReactionListControllerState ) -> [PeerAllowedReactionListControllerEntry] { var entries: [PeerAllowedReactionListControllerEntry] = [] - + if let peer = peer, let availableReactions = availableReactions, let allowedReactions = state.updatedAllowedReactions, let mode = state.updatedMode { - if let channel = peer as? TelegramChannel, case .broadcast = channel.info { + if case let .channel(channel) = peer, case .broadcast = channel.info { entries.append(.allowSwitch(text: presentationData.strings.PeerInfo_AllowedReactions_AllowAllText, value: mode != .empty)) entries.append(.itemsHeader(presentationData.strings.PeerInfo_AllowedReactions_ReactionListHeader)) @@ -301,7 +300,7 @@ private func peerAllowedReactionListControllerEntries( entries.append(.allowNone(text: presentationData.strings.PeerInfo_AllowedReactions_OptionNoReactions, isEnabled: mode == .empty)) let allInfoText: String - if let peer = peer as? TelegramChannel, case .broadcast = peer.info { + if case let .channel(peer) = peer, case .broadcast = peer.info { switch mode { case .all: allInfoText = presentationData.strings.PeerInfo_AllowedReactions_GroupOptionAllInfo @@ -343,7 +342,7 @@ private func peerAllowedReactionListControllerEntries( public func peerAllowedReactionListController( context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal)? = nil, - peerId: PeerId + peerId: EnginePeer.Id ) -> ViewController { let statePromise = ValuePromise(PeerAllowedReactionListControllerState(), ignoreRepeated: true) let stateValue = Atomic(value: PeerAllowedReactionListControllerState()) @@ -476,7 +475,7 @@ public func peerAllowedReactionListController( let entries = peerAllowedReactionListControllerEntries( presentationData: presentationData, availableReactions: availableReactions, - peer: peerView.peers[peerId], + peer: peerView.peers[peerId].flatMap(EnginePeer.init), cachedData: peerView.cachedData, state: state ) diff --git a/submodules/PlatformRestrictionMatching/Sources/PlatformRestrictionMatching.swift b/submodules/PlatformRestrictionMatching/Sources/PlatformRestrictionMatching.swift index a4e19b1975..cdafe9a37c 100644 --- a/submodules/PlatformRestrictionMatching/Sources/PlatformRestrictionMatching.swift +++ b/submodules/PlatformRestrictionMatching/Sources/PlatformRestrictionMatching.swift @@ -1,5 +1,6 @@ import Foundation import TelegramCore +import Postbox public extension Message { func isRestricted(platform: String, contentSettings: ContentSettings) -> Bool { diff --git a/submodules/SettingsUI/Sources/Notifications/NotificationsAndSoundsController.swift b/submodules/SettingsUI/Sources/Notifications/NotificationsAndSoundsController.swift index 3dc9a053c2..9703406855 100644 --- a/submodules/SettingsUI/Sources/Notifications/NotificationsAndSoundsController.swift +++ b/submodules/SettingsUI/Sources/Notifications/NotificationsAndSoundsController.swift @@ -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 struct CounterTagSettings: OptionSet { self.rawValue = rawValue } - init(summaryTags: PeerSummaryCounterTags) { + init(summaryTags: EnginePeerSummaryCounterTags) { var result = CounterTagSettings() if summaryTags.contains(.contact) { result.insert(.regularChatsAndGroups) @@ -35,8 +34,8 @@ private struct CounterTagSettings: OptionSet { self = result } - func toSumaryTags() -> PeerSummaryCounterTags { - var result = PeerSummaryCounterTags() + func toSumaryTags() -> EnginePeerSummaryCounterTags { + var result = EnginePeerSummaryCounterTags() if self.contains(.regularChatsAndGroups) { result.insert(.contact) result.insert(.nonContact) @@ -786,10 +785,10 @@ public func notificationsAndSoundsController(context: AccountContext, exceptions let defaultStorySettings = PeerStoryNotificationSettings.default notificationExceptions.set(exceptionsSignal |> map { list -> (NotificationExceptionMode, NotificationExceptionMode, NotificationExceptionMode, NotificationExceptionMode) in - var users:[PeerId : NotificationExceptionWrapper] = [:] - var groups: [PeerId : NotificationExceptionWrapper] = [:] - var channels: [PeerId : NotificationExceptionWrapper] = [:] - var stories: [PeerId : NotificationExceptionWrapper] = [:] + var users:[EnginePeer.Id : NotificationExceptionWrapper] = [:] + var groups: [EnginePeer.Id : NotificationExceptionWrapper] = [:] + var channels: [EnginePeer.Id : NotificationExceptionWrapper] = [:] + var stories: [EnginePeer.Id : NotificationExceptionWrapper] = [:] if let list = list { for (key, value) in list.settings { if let peer = list.peers[key], !peer.debugDisplayTitle.isEmpty, peer.id != context.account.peerId { diff --git a/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/RecentSessionsController.swift b/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/RecentSessionsController.swift index a2cd1fcee2..e13509014e 100644 --- a/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/RecentSessionsController.swift +++ b/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/RecentSessionsController.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import Display import SwiftSignalKit -import Postbox import TelegramCore import TelegramPresentationData import TelegramUIPreferences @@ -543,7 +542,7 @@ private func recentSessionsControllerEntries(presentationData: PresentationData, return entries } -private func recentSessionsControllerEntries(presentationData: PresentationData, state: RecentSessionsControllerState, websites: [WebAuthorization]?, peers: [PeerId : Peer]?) -> [RecentSessionsEntry] { +private func recentSessionsControllerEntries(presentationData: PresentationData, state: RecentSessionsControllerState, websites: [WebAuthorization]?, peers: [EnginePeer.Id: EnginePeer]?) -> [RecentSessionsEntry] { var entries: [RecentSessionsEntry] = [] if let websites = websites, let peers = peers { @@ -562,7 +561,7 @@ private func recentSessionsControllerEntries(presentationData: PresentationData, let website = websites[i] if !existingSessionIds.contains(website.hash) { existingSessionIds.insert(website.hash) - entries.append(.website(index: Int32(i), sortIndex: SortIndex(section: 1, item: i), strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, website: website, peer: peers[website.botId].flatMap(EnginePeer.init), enabled: state.removingSessionId != website.hash && !state.terminatingOtherSessions, editing: state.editing, revealed: state.sessionIdWithRevealedOptions == website.hash)) + entries.append(.website(index: Int32(i), sortIndex: SortIndex(section: 1, item: i), strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, website: website, peer: peers[website.botId], enabled: state.removingSessionId != website.hash && !state.terminatingOtherSessions, editing: state.editing, revealed: state.sessionIdWithRevealedOptions == website.hash)) } } } diff --git a/submodules/SettingsUI/Sources/Search/SettingsSearchableItems.swift b/submodules/SettingsUI/Sources/Search/SettingsSearchableItems.swift index 560caa33be..edf9021487 100644 --- a/submodules/SettingsUI/Sources/Search/SettingsSearchableItems.swift +++ b/submodules/SettingsUI/Sources/Search/SettingsSearchableItems.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import Display import SwiftSignalKit -import Postbox import TelegramCore import TelegramUIPreferences import TelegramCallsUI @@ -1542,10 +1541,10 @@ private func notificationSearchableItems(context: AccountContext, settings: Glob let defaultStorySettings = PeerStoryNotificationSettings.default let exceptions = { () -> (NotificationExceptionMode, NotificationExceptionMode, NotificationExceptionMode, NotificationExceptionMode) in - var users:[PeerId : NotificationExceptionWrapper] = [:] - var groups: [PeerId : NotificationExceptionWrapper] = [:] - var channels: [PeerId : NotificationExceptionWrapper] = [:] - var stories: [PeerId : NotificationExceptionWrapper] = [:] + var users:[EnginePeer.Id: NotificationExceptionWrapper] = [:] + var groups: [EnginePeer.Id: NotificationExceptionWrapper] = [:] + var channels: [EnginePeer.Id: NotificationExceptionWrapper] = [:] + var stories: [EnginePeer.Id: NotificationExceptionWrapper] = [:] if let list = exceptionsList { for (key, value) in list.settings { @@ -4515,20 +4514,20 @@ func settingsSearchableItems( } } -private func stringTokens(_ string: String) -> [ValueBoxKey] { +private func stringTokens(_ string: String) -> [EngineDataBuffer] { 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: [EngineDataBuffer] = [] - var addedTokens = Set() + var addedTokens = Set() while tokenType != [] { let currentTokenRange = CFStringTokenizerGetCurrentTokenRange(tokenizer) if currentTokenRange.location >= 0 && currentTokenRange.length != 0 { - let token = ValueBoxKey(length: currentTokenRange.length * 2) + let token = EngineDataBuffer(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) @@ -4541,7 +4540,7 @@ private func stringTokens(_ string: String) -> [ValueBoxKey] { return tokens } -private func matchStringTokens(_ tokens: [ValueBoxKey], with other: [ValueBoxKey]) -> Bool { +private func matchStringTokens(_ tokens: [EngineDataBuffer], with other: [EngineDataBuffer]) -> Bool { if other.isEmpty { return false } else if other.count == 1 { diff --git a/submodules/SettingsUI/Sources/ThemePickerController.swift b/submodules/SettingsUI/Sources/ThemePickerController.swift index 8be71db7d0..b90159eb76 100644 --- a/submodules/SettingsUI/Sources/ThemePickerController.swift +++ b/submodules/SettingsUI/Sources/ThemePickerController.swift @@ -349,7 +349,7 @@ private final class ThemePickerControllerImpl: ItemListController, ThemePickerCo public func themePickerController(context: AccountContext, focusOnItemTag: ThemeSettingsEntryTag? = nil) -> ViewController { #if DEBUG - BuiltinWallpaperData.generate(account: context.account) + BuiltinWallpaperData.generate(network: context.account.network) #endif var pushControllerImpl: ((ViewController) -> Void)? diff --git a/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift b/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift index 60575fb189..38f2bb26ca 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift @@ -506,7 +506,7 @@ private final class ThemeSettingsControllerImpl: ItemListController, ThemeSettin public func themeSettingsController(context: AccountContext, focusOnItemTag: ThemeSettingsEntryTag? = nil) -> ViewController { #if DEBUG - BuiltinWallpaperData.generate(account: context.account) + BuiltinWallpaperData.generate(network: context.account.network) #endif var pushControllerImpl: ((ViewController) -> Void)? diff --git a/submodules/TelegramAnimatedStickerNode/Sources/AnimatedStickerUtils.swift b/submodules/TelegramAnimatedStickerNode/Sources/AnimatedStickerUtils.swift index c9d2fda55e..caeb85c732 100644 --- a/submodules/TelegramAnimatedStickerNode/Sources/AnimatedStickerUtils.swift +++ b/submodules/TelegramAnimatedStickerNode/Sources/AnimatedStickerUtils.swift @@ -2,7 +2,6 @@ import Foundation import CoreMedia import UIKit import SwiftSignalKit -import Postbox import Display import TelegramCore import Compression @@ -17,7 +16,7 @@ import ManagedFile import UniversalMediaPlayer import SoftwareVideo -public func fetchCompressedLottieFirstFrameAJpeg(data: Data, size: CGSize, fitzModifier: EmojiFitzModifier? = nil, cacheKey: String) -> Signal { +public func fetchCompressedLottieFirstFrameAJpeg(data: Data, size: CGSize, fitzModifier: EmojiFitzModifier? = nil, cacheKey: String) -> Signal { return Signal({ subscriber in let queue = Queue() @@ -97,7 +96,7 @@ public func fetchCompressedLottieFirstFrameAJpeg(data: Data, size: CGSize, fitzM finalData.append(&alphaSize, length: 4) finalData.append(alphaData as Data) - let tempFile = TempBox.shared.tempFile(fileName: "image.ajpg") + let tempFile = EngineTempBox.shared.tempFile(fileName: "image.ajpg") let _ = try? finalData.write(to: URL(fileURLWithPath: tempFile.path), options: []) subscriber.putNext(tempFile) subscriber.putCompletion() @@ -117,7 +116,7 @@ private let threadPool: ThreadPool = { return ThreadPool(threadCount: 3, threadPriority: 0.5) }() -public func cacheAnimatedStickerFrames(data: Data, size: CGSize, fitzModifier: EmojiFitzModifier? = nil, cacheKey: String) -> Signal { +public func cacheAnimatedStickerFrames(data: Data, size: CGSize, fitzModifier: EmojiFitzModifier? = nil, cacheKey: String) -> Signal { return Signal({ subscriber in let cancelled = Atomic(value: false) @@ -144,7 +143,7 @@ public func cacheAnimatedStickerFrames(data: Data, size: CGSize, fitzModifier: E var currentFrame: Int32 = 0 - let tempFile = TempBox.shared.tempFile(fileName: "result.asticker") + let tempFile = EngineTempBox.shared.tempFile(fileName: "result.asticker") guard let file = ManagedFile(queue: nil, path: tempFile.path, mode: .readwrite) else { return } @@ -258,7 +257,7 @@ public func cacheAnimatedStickerFrames(data: Data, size: CGSize, fitzModifier: E }) } -public func cacheVideoStickerFrames(path: String, size: CGSize, cacheKey: String) -> Signal { +public func cacheVideoStickerFrames(path: String, size: CGSize, cacheKey: String) -> Signal { return Signal { subscriber in let cancelled = Atomic(value: false) @@ -278,7 +277,7 @@ public func cacheVideoStickerFrames(path: String, size: CGSize, cacheKey: String var currentFrame: Int32 = 0 - let tempFile = TempBox.shared.tempFile(fileName: "result.vsticker") + let tempFile = EngineTempBox.shared.tempFile(fileName: "result.vsticker") guard let file = ManagedFile(queue: nil, path: tempFile.path, mode: .readwrite) else { return } diff --git a/submodules/TelegramBaseController/BUILD b/submodules/TelegramBaseController/BUILD index 57b114255f..cc8f0bd82b 100644 --- a/submodules/TelegramBaseController/BUILD +++ b/submodules/TelegramBaseController/BUILD @@ -11,7 +11,6 @@ swift_library( ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", - "//submodules/Postbox:Postbox", "//submodules/TelegramCore:TelegramCore", "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", diff --git a/submodules/TelegramBaseController/Sources/LocationBroadcastActionSheetItem.swift b/submodules/TelegramBaseController/Sources/LocationBroadcastActionSheetItem.swift index 30bdac8506..105be70e18 100644 --- a/submodules/TelegramBaseController/Sources/LocationBroadcastActionSheetItem.swift +++ b/submodules/TelegramBaseController/Sources/LocationBroadcastActionSheetItem.swift @@ -3,7 +3,6 @@ import UIKit import AsyncDisplayKit import Display import TelegramCore -import Postbox import TelegramPresentationData import AccountContext import LiveLocationTimerNode @@ -11,14 +10,14 @@ import AvatarNode public class LocationBroadcastActionSheetItem: ActionSheetItem { public let context: AccountContext - public let peer: Peer + public let peer: EnginePeer public let title: String public let beginTimestamp: Double public let timeout: Double public let strings: PresentationStrings public let action: () -> Void - public init(context: AccountContext, peer: Peer, title: String, beginTimestamp: Double, timeout: Double, strings: PresentationStrings, action: @escaping () -> Void) { + public init(context: AccountContext, peer: EnginePeer, title: String, beginTimestamp: Double, timeout: Double, strings: PresentationStrings, action: @escaping () -> Void) { self.context = context self.peer = peer self.title = title @@ -105,7 +104,7 @@ public class LocationBroadcastActionSheetItemNode: ActionSheetItemNode { let textColor: UIColor = self.theme.primaryTextColor self.label.attributedText = NSAttributedString(string: item.title, font: defaultFont, textColor: textColor) - self.avatarNode.setPeer(context: item.context, theme: (item.context.sharedContext.currentPresentationData.with { $0 }).theme, peer: EnginePeer(item.peer)) + self.avatarNode.setPeer(context: item.context, theme: (item.context.sharedContext.currentPresentationData.with { $0 }).theme, peer: item.peer) self.timerNode.update(backgroundColor: self.theme.controlAccentColor.withAlphaComponent(0.4), foregroundColor: self.theme.controlAccentColor, textColor: self.theme.controlAccentColor, beginTimestamp: item.beginTimestamp, timeout: Int32(item.timeout) == liveLocationIndefinitePeriod ? -1.0 : item.timeout, strings: item.strings) } diff --git a/submodules/TelegramCallsUI/Sources/CallController.swift b/submodules/TelegramCallsUI/Sources/CallController.swift index 098c84bf08..a830950e41 100644 --- a/submodules/TelegramCallsUI/Sources/CallController.swift +++ b/submodules/TelegramCallsUI/Sources/CallController.swift @@ -33,7 +33,7 @@ protocol CallControllerNodeProtocol: AnyObject { func updateAudioOutputs(availableOutputs: [AudioSessionOutput], currentOutput: AudioSessionOutput?) func updateCallState(_ callState: PresentationCallState) - func updatePeer(accountPeer: Peer, peer: Peer, hasOther: Bool) + func updatePeer(accountPeer: EnginePeer, peer: EnginePeer, hasOther: Bool) func animateIn() func animateOut(completion: @escaping () -> Void) @@ -63,8 +63,6 @@ public final class CallController: ViewController { private var presentationData: PresentationData private var didPlayPresentationAnimation = false - private var peer: Peer? - private var peerDisposable: Disposable? private var disposable: Disposable? @@ -164,7 +162,6 @@ public final class CallController: ViewController { override public func loadDisplayNode() { let displayNode = CallControllerNodeV2( sharedContext: self.sharedContext, - account: self.account, presentationData: self.presentationData, statusBar: self.statusBar, debugInfo: self.call.debugInfo(), @@ -372,8 +369,7 @@ public final class CallController: ViewController { if let strongSelf = self { if let view { if let accountPeer = accountView.peers[accountView.peerId], let peer = view.peers[view.peerId] { - strongSelf.peer = peer - strongSelf.controllerNode.updatePeer(accountPeer: accountPeer, peer: peer, hasOther: activeAccountsWithInfo.accounts.count > 1) + strongSelf.controllerNode.updatePeer(accountPeer: EnginePeer(accountPeer), peer: EnginePeer(peer), hasOther: activeAccountsWithInfo.accounts.count > 1) strongSelf.isDataReady.set(.single(true)) } } else { diff --git a/submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift b/submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift index 86db813a19..230815678b 100644 --- a/submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift +++ b/submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift @@ -3,7 +3,6 @@ import UIKit import AsyncDisplayKit import Display import TelegramCore -import Postbox import TelegramAudio import AccountContext import TelegramPresentationData @@ -30,7 +29,6 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP } private let sharedContext: SharedAccountContext - private let account: Account private let presentationData: PresentationData private let statusBar: StatusBar private let call: PresentationCall @@ -88,7 +86,6 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP init( sharedContext: SharedAccountContext, - account: Account, presentationData: PresentationData, statusBar: StatusBar, debugInfo: Signal<(String, String), NoError>, @@ -96,7 +93,6 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP call: PresentationCall ) { self.sharedContext = sharedContext - self.account = account self.presentationData = presentationData self.statusBar = statusBar self.call = call @@ -611,8 +607,8 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP } } - func updatePeer(accountPeer: Peer, peer: Peer, hasOther: Bool) { - self.updatePeer(peer: EnginePeer(peer)) + func updatePeer(accountPeer: EnginePeer, peer: EnginePeer, hasOther: Bool) { + self.updatePeer(peer: peer) } private func updatePeer(peer: EnginePeer) { diff --git a/submodules/TelegramCallsUI/Sources/CallStatusBarNode.swift b/submodules/TelegramCallsUI/Sources/CallStatusBarNode.swift index 97dbfb86b2..050decd464 100644 --- a/submodules/TelegramCallsUI/Sources/CallStatusBarNode.swift +++ b/submodules/TelegramCallsUI/Sources/CallStatusBarNode.swift @@ -221,7 +221,7 @@ public class CallStatusBarNodeImpl: CallStatusBarNode { private var presentationData: PresentationData? private let presentationDataDisposable = MetaDisposable() - private var currentPeer: Peer? + private var currentPeer: EnginePeer? private var currentCallTimer: SwiftSignalKit.Timer? private var currentCallState: PresentationCallState? private var currentGroupCallState: PresentationGroupCallSummaryState? @@ -335,7 +335,7 @@ public class CallStatusBarNodeImpl: CallStatusBarNode { ) |> deliverOnMainQueue).start(next: { [weak self] peer, state, isMuted in if let strongSelf = self { - strongSelf.currentPeer = peer._asPeer() + strongSelf.currentPeer = peer strongSelf.currentCallState = state strongSelf.currentIsMuted = isMuted @@ -384,7 +384,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] + strongSelf.currentPeer = view.peers[view.peerId].flatMap(EnginePeer.init) } else { strongSelf.currentPeer = nil } @@ -470,7 +470,7 @@ public class CallStatusBarNodeImpl: CallStatusBarNode { if let voiceChatTitle = self.currentGroupCallState?.info?.title, !voiceChatTitle.isEmpty { title = voiceChatTitle } else if let currentPeer = self.currentPeer { - title = EnginePeer(currentPeer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder) + title = currentPeer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder) } var membersCount: Int32? if let groupCallState = self.currentGroupCallState { diff --git a/submodules/TelegramCallsUI/Sources/Components/LivestreamVideoViewV1.swift b/submodules/TelegramCallsUI/Sources/Components/LivestreamVideoViewV1.swift index e9d61c78a6..f5ee73edea 100644 --- a/submodules/TelegramCallsUI/Sources/Components/LivestreamVideoViewV1.swift +++ b/submodules/TelegramCallsUI/Sources/Components/LivestreamVideoViewV1.swift @@ -3,7 +3,6 @@ import UIKit import AVFoundation import SwiftSignalKit import UniversalMediaPlayer -import Postbox import TelegramCore import AccountContext import TelegramAudio @@ -19,7 +18,7 @@ final class LivestreamVideoViewV1: UIView { let part: DirectMediaStreamingContext.Playlist.Part let disposable = MetaDisposable() var resolvedTimeOffset: Double? - var data: TempBoxFile? + var data: EngineTempBoxFile? var info: FFMpegMediaInfo? init(part: DirectMediaStreamingContext.Playlist.Part) { @@ -164,11 +163,11 @@ final class LivestreamVideoViewV1: UIView { if let streamingContext = self.streamingContext { partContext.disposable.set((streamingContext.partData(index: part.index) |> deliverOn(Queue.concurrentDefaultQueue()) - |> map { data -> (file: TempBoxFile, info: FFMpegMediaInfo)? in + |> map { data -> (file: EngineTempBoxFile, info: FFMpegMediaInfo)? in guard let data else { return nil } - let tempFile = TempBox.shared.tempFile(fileName: "part.mp4") + let tempFile = EngineTempBox.shared.tempFile(fileName: "part.mp4") if let _ = try? data.write(to: URL(fileURLWithPath: tempFile.path), options: .atomic) { if let info = extractFFMpegMediaInfo(path: tempFile.path) { return (tempFile, info) @@ -176,7 +175,7 @@ final class LivestreamVideoViewV1: UIView { return nil } } else { - TempBox.shared.dispose(tempFile) + EngineTempBox.shared.dispose(tempFile) return nil } } diff --git a/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift b/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift index df2a9311c6..77fcad9098 100644 --- a/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift +++ b/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift @@ -6,7 +6,6 @@ import AccountContext import SwiftSignalKit import AVKit import TelegramCore -import Postbox import UndoUI import TelegramPresentationData @@ -66,7 +65,7 @@ public final class MediaStreamComponent: CombinedComponent { private(set) var recordingStartTimestamp: Int32? private(set) var peerTitle: String = "" - private(set) var chatPeer: Peer? + private(set) var chatPeer: EnginePeer? private(set) var isVisibleInHierarchy: Bool = false private var isVisibleInHierarchyDisposable: Disposable? @@ -152,7 +151,7 @@ public final class MediaStreamComponent: CombinedComponent { strongSelf.peerTitle = callPeer.debugDisplayTitle updated = true } - strongSelf.chatPeer = callPeer._asPeer() + strongSelf.chatPeer = callPeer if strongSelf.callTitle != state.title { strongSelf.callTitle = state.title @@ -508,7 +507,7 @@ public final class MediaStreamComponent: CombinedComponent { let title: String = presentationData.strings.LiveStream_EditTitle let text: String = presentationData.strings.LiveStream_EditTitleText - let editController = voiceChatTitleEditController(context: call.accountContext, forceTheme: defaultDarkPresentationTheme, title: title, text: text, placeholder: EnginePeer(chatPeer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), value: initialTitle, maxLength: 40, apply: { [weak call] title in + let editController = voiceChatTitleEditController(context: call.accountContext, forceTheme: defaultDarkPresentationTheme, title: title, text: text, placeholder: chatPeer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), value: initialTitle, maxLength: 40, apply: { [weak call] title in guard let call = call else { return } diff --git a/submodules/TelegramCallsUI/Sources/Components/MediaStreamVideoComponent.swift b/submodules/TelegramCallsUI/Sources/Components/MediaStreamVideoComponent.swift index eece3a8a6a..495eb5ff61 100644 --- a/submodules/TelegramCallsUI/Sources/Components/MediaStreamVideoComponent.swift +++ b/submodules/TelegramCallsUI/Sources/Components/MediaStreamVideoComponent.swift @@ -9,7 +9,6 @@ import ShimmerEffect import TelegramCore import SwiftSignalKit import AvatarNode -import Postbox import TelegramVoip import ComponentDisplayAdapters @@ -28,7 +27,7 @@ public final class MediaStreamVideoComponent: Component { let isFullscreen: Bool let onVideoSizeRetrieved: (CGSize) -> Void let videoLoading: Bool - let callPeer: Peer? + let callPeer: EnginePeer? let onVideoPlaybackLiveChange: (Bool) -> Void public init( @@ -40,7 +39,7 @@ public final class MediaStreamVideoComponent: Component { addInset: Bool, isFullscreen: Bool, videoLoading: Bool, - callPeer: Peer?, + callPeer: EnginePeer?, enablePictureInPicture: Bool, activatePictureInPicture: ActionSlot>, deactivatePictureInPicture: ActionSlot, @@ -306,7 +305,7 @@ public final class MediaStreamVideoComponent: Component { if let peer = component.callPeer, !didBeginLoadingAvatar { didBeginLoadingAvatar = true - avatarDisposable = peerAvatarCompleteImage(account: component.call.account, peer: EnginePeer(peer), size: CGSize(width: 250.0, height: 250.0), round: false, font: Font.regular(16.0), drawLetters: false, fullSize: false, blurred: true).start(next: { [weak self] image in + avatarDisposable = peerAvatarCompleteImage(account: component.call.account, peer: peer, size: CGSize(width: 250.0, height: 250.0), round: false, font: Font.regular(16.0), drawLetters: false, fullSize: false, blurred: true).start(next: { [weak self] image in DispatchQueue.main.async { self?.placeholderView.contentMode = .scaleAspectFill self?.placeholderView.image = image diff --git a/submodules/TelegramCallsUI/Sources/LegacyCallControllerNode.swift b/submodules/TelegramCallsUI/Sources/LegacyCallControllerNode.swift index 9b5caf3cc0..90c82ea124 100644 --- a/submodules/TelegramCallsUI/Sources/LegacyCallControllerNode.swift +++ b/submodules/TelegramCallsUI/Sources/LegacyCallControllerNode.swift @@ -20,7 +20,7 @@ final class LegacyCallControllerNode: ASDisplayNode, CallControllerNodeProtocol private let statusBar: StatusBar private var presentationData: PresentationData - private var peer: Peer? + private var peer: EnginePeer? private let debugInfo: Signal<(String, String), NoError> private var forceReportRating = false private let easyDebugAccess: Bool @@ -167,10 +167,10 @@ final class LegacyCallControllerNode: ASDisplayNode, CallControllerNodeProtocol self.view.addGestureRecognizer(tapRecognizer) } - func updatePeer(accountPeer: Peer, peer: Peer, hasOther: Bool) { - if !arePeersEqual(self.peer, peer) { + func updatePeer(accountPeer: EnginePeer, peer: EnginePeer, hasOther: Bool) { + if self.peer != peer { self.peer = peer - if let peerReference = PeerReference(peer), !peer.profileImageRepresentations.isEmpty { + if let peerReference = PeerReference(peer._asPeer()), !peer.profileImageRepresentations.isEmpty { let representations: [ImageRepresentationWithReference] = peer.profileImageRepresentations.map({ ImageRepresentationWithReference(representation: $0, reference: .avatar(peer: peerReference, resource: $0.resource)) }) self.imageNode.setSignal(chatAvatarGalleryPhoto(account: self.account, representations: representations, immediateThumbnailData: nil, autoFetchFullSize: true)) self.dimNode.isHidden = false @@ -178,10 +178,10 @@ final class LegacyCallControllerNode: ASDisplayNode, CallControllerNodeProtocol self.imageNode.setSignal(callDefaultBackground()) self.dimNode.isHidden = true } - - self.statusNode.title = EnginePeer(peer).displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) + + self.statusNode.title = peer.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) if hasOther { - self.statusNode.subtitle = self.presentationData.strings.Call_AnsweringWithAccount(EnginePeer(accountPeer).displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder)).string + self.statusNode.subtitle = self.presentationData.strings.Call_AnsweringWithAccount(accountPeer.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder)).string if let callState = callState { self.updateCallState(callState) @@ -444,7 +444,7 @@ final class LegacyCallControllerNode: ASDisplayNode, CallControllerNodeProtocol @objc func keyPressed() { if self.keyPreviewNode == nil, let keyText = self.keyTextData?.1, let peer = self.peer { - let keyPreviewNode = CallControllerKeyPreviewNode(keyText: keyText, infoText: self.presentationData.strings.Call_EmojiDescription(EnginePeer(peer).compactDisplayTitle).string.replacingOccurrences(of: "%%", with: "%"), dismiss: { [weak self] in + let keyPreviewNode = CallControllerKeyPreviewNode(keyText: keyText, infoText: self.presentationData.strings.Call_EmojiDescription(peer.compactDisplayTitle).string.replacingOccurrences(of: "%%", with: "%"), dismiss: { [weak self] in if let _ = self?.keyPreviewNode { self?.backPressed() } diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift index 1e883ee6f3..dfedb7852c 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift @@ -9,7 +9,6 @@ import TelegramStringFormatting import TelegramVoip import TelegramAudio import AccountContext -import Postbox import TelegramCore import MergeLists import ItemListUI @@ -124,7 +123,7 @@ struct VoiceChatPeerEntry: Identifiable { case raisedHand } - var peer: Peer + var peer: EnginePeer var about: String? var isMyPeer: Bool var videoEndpointId: String? @@ -146,7 +145,7 @@ struct VoiceChatPeerEntry: Identifiable { } init( - peer: Peer, + peer: EnginePeer, about: String?, isMyPeer: Bool, videoEndpointId: String?, @@ -181,12 +180,12 @@ struct VoiceChatPeerEntry: Identifiable { self.isLandscape = isLandscape } - var stableId: PeerId { + var stableId: EnginePeer.Id { return self.peer.id } - + static func ==(lhs: VoiceChatPeerEntry, rhs: VoiceChatPeerEntry) -> Bool { - if !lhs.peer.isEqual(rhs.peer) { + if lhs.peer != rhs.peer { return false } if lhs.about != rhs.about { diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatFullscreenParticipantItem.swift b/submodules/TelegramCallsUI/Sources/VoiceChatFullscreenParticipantItem.swift index fc62365030..b2c90c80c5 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatFullscreenParticipantItem.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatFullscreenParticipantItem.swift @@ -3,7 +3,6 @@ import UIKit import Display import AsyncDisplayKit import SwiftSignalKit -import Postbox import TelegramCore import TelegramPresentationData import TelegramUIPreferences @@ -73,7 +72,7 @@ final class VoiceChatFullscreenParticipantItem: ListViewItem { let presentationData: ItemListPresentationData let nameDisplayOrder: PresentationPersonNameOrder let context: AccountContext - let peer: Peer + let peer: EnginePeer let videoEndpointId: String? let isPaused: Bool let icon: Icon @@ -91,7 +90,7 @@ final class VoiceChatFullscreenParticipantItem: ListViewItem { public let selectable: Bool = true - public init(presentationData: ItemListPresentationData, nameDisplayOrder: PresentationPersonNameOrder, context: AccountContext, peer: Peer, videoEndpointId: String?, isPaused: Bool, icon: Icon, text: VoiceChatParticipantItem.ParticipantText, textColor: Color, color: Color, isLandscape: Bool, active: Bool, showVideoWhenActive: Bool, getAudioLevel: (() -> Signal)?, getVideo: @escaping () -> GroupVideoNode?, action: ((ASDisplayNode?) -> Void)?, contextAction: ((ASDisplayNode, ContextGesture?) -> Void)? = nil, getUpdatingAvatar: @escaping () -> Signal<(TelegramMediaImageRepresentation, Float)?, NoError>) { + public init(presentationData: ItemListPresentationData, nameDisplayOrder: PresentationPersonNameOrder, context: AccountContext, peer: EnginePeer, videoEndpointId: String?, isPaused: Bool, icon: Icon, text: VoiceChatParticipantItem.ParticipantText, textColor: Color, color: Color, isLandscape: Bool, active: Bool, showVideoWhenActive: Bool, getAudioLevel: (() -> Signal)?, getVideo: @escaping () -> GroupVideoNode?, action: ((ASDisplayNode?) -> Void)?, contextAction: ((ASDisplayNode, ContextGesture?) -> Void)? = nil, getUpdatingAvatar: @escaping () -> Signal<(TelegramMediaImageRepresentation, Float)?, NoError>) { self.presentationData = presentationData self.nameDisplayOrder = nameDisplayOrder self.context = context @@ -384,7 +383,7 @@ class VoiceChatFullscreenParticipantItemNode: ItemListRevealOptionsItemNode { if let videoNode = self.videoNode, videoNode.supernode == self.videoContainerNode, !videoNode.alpha.isZero { hasVideo = true } - let profileNode = VoiceChatPeerProfileNode(context: item.context, size: extractedRect.size, sourceSize: nonExtractedRect.size, peer: EnginePeer(item.peer), text: item.text, customNode: hasVideo ? self.videoContainerNode : nil, additionalEntry: .single(nil), requestDismiss: { [weak self] in + let profileNode = VoiceChatPeerProfileNode(context: item.context, size: extractedRect.size, sourceSize: nonExtractedRect.size, peer: item.peer, text: item.text, customNode: hasVideo ? self.videoContainerNode : nil, additionalEntry: .single(nil), requestDismiss: { [weak self] in self?.contextSourceNode.requestDismiss?() }) profileNode.frame = CGRect(origin: CGPoint(), size: extractedRect.size) @@ -457,7 +456,7 @@ class VoiceChatFullscreenParticipantItemNode: ItemListRevealOptionsItemNode { } let currentBoldFont: UIFont = titleFont - if let user = item.peer as? TelegramUser { + if case let .user(user) = item.peer { if let firstName = user.firstName, let lastName = user.lastName, !firstName.isEmpty, !lastName.isEmpty { titleAttributedString = NSAttributedString(string: firstName, font: titleFont, textColor: titleColor) } else if let firstName = user.firstName, !firstName.isEmpty { @@ -467,9 +466,9 @@ class VoiceChatFullscreenParticipantItemNode: ItemListRevealOptionsItemNode { } else { titleAttributedString = NSAttributedString(string: item.presentationData.strings.User_DeletedAccount, font: currentBoldFont, textColor: titleColor) } - } else if let group = item.peer as? TelegramGroup { + } else if case let .legacyGroup(group) = item.peer { titleAttributedString = NSAttributedString(string: group.title, font: currentBoldFont, textColor: titleColor) - } else if let channel = item.peer as? TelegramChannel { + } else if case let .channel(channel) = item.peer { titleAttributedString = NSAttributedString(string: channel.title, font: currentBoldFont, textColor: titleColor) } @@ -763,7 +762,7 @@ class VoiceChatFullscreenParticipantItemNode: ItemListRevealOptionsItemNode { if item.peer.isDeleted { overrideImage = .deletedIcon } - strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(item.peer), overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad, storeUnrounded: true) + strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: item.peer, overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad, storeUnrounded: true) var hadMicrophoneNode = false var hadRaiseHandNode = false diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatHeaderButton.swift b/submodules/TelegramCallsUI/Sources/VoiceChatHeaderButton.swift index a4bf02de6f..c6f42e60b5 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatHeaderButton.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatHeaderButton.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import AsyncDisplayKit import Display -import Postbox import TelegramCore import AccountContext import TelegramPresentationData @@ -69,7 +68,7 @@ final class VoiceChatHeaderButton: HighlightableButtonNode { enum Content { case image(UIImage?) case more(UIImage?) - case avatar(Peer) + case avatar(EnginePeer) } private let context: AccountContext @@ -155,7 +154,7 @@ final class VoiceChatHeaderButton: HighlightableButtonNode { self.iconNode.isHidden = false self.avatarNode.isHidden = true case let .avatar(peer): - self.avatarNode.setPeer(context: self.context, theme: self.theme, peer: EnginePeer(peer)) + self.avatarNode.setPeer(context: self.context, theme: self.theme, peer: peer) self.iconNode.isHidden = true self.avatarNode.isHidden = false self.animationNode?.isHidden = true @@ -173,7 +172,7 @@ final class VoiceChatHeaderButton: HighlightableButtonNode { self.iconNode.isHidden = false self.avatarNode.isHidden = true case let .avatar(peer): - self.avatarNode.setPeer(context: self.context, theme: self.theme, peer: EnginePeer(peer)) + self.avatarNode.setPeer(context: self.context, theme: self.theme, peer: peer) self.iconNode.isHidden = true self.avatarNode.isHidden = false self.animationNode?.isHidden = true diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatMainStageNode.swift b/submodules/TelegramCallsUI/Sources/VoiceChatMainStageNode.swift index 02d15f743f..4afedb47e8 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatMainStageNode.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatMainStageNode.swift @@ -9,7 +9,6 @@ import TelegramStringFormatting import TelegramVoip import TelegramAudio import AccountContext -import Postbox import TelegramCore import AppBundle import PresentationDataUtils @@ -95,7 +94,7 @@ class VoiceChatPinButtonNode: HighlightTrackingButtonNode { final class VoiceChatMainStageNode: ASDisplayNode { private let context: AccountContext private let call: PresentationGroupCall - private(set) var currentPeer: (PeerId, String?, Bool, Bool, Bool)? + private(set) var currentPeer: (EnginePeer.Id, String?, Bool, Bool, Bool)? private var currentPeerEntry: VoiceChatPeerEntry? var callState: PresentationGroupCallState? @@ -137,12 +136,12 @@ final class VoiceChatMainStageNode: ASDisplayNode { var tapped: (() -> Void)? var back: (() -> Void)? var togglePin: (() -> Void)? - var switchTo: ((PeerId) -> Void)? + var switchTo: ((EnginePeer.Id) -> Void)? var stopScreencast: (() -> Void)? var controlsHidden: ((Bool) -> Void)? - var getAudioLevel: ((PeerId) -> Signal)? + var getAudioLevel: ((EnginePeer.Id) -> Signal)? var getVideo: ((String, Bool, @escaping (GroupVideoNode?) -> Void) -> Void)? private let videoReadyDisposable = MetaDisposable() private var silenceTimer: SwiftSignalKit.Timer? @@ -610,7 +609,7 @@ final class VoiceChatMainStageNode: ASDisplayNode { self.update(speakingPeerId: nil) } - private var effectiveSpeakingPeerId: PeerId? + private var effectiveSpeakingPeerId: EnginePeer.Id? private func updateSpeakingPeer() { guard let (_, _, _, _, isTablet) = self.validLayout else { return @@ -720,14 +719,14 @@ final class VoiceChatMainStageNode: ASDisplayNode { } } - private var visiblePeerIds = Set() - func update(visiblePeerIds: Set) { + private var visiblePeerIds = Set() + func update(visiblePeerIds: Set) { self.visiblePeerIds = visiblePeerIds self.updateSpeakingPeer() } - private var speakingPeerId: PeerId? - func update(speakingPeerId: PeerId?) { + private var speakingPeerId: EnginePeer.Id? + func update(speakingPeerId: EnginePeer.Id?) { self.speakingPeerId = speakingPeerId self.updateSpeakingPeer() } @@ -738,9 +737,9 @@ final class VoiceChatMainStageNode: ASDisplayNode { let peer = peerEntry.peer let presentationData = self.context.sharedContext.currentPresentationData.with { $0 } - if !arePeersEqual(previousPeerEntry?.peer, peerEntry.peer) { - self.backdropAvatarNode.setSignal(peerAvatarCompleteImage(account: self.context.account, peer: EnginePeer(peer), size: CGSize(width: 240.0, height: 240.0), round: false, font: avatarPlaceholderFont(size: 78.0), drawLetters: false, blurred: true)) - self.avatarNode.setSignal(peerAvatarCompleteImage(account: self.context.account, peer: EnginePeer(peer), size: CGSize(width: 180.0, height: 180.0), font: avatarPlaceholderFont(size: 78.0), fullSize: true)) + if previousPeerEntry?.peer != peerEntry.peer { + self.backdropAvatarNode.setSignal(peerAvatarCompleteImage(account: self.context.account, peer: peer, size: CGSize(width: 240.0, height: 240.0), round: false, font: avatarPlaceholderFont(size: 78.0), drawLetters: false, blurred: true)) + self.avatarNode.setSignal(peerAvatarCompleteImage(account: self.context.account, peer: peer, size: CGSize(width: 180.0, height: 180.0), font: avatarPlaceholderFont(size: 78.0), fullSize: true)) } var gradient: VoiceChatBlobNode.Gradient = .active @@ -778,7 +777,7 @@ final class VoiceChatMainStageNode: ASDisplayNode { } var microphoneColor = UIColor.white - var titleAttributedString = NSAttributedString(string: EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), font: Font.semibold(15.0), textColor: .white) + var titleAttributedString = NSAttributedString(string: peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), font: Font.semibold(15.0), textColor: .white) if mutedForYou { microphoneColor = destructiveColor @@ -836,7 +835,7 @@ final class VoiceChatMainStageNode: ASDisplayNode { self.audioLevelNode.isHidden = hidden } - func update(peer: (peer: PeerId, endpointId: String?, isMyPeer: Bool, isPresentation: Bool, isPaused: Bool)?, isReady: Bool = true, waitForFullSize: Bool, completion: (() -> Void)? = nil) { + func update(peer: (peer: EnginePeer.Id, endpointId: String?, isMyPeer: Bool, isPresentation: Bool, isPaused: Bool)?, isReady: Bool = true, waitForFullSize: Bool, completion: (() -> Void)? = nil) { let previousPeer = self.currentPeer if previousPeer?.0 == peer?.0 && previousPeer?.1 == peer?.1 && previousPeer?.2 == peer?.2 && previousPeer?.3 == peer?.3 && previousPeer?.4 == peer?.4 { completion?() diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/Message.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/Message.swift index 30b173ed59..dc79e2a281 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/Message.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/Message.swift @@ -78,9 +78,19 @@ public final class EngineMessage: Equatable { public var media: [Media] { return self.impl.media } + public var engineMedia: [EngineMedia] { + return self.impl.media.map(EngineMedia.init) + } public var peers: SimpleDictionary { return self.impl.peers } + public var enginePeers: [EnginePeer.Id: EnginePeer] { + var result: [EnginePeer.Id: EnginePeer] = [:] + for (id, peer) in self.impl.peers { + result[id] = EnginePeer(peer) + } + return result + } public var associatedMessages: SimpleDictionary { return self.impl.associatedMessages } @@ -228,3 +238,45 @@ public final class EngineMessage: Equatable { return true } } + +public extension EngineMessage { + var containsSecretMedia: Bool { + return self._asMessage().containsSecretMedia + } + + func effectiveReactions(isTags: Bool) -> [MessageReaction]? { + return self._asMessage().effectiveReactions(isTags: isTags) + } + + func areReactionsTags(accountPeerId: EnginePeer.Id) -> Bool { + return self._asMessage().areReactionsTags(accountPeerId: accountPeerId) + } + + var textEntitiesAttribute: TextEntitiesMessageAttribute? { + return self._asMessage().textEntitiesAttribute + } + + var adAttribute: AdMessageAttribute? { + return self._asMessage().adAttribute + } + + func effectivelyIncoming(_ accountPeerId: EnginePeer.Id) -> Bool { + return self._asMessage().effectivelyIncoming(accountPeerId) + } + + var pendingProcessingAttribute: PendingProcessingMessageAttribute? { + return self._asMessage().pendingProcessingAttribute + } + + var scheduleTime: Int32? { + return self._asMessage().scheduleTime + } + + var scheduleRepeatPeriod: Int32? { + return self._asMessage().scheduleRepeatPeriod + } + + var sourceAuthorInfo: SourceAuthorInfoMessageAttribute? { + return self._asMessage().sourceAuthorInfo + } +} diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/PeerCommands.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/PeerCommands.swift index 3471b95118..53cd10b608 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/PeerCommands.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/PeerCommands.swift @@ -4,13 +4,13 @@ import SwiftSignalKit public struct PeerCommand: Hashable { - public let peer: Peer + public let peer: EnginePeer public let command: BotCommand - + public static func ==(lhs: PeerCommand, rhs: PeerCommand) -> Bool { - return lhs.peer.isEqual(rhs.peer) && lhs.command == rhs.command + return lhs.peer == rhs.peer && lhs.command == rhs.command } - + public func hash(into hasher: inout Hasher) { hasher.combine(self.peer.id) hasher.combine(self.command) @@ -32,7 +32,7 @@ func _internal_peerCommands(account: Account, id: PeerId) -> Signal Signal Signal [EngineDataBuffer] { return stringIndexTokens(string, transliteration: transliteration) } + + public func matchSearchTokens(_ tokens: [EngineDataBuffer], with other: [EngineDataBuffer]) -> Bool { + return matchStringIndexTokens(tokens, with: other) + } public func updatePeerStoriesHidden(id: PeerId, isHidden: Bool) { let _ = _internal_updatePeerStoriesHidden(account: self.account, id: id, isHidden: isHidden).start() diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Privacy/ActiveSessionsContext.swift b/submodules/TelegramCore/Sources/TelegramEngine/Privacy/ActiveSessionsContext.swift index 92900626e2..c2914fea67 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Privacy/ActiveSessionsContext.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Privacy/ActiveSessionsContext.swift @@ -287,8 +287,8 @@ public final class ActiveSessionsContext { public struct WebSessionsContextState: Equatable { public var isLoadingMore: Bool public var sessions: [WebAuthorization] - public var peers: [PeerId: Peer] - + public var peers: [EnginePeer.Id: EnginePeer] + public static func ==(lhs: WebSessionsContextState, rhs: WebSessionsContextState) -> Bool { if lhs.isLoadingMore != rhs.isLoadingMore { return false @@ -296,7 +296,7 @@ public struct WebSessionsContextState: Equatable { if lhs.sessions != rhs.sessions { return false } - if !arePeerDictionariesEqual(lhs.peers, rhs.peers) { + if lhs.peers != rhs.peers { return false } return true @@ -342,14 +342,14 @@ public final class WebSessionsContext { } self._state = WebSessionsContextState(isLoadingMore: true, sessions: self._state.sessions, peers: self._state.peers) self.disposable.set((webSessions(network: account.network) - |> map { result -> (sessions: [WebAuthorization], peers: [PeerId: Peer], canLoadMore: Bool) in - return (result.0, result.1, false) + |> map { result -> (sessions: [WebAuthorization], peers: [EnginePeer.Id: EnginePeer], canLoadMore: Bool) in + return (result.0, result.1.mapValues(EnginePeer.init), false) } |> deliverOnMainQueue).start(next: { [weak self] (sessions, peers, canLoadMore) in guard let strongSelf = self else { return } - + strongSelf._state = WebSessionsContextState(isLoadingMore: false, sessions: sessions, peers: peers) })) } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Resources/CollectCacheUsageStats.swift b/submodules/TelegramCore/Sources/TelegramEngine/Resources/CollectCacheUsageStats.swift index e51b9a840e..d068a22a93 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Resources/CollectCacheUsageStats.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Resources/CollectCacheUsageStats.swift @@ -14,15 +14,15 @@ public enum PeerCacheUsageCategory: Int32 { public struct CacheUsageStats { public let media: [PeerId: [PeerCacheUsageCategory: [MediaId: Int64]]] public let mediaResourceIds: [MediaId: [MediaResourceId]] - public let peers: [PeerId: Peer] + public let peers: [EnginePeer.Id: EnginePeer] public let otherSize: Int64 public let otherPaths: [String] public let cacheSize: Int64 public let tempPaths: [String] public let tempSize: Int64 public let immutableSize: Int64 - - public init(media: [PeerId: [PeerCacheUsageCategory: [MediaId: Int64]]], mediaResourceIds: [MediaId: [MediaResourceId]], peers: [PeerId: Peer], otherSize: Int64, otherPaths: [String], cacheSize: Int64, tempPaths: [String], tempSize: Int64, immutableSize: Int64) { + + public init(media: [PeerId: [PeerCacheUsageCategory: [MediaId: Int64]]], mediaResourceIds: [MediaId: [MediaResourceId]], peers: [EnginePeer.Id: EnginePeer], otherSize: Int64, otherPaths: [String], cacheSize: Int64, tempPaths: [String], tempSize: Int64, immutableSize: Int64) { self.media = media self.mediaResourceIds = mediaResourceIds self.peers = peers @@ -894,7 +894,7 @@ func _internal_collectCacheUsageStats(account: Account, peerId: PeerId? = nil, a subscriber.putNext(.result(CacheUsageStats( media: state.media, mediaResourceIds: state.mediaResourceIds, - peers: state.peers, + peers: state.peers.mapValues(EnginePeer.init), otherSize: state.otherSize, otherPaths: state.otherPaths, cacheSize: cacheSize, diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Resources/TelegramEngineResources.swift b/submodules/TelegramCore/Sources/TelegramEngine/Resources/TelegramEngineResources.swift index 18a0f80ff0..bedca3980a 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Resources/TelegramEngineResources.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Resources/TelegramEngineResources.swift @@ -274,8 +274,8 @@ public extension TelegramEngine { _internal_clearStorage(account: self.account, messages: messages.map { $0._asMessage() }) } - public func clearCachedMediaResources(mediaResourceIds: Set) -> Signal { - return _internal_clearCachedMediaResources(account: self.account, mediaResourceIds: mediaResourceIds) + public func clearCachedMediaResources(mediaResourceIds: Set) -> Signal { + return _internal_clearCachedMediaResources(account: self.account, mediaResourceIds: Set(mediaResourceIds.map { MediaResourceId($0.stringRepresentation) })) } public func reindexCacheInBackground(lowImpact: Bool) -> Signal { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/TelegramEngine.swift b/submodules/TelegramCore/Sources/TelegramEngine/TelegramEngine.swift index 35a49e9ea3..5b186894b5 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/TelegramEngine.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/TelegramEngine.swift @@ -1,3 +1,4 @@ +import Foundation import SwiftSignalKit import Postbox @@ -107,16 +108,34 @@ public final class TelegramEngineUnauthorized { public lazy var localization: Localization = { return Localization(account: self.account) }() - + public lazy var payments: Payments = { return Payments(account: self.account) }() + + public lazy var resources: UnauthorizedResources = { + return UnauthorizedResources(account: self.account) + }() public lazy var itemCache: ItemCache = { return ItemCache(account: self.account) }() } +public extension TelegramEngineUnauthorized { + final class UnauthorizedResources { + private let account: UnauthorizedAccount + + init(account: UnauthorizedAccount) { + self.account = account + } + + public func storeResourceData(id: EngineMediaResource.Id, data: Data, synchronous: Bool = false) { + self.account.postbox.mediaBox.storeResourceData(MediaResourceId(id.stringRepresentation), data: data, synchronous: synchronous) + } + } +} + public enum SomeTelegramEngine { case unauthorized(TelegramEngineUnauthorized) case authorized(TelegramEngine) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Utils/EnginePostboxCoding.swift b/submodules/TelegramCore/Sources/TelegramEngine/Utils/EnginePostboxCoding.swift index c493032d7b..9d0752d94e 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Utils/EnginePostboxCoding.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Utils/EnginePostboxCoding.swift @@ -8,3 +8,28 @@ public typealias EngineItemCollectionId = ItemCollectionId public typealias EngineStoryId = StoryId public typealias EngineFetchResourceSourceType = FetchResourceSourceType public typealias EngineFetchResourceError = FetchResourceError +public typealias EngineCodableEntry = CodableEntry +public typealias EngineNoticeEntryKey = NoticeEntryKey +public typealias EngineChatListIndex = ChatListIndex +public typealias EngineTempBoxFile = TempBoxFile +public typealias EngineItemCollectionItemIndex = ItemCollectionItemIndex +public typealias EngineItemCollectionViewEntryIndex = ItemCollectionViewEntryIndex +public typealias EngineValueBoxEncryptionParameters = ValueBoxEncryptionParameters +public typealias EngineMessageAndThreadId = MessageAndThreadId +public typealias EnginePeerStoryStats = PeerStoryStats +public typealias EngineMessageHistoryAnchorIndex = MessageHistoryAnchorIndex +public typealias EngineChatListTotalUnreadStateCategory = ChatListTotalUnreadStateCategory +public typealias EngineChatListTotalUnreadStateStats = ChatListTotalUnreadStateStats +public typealias EngineChatListTotalUnreadState = ChatListTotalUnreadState +public typealias EngineItemCacheEntryId = ItemCacheEntryId +public typealias EnginePeerSummaryCounterTags = PeerSummaryCounterTags +public typealias EngineHashFunctions = HashFunctions +public typealias EngineCachedMediaResourceRepresentationResult = CachedMediaResourceRepresentationResult +public typealias EngineMediaResourceDataFetchResult = MediaResourceDataFetchResult +public typealias EngineMediaResourceDataFetchError = MediaResourceDataFetchError +public typealias EngineMediaResourceStatus = MediaResourceStatus +public typealias EngineCachedPeerData = CachedPeerData + +public func engineFileSize(_ path: String, useTotalFileAllocatedSize: Bool = false) -> Int64? { + return fileSize(path, useTotalFileAllocatedSize: useTotalFileAllocatedSize) +} diff --git a/submodules/TelegramNotices/BUILD b/submodules/TelegramNotices/BUILD index 5a8b8127a4..00bc43ac10 100644 --- a/submodules/TelegramNotices/BUILD +++ b/submodules/TelegramNotices/BUILD @@ -10,7 +10,6 @@ swift_library( "-warnings-as-errors", ], deps = [ - "//submodules/Postbox:Postbox", "//submodules/TelegramCore:TelegramCore", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/TelegramPermissions:TelegramPermissions", diff --git a/submodules/TelegramNotices/Sources/Notices.swift b/submodules/TelegramNotices/Sources/Notices.swift index 7a7ac6d024..efbb638613 100644 --- a/submodules/TelegramNotices/Sources/Notices.swift +++ b/submodules/TelegramNotices/Sources/Notices.swift @@ -1,5 +1,4 @@ import Foundation -import Postbox import TelegramCore import SwiftSignalKit import TelegramPermissions @@ -119,14 +118,14 @@ public final class ApplicationSpecificInt64ArrayNotice: Codable { } } -private func noticeNamespace(namespace: Int32) -> ValueBoxKey { - let key = ValueBoxKey(length: 4) +private func noticeNamespace(namespace: Int32) -> EngineDataBuffer { + let key = EngineDataBuffer(length: 4) key.setInt32(0, value: namespace) return key } -private func noticeKey(peerId: PeerId, key: Int32) -> ValueBoxKey { - let v = ValueBoxKey(length: 8 + 4) +private func noticeKey(peerId: EnginePeer.Id, key: Int32) -> EngineDataBuffer { + let v = EngineDataBuffer(length: 8 + 4) v.setInt64(0, value: peerId.toInt64()) v.setInt32(8, value: key) return v @@ -210,15 +209,15 @@ private enum ApplicationSpecificGlobalNotice: Int32 { case aiTextProcessingStyleSelectionTips = 87 case savedMessagesChatListView = 88 - var key: ValueBoxKey { - let v = ValueBoxKey(length: 4) + var key: EngineDataBuffer { + let v = EngineDataBuffer(length: 4) v.setInt32(0, value: self.rawValue) return v } } private extension PermissionKind { - var noticeKey: NoticeEntryKey? { + var noticeKey: EngineNoticeEntryKey? { switch self { case .contacts: return ApplicationSpecificNoticeKeys.contactsPermissionWarning() @@ -247,365 +246,365 @@ private struct ApplicationSpecificNoticeKeys { private static let displayedPeerVerificationNamespace: Int32 = 11 private static let dismissedPaidMessageWarningNamespace: Int32 = 11 - static func inlineBotLocationRequestNotice(peerId: PeerId) -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: inlineBotLocationRequestNamespace), key: noticeKey(peerId: peerId, key: 0)) + static func inlineBotLocationRequestNotice(peerId: EnginePeer.Id) -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: inlineBotLocationRequestNamespace), key: noticeKey(peerId: peerId, key: 0)) } - static func botPaymentLiabilityNotice(peerId: PeerId) -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: botPaymentLiabilityNamespace), key: noticeKey(peerId: peerId, key: 0)) + static func botPaymentLiabilityNotice(peerId: EnginePeer.Id) -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: botPaymentLiabilityNamespace), key: noticeKey(peerId: peerId, key: 0)) } - static func botGameNotice(peerId: PeerId) -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: botGameNoticeNamespace), key: noticeKey(peerId: peerId, key: 0)) + static func botGameNotice(peerId: EnginePeer.Id) -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: botGameNoticeNamespace), key: noticeKey(peerId: peerId, key: 0)) } - static func irrelevantPeerGeoNotice(peerId: PeerId) -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: peerReportNamespace), key: noticeKey(peerId: peerId, key: 0)) + static func irrelevantPeerGeoNotice(peerId: EnginePeer.Id) -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: peerReportNamespace), key: noticeKey(peerId: peerId, key: 0)) } - static func dismissedPremiumGiftNotice(peerId: PeerId) -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: dismissedPremiumGiftNamespace), key: noticeKey(peerId: peerId, key: 0)) + static func dismissedPremiumGiftNotice(peerId: EnginePeer.Id) -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: dismissedPremiumGiftNamespace), key: noticeKey(peerId: peerId, key: 0)) } - static func groupEmojiPackNotice(peerId: PeerId) -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: groupEmojiPackNamespace), key: noticeKey(peerId: peerId, key: 0)) + static func groupEmojiPackNotice(peerId: EnginePeer.Id) -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: groupEmojiPackNamespace), key: noticeKey(peerId: peerId, key: 0)) } - static func forcedPasswordSetup() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.secretChatInlineBotUsage.key) + static func forcedPasswordSetup() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.secretChatInlineBotUsage.key) } - static func secretChatInlineBotUsage() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.secretChatInlineBotUsage.key) + static func secretChatInlineBotUsage() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.secretChatInlineBotUsage.key) } - static func secretChatLinkPreviews() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.secretChatLinkPreviews.key) + static func secretChatLinkPreviews() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.secretChatLinkPreviews.key) } - static func archiveIntroDismissed() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.archiveIntroDismissed.key) + static func archiveIntroDismissed() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.archiveIntroDismissed.key) } - static func chatMediaMediaRecordingTips() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatMediaMediaRecordingTips.key) + static func chatMediaMediaRecordingTips() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatMediaMediaRecordingTips.key) } - static func archiveChatTips() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.archiveChatTips.key) + static func archiveChatTips() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.archiveChatTips.key) } - static func chatFolderTips() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatFolderTips.key) + static func chatFolderTips() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatFolderTips.key) } - static func profileCallTips() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.profileCallTips.key) + static func profileCallTips() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.profileCallTips.key) } - static func proxyAdsAcknowledgment() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.proxyAdsAcknowledgment.key) + static func proxyAdsAcknowledgment() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.proxyAdsAcknowledgment.key) } - static func psaAdsAcknowledgment(peerId: PeerId) -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: psaAcknowledgementNamespace), key: noticeKey(peerId: peerId, key: 0)) + static func psaAdsAcknowledgment(peerId: EnginePeer.Id) -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: psaAcknowledgementNamespace), key: noticeKey(peerId: peerId, key: 0)) } - static func setPublicChannelLink() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.setPublicChannelLink.key) + static func setPublicChannelLink() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.setPublicChannelLink.key) } - static func passcodeLockTips() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.passcodeLockTips.key) + static func passcodeLockTips() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.passcodeLockTips.key) } - static func contactsPermissionWarning() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: permissionsNamespace), key: ApplicationSpecificGlobalNotice.contactsPermissionWarning.key) + static func contactsPermissionWarning() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: permissionsNamespace), key: ApplicationSpecificGlobalNotice.contactsPermissionWarning.key) } - static func notificationsPermissionWarning() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: permissionsNamespace), key: ApplicationSpecificGlobalNotice.notificationsPermissionWarning.key) + static func notificationsPermissionWarning() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: permissionsNamespace), key: ApplicationSpecificGlobalNotice.notificationsPermissionWarning.key) } - static func cellularDataPermissionWarning() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: permissionsNamespace), key: ApplicationSpecificGlobalNotice.cellularDataPermissionWarning.key) + static func cellularDataPermissionWarning() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: permissionsNamespace), key: ApplicationSpecificGlobalNotice.cellularDataPermissionWarning.key) } - static func volumeButtonToUnmuteTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.volumeButtonToUnmuteTip.key) + static func volumeButtonToUnmuteTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.volumeButtonToUnmuteTip.key) } - static func callsTabTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.callsTabTip.key) + static func callsTabTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.callsTabTip.key) } - static func chatMessageSearchResultsTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatMessageSearchResultsTip.key) + static func chatMessageSearchResultsTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatMessageSearchResultsTip.key) } - static func chatMessageOptionsTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatMessageOptionsTip.key) + static func chatMessageOptionsTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatMessageOptionsTip.key) } - static func chatTextSelectionTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatTextSelectionTip.key) + static func chatTextSelectionTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatTextSelectionTip.key) } - static func messageViewsPrivacyTips() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.messageViewsPrivacyTips.key) + static func messageViewsPrivacyTips() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.messageViewsPrivacyTips.key) } - static func themeChangeTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.themeChangeTip.key) + static func themeChangeTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.themeChangeTip.key) } - static func locationProximityAlertTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.locationProximityAlertTip.key) + static func locationProximityAlertTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.locationProximityAlertTip.key) } - static func nextChatSuggestionTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.nextChatSuggestionTip.key) + static func nextChatSuggestionTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.nextChatSuggestionTip.key) } - static func dismissedTrendingStickerPacks() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.dismissedTrendingStickerPacks.key) + static func dismissedTrendingStickerPacks() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.dismissedTrendingStickerPacks.key) } - static func chatSpecificThemeLightPreviewTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatSpecificThemeLightPreviewTip.key) + static func chatSpecificThemeLightPreviewTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatSpecificThemeLightPreviewTip.key) } - static func chatSpecificThemeDarkPreviewTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatSpecificThemeDarkPreviewTip.key) + static func chatSpecificThemeDarkPreviewTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatSpecificThemeDarkPreviewTip.key) } - static func chatWallpaperLightPreviewTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatWallpaperLightPreviewTip.key) + static func chatWallpaperLightPreviewTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatWallpaperLightPreviewTip.key) } - static func chatWallpaperDarkPreviewTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatWallpaperDarkPreviewTip.key) + static func chatWallpaperDarkPreviewTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatWallpaperDarkPreviewTip.key) } - static func chatForwardOptionsTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatForwardOptionsTip.key) + static func chatForwardOptionsTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatForwardOptionsTip.key) } - static func chatReplyOptionsTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatReplyOptionsTip.key) + static func chatReplyOptionsTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.chatReplyOptionsTip.key) } - static func interactiveEmojiSyncTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.interactiveEmojiSyncTip.key) + static func interactiveEmojiSyncTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.interactiveEmojiSyncTip.key) } - static func dismissedInvitationRequestsNotice(peerId: PeerId) -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: peerInviteRequestsNamespace), key: noticeKey(peerId: peerId, key: 0)) + static func dismissedInvitationRequestsNotice(peerId: EnginePeer.Id) -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: peerInviteRequestsNamespace), key: noticeKey(peerId: peerId, key: 0)) } - static func sharedMediaScrollingTooltip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.sharedMediaScrollingTooltip.key) + static func sharedMediaScrollingTooltip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.sharedMediaScrollingTooltip.key) } - static func sharedMediaFastScrollingTooltip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.sharedMediaFastScrollingTooltip.key) + static func sharedMediaFastScrollingTooltip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.sharedMediaFastScrollingTooltip.key) } - static func emojiTooltip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.emojiTooltip.key) + static func emojiTooltip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.emojiTooltip.key) } - static func audioTranscriptionSuggestion() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.audioTranscriptionSuggestion.key) + static func audioTranscriptionSuggestion() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.audioTranscriptionSuggestion.key) } - static func clearStorageDismissedTipSize() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.clearStorageDismissedTipSize.key) + static func clearStorageDismissedTipSize() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.clearStorageDismissedTipSize.key) } - static func dismissedTrendingEmojiPacks() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.dismissedTrendingEmojiPacks.key) + static func dismissedTrendingEmojiPacks() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.dismissedTrendingEmojiPacks.key) } - static func translationSuggestionNotice() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.translationSuggestion.key) + static func translationSuggestionNotice() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.translationSuggestion.key) } - static func audioRateOptionsTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.audioRateOptionsTip.key) + static func audioRateOptionsTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.audioRateOptionsTip.key) } - static func sendWhenOnlineTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.sendWhenOnlineTip.key) + static func sendWhenOnlineTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.sendWhenOnlineTip.key) } - static func displayChatListContacts() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.displayChatListContacts.key) + static func displayChatListContacts() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.displayChatListContacts.key) } - static func displayChatListStoriesTooltip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.displayChatListStoriesTooltip.key) + static func displayChatListStoriesTooltip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.displayChatListStoriesTooltip.key) } - static func storiesCameraTooltip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.storiesCameraTooltip.key) + static func storiesCameraTooltip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.storiesCameraTooltip.key) } - static func storiesDualCameraTooltip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.storiesDualCameraTooltip.key) + static func storiesDualCameraTooltip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.storiesDualCameraTooltip.key) } - static func displayChatListArchiveTooltip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.displayChatListArchiveTooltip.key) + static func displayChatListArchiveTooltip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.displayChatListArchiveTooltip.key) } - static func displayStoryReactionTooltip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.displayStoryReactionTooltip.key) + static func displayStoryReactionTooltip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.displayStoryReactionTooltip.key) } - static func storyStealthModeReplyCount() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.storyStealthModeReplyCount.key) + static func storyStealthModeReplyCount() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.storyStealthModeReplyCount.key) } - static func viewOnceTooltip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.viewOnceTooltip.key) + static func viewOnceTooltip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.viewOnceTooltip.key) } - static func displayStoryUnmuteTooltip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.displayStoryUnmuteTooltip.key) + static func displayStoryUnmuteTooltip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.displayStoryUnmuteTooltip.key) } - static func displayStoryInteractionGuide() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.displayStoryInteractionGuide.key) + static func displayStoryInteractionGuide() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.displayStoryInteractionGuide.key) } - static func replyQuoteTextSelectionTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.replyQuoteTextSelectionTip.key) + static func replyQuoteTextSelectionTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.replyQuoteTextSelectionTip.key) } - static func multipleReactionsSuggestion() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.multipleReactionsSuggestion.key) + static func multipleReactionsSuggestion() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.multipleReactionsSuggestion.key) } - static func savedMessagesChatsSuggestion() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.savedMessagesChatsSuggestion.key) + static func savedMessagesChatsSuggestion() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.savedMessagesChatsSuggestion.key) } - static func voiceMessagesPlayOnceSuggestion() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.voiceMessagesPlayOnceSuggestion.key) + static func voiceMessagesPlayOnceSuggestion() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.voiceMessagesPlayOnceSuggestion.key) } - static func incomingVoiceMessagePlayOnceTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.incomingVoiceMessagePlayOnceTip.key) + static func incomingVoiceMessagePlayOnceTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.incomingVoiceMessagePlayOnceTip.key) } - static func outgoingVoiceMessagePlayOnceTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.outgoingVoiceMessagePlayOnceTip.key) + static func outgoingVoiceMessagePlayOnceTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.outgoingVoiceMessagePlayOnceTip.key) } - static func videoMessagesPlayOnceSuggestion() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.videoMessagesPlayOnceSuggestion.key) + static func videoMessagesPlayOnceSuggestion() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.videoMessagesPlayOnceSuggestion.key) } - static func incomingVideoMessagePlayOnceTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.incomingVideoMessagePlayOnceTip.key) + static func incomingVideoMessagePlayOnceTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.incomingVideoMessagePlayOnceTip.key) } - static func outgoingVideoMessagePlayOnceTip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.outgoingVideoMessagePlayOnceTip.key) + static func outgoingVideoMessagePlayOnceTip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.outgoingVideoMessagePlayOnceTip.key) } - static func savedMessageTagLabelSuggestion() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.savedMessageTagLabelSuggestion.key) + static func savedMessageTagLabelSuggestion() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.savedMessageTagLabelSuggestion.key) } - static func dismissedBirthdayPremiumGiftTip(peerId: PeerId) -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: dismissedBirthdayPremiumGiftTipNamespace), key: noticeKey(peerId: peerId, key: 0)) + static func dismissedBirthdayPremiumGiftTip(peerId: EnginePeer.Id) -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: dismissedBirthdayPremiumGiftTipNamespace), key: noticeKey(peerId: peerId, key: 0)) } - static func displayedPeerVerification(peerId: PeerId) -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: displayedPeerVerificationNamespace), key: noticeKey(peerId: peerId, key: 0)) + static func displayedPeerVerification(peerId: EnginePeer.Id) -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: displayedPeerVerificationNamespace), key: noticeKey(peerId: peerId, key: 0)) } - static func dismissedPaidMessageWarning(peerId: PeerId) -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: dismissedPaidMessageWarningNamespace), key: noticeKey(peerId: peerId, key: 0)) + static func dismissedPaidMessageWarning(peerId: EnginePeer.Id) -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: dismissedPaidMessageWarningNamespace), key: noticeKey(peerId: peerId, key: 0)) } - static func monetizationIntroDismissed() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.monetizationIntroDismissed.key) + static func monetizationIntroDismissed() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.monetizationIntroDismissed.key) } - static func businessBotMessageTooltip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.businessBotMessageTooltip.key) + static func businessBotMessageTooltip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.businessBotMessageTooltip.key) } - static func captionAboveMediaTooltip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.captionAboveMediaTooltip.key) + static func captionAboveMediaTooltip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.captionAboveMediaTooltip.key) } - static func channelSendGiftTooltip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.channelSendGiftTooltip.key) + static func channelSendGiftTooltip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.channelSendGiftTooltip.key) } - static func starGiftWearTips() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.starGiftWearTips.key) + static func starGiftWearTips() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.starGiftWearTips.key) } - static func channelSuggestTooltip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.channelSuggestTooltip.key) + static func channelSuggestTooltip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.channelSuggestTooltip.key) } - static func multipleStoriesTooltip() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.multipleStoriesTooltip.key) + static func multipleStoriesTooltip() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.multipleStoriesTooltip.key) } - static func voiceMessagesPauseSuggestion() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.voiceMessagesPauseSuggestion.key) + static func voiceMessagesPauseSuggestion() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.voiceMessagesPauseSuggestion.key) } - static func videoMessagesPauseSuggestion() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.videoMessagesPauseSuggestion.key) + static func videoMessagesPauseSuggestion() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.videoMessagesPauseSuggestion.key) } - static func voiceMessagesResumeTrimWarning() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.voiceMessagesResumeTrimWarning.key) + static func voiceMessagesResumeTrimWarning() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.voiceMessagesResumeTrimWarning.key) } - static func globalPostsSearch() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.globalPostsSearch.key) + static func globalPostsSearch() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.globalPostsSearch.key) } - static func giftAuctionTips() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.giftAuctionTips.key) + static func giftAuctionTips() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.giftAuctionTips.key) } - static func giftCraftingTips() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.giftCraftingTips.key) + static func giftCraftingTips() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.giftCraftingTips.key) } - static func copyProtectionTips() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.copyProtectionTips.key) + static func copyProtectionTips() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.copyProtectionTips.key) } - static func aiTextProcessingStyleSelectionTips() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.aiTextProcessingStyleSelectionTips.key) + static func aiTextProcessingStyleSelectionTips() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.aiTextProcessingStyleSelectionTips.key) } - static func savedMessagesChatListView() -> NoticeEntryKey { - return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.savedMessagesChatListView.key) + static func savedMessagesChatListView() -> EngineNoticeEntryKey { + return EngineNoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.savedMessagesChatListView.key) } } public struct ApplicationSpecificNotice { - public static func irrelevantPeerGeoReportKey(peerId: PeerId) -> NoticeEntryKey { + public static func irrelevantPeerGeoReportKey(peerId: EnginePeer.Id) -> EngineNoticeEntryKey { return ApplicationSpecificNoticeKeys.irrelevantPeerGeoNotice(peerId: peerId) } - public static func setIrrelevantPeerGeoReport(engine: TelegramEngine, peerId: PeerId) -> Signal { + public static func setIrrelevantPeerGeoReport(engine: TelegramEngine, peerId: EnginePeer.Id) -> Signal { return engine.notices.set(id: ApplicationSpecificNoticeKeys.irrelevantPeerGeoNotice(peerId: peerId), item: ApplicationSpecificBoolNotice()) } - public static func getBotPaymentLiability(accountManager: AccountManager, peerId: PeerId) -> Signal { + public static func getBotPaymentLiability(accountManager: AccountManager, peerId: EnginePeer.Id) -> Signal { return accountManager.transaction { transaction -> Bool in if let _ = transaction.getNotice(ApplicationSpecificNoticeKeys.botPaymentLiabilityNotice(peerId: peerId))?.get(ApplicationSpecificBoolNotice.self) { return true @@ -615,15 +614,15 @@ public struct ApplicationSpecificNotice { } } - public static func setBotPaymentLiability(accountManager: AccountManager, peerId: PeerId) -> Signal { + public static func setBotPaymentLiability(accountManager: AccountManager, peerId: EnginePeer.Id) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.botPaymentLiabilityNotice(peerId: peerId), entry) } } } - public static func getBotGameNotice(accountManager: AccountManager, peerId: PeerId) -> Signal { + public static func getBotGameNotice(accountManager: AccountManager, peerId: EnginePeer.Id) -> Signal { return accountManager.transaction { transaction -> Bool in if let _ = transaction.getNotice(ApplicationSpecificNoticeKeys.botGameNotice(peerId: peerId))?.get(ApplicationSpecificBoolNotice.self) { return true @@ -633,15 +632,15 @@ public struct ApplicationSpecificNotice { } } - public static func setBotGameNotice(accountManager: AccountManager, peerId: PeerId) -> Signal { + public static func setBotGameNotice(accountManager: AccountManager, peerId: EnginePeer.Id) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.botGameNotice(peerId: peerId), entry) } } } - public static func getInlineBotLocationRequest(accountManager: AccountManager, peerId: PeerId) -> Signal { + public static func getInlineBotLocationRequest(accountManager: AccountManager, peerId: EnginePeer.Id) -> Signal { return accountManager.transaction { transaction -> Int32? in if let notice = transaction.getNotice(ApplicationSpecificNoticeKeys.inlineBotLocationRequestNotice(peerId: peerId))?.get(ApplicationSpecificTimestampNotice.self) { return notice.value @@ -651,7 +650,7 @@ public struct ApplicationSpecificNotice { } } - public static func inlineBotLocationRequestStatus(accountManager: AccountManager, peerId: PeerId) -> Signal { + public static func inlineBotLocationRequestStatus(accountManager: AccountManager, peerId: EnginePeer.Id) -> Signal { return accountManager.noticeEntry(key: ApplicationSpecificNoticeKeys.inlineBotLocationRequestNotice(peerId: peerId)) |> map { view -> Bool in guard let value = view.value?.get(ApplicationSpecificTimestampNotice.self) else { @@ -665,13 +664,13 @@ public struct ApplicationSpecificNotice { } } - public static func updateInlineBotLocationRequestState(accountManager: AccountManager, peerId: PeerId, timestamp: Int32) -> Signal { + public static func updateInlineBotLocationRequestState(accountManager: AccountManager, peerId: EnginePeer.Id, timestamp: Int32) -> Signal { return accountManager.transaction { transaction -> Bool in if let notice = transaction.getNotice(ApplicationSpecificNoticeKeys.inlineBotLocationRequestNotice(peerId: peerId))?.get(ApplicationSpecificTimestampNotice.self), (notice.value == 0 || timestamp <= notice.value + 10 * 60) { return false } - if let entry = CodableEntry(ApplicationSpecificTimestampNotice(value: timestamp)) { + if let entry = EngineCodableEntry(ApplicationSpecificTimestampNotice(value: timestamp)) { transaction.setNotice(ApplicationSpecificNoticeKeys.inlineBotLocationRequestNotice(peerId: peerId), entry) } @@ -679,9 +678,9 @@ public struct ApplicationSpecificNotice { } } - public static func setInlineBotLocationRequest(accountManager: AccountManager, peerId: PeerId, value: Int32) -> Signal { + public static func setInlineBotLocationRequest(accountManager: AccountManager, peerId: EnginePeer.Id, value: Int32) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificTimestampNotice(value: value)) { + if let entry = EngineCodableEntry(ApplicationSpecificTimestampNotice(value: value)) { transaction.setNotice(ApplicationSpecificNoticeKeys.inlineBotLocationRequestNotice(peerId: peerId), entry) } } @@ -699,14 +698,14 @@ public struct ApplicationSpecificNotice { public static func setSecretChatInlineBotUsage(accountManager: AccountManager) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.secretChatInlineBotUsage(), entry) } } } public static func setSecretChatInlineBotUsage(transaction: AccountManagerModifier) { - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.secretChatInlineBotUsage(), entry) } } @@ -721,7 +720,7 @@ public struct ApplicationSpecificNotice { } } - public static func getSecretChatLinkPreviews(_ entry: CodableEntry) -> Bool? { + public static func getSecretChatLinkPreviews(_ entry: EngineCodableEntry) -> Bool? { if let value = entry.get(ApplicationSpecificVariantNotice.self) { return value.value } else { @@ -731,19 +730,19 @@ public struct ApplicationSpecificNotice { public static func setSecretChatLinkPreviews(accountManager: AccountManager, value: Bool) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificVariantNotice(value: value)) { + if let entry = EngineCodableEntry(ApplicationSpecificVariantNotice(value: value)) { transaction.setNotice(ApplicationSpecificNoticeKeys.secretChatLinkPreviews(), entry) } } } public static func setSecretChatLinkPreviews(transaction: AccountManagerModifier, value: Bool) { - if let entry = CodableEntry(ApplicationSpecificVariantNotice(value: value)) { + if let entry = EngineCodableEntry(ApplicationSpecificVariantNotice(value: value)) { transaction.setNotice(ApplicationSpecificNoticeKeys.secretChatLinkPreviews(), entry) } } - public static func secretChatLinkPreviewsKey() -> NoticeEntryKey { + public static func secretChatLinkPreviewsKey() -> EngineNoticeEntryKey { return ApplicationSpecificNoticeKeys.secretChatLinkPreviews() } @@ -765,7 +764,7 @@ public struct ApplicationSpecificNotice { } currentValue += count - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.chatMediaMediaRecordingTips(), entry) } } @@ -790,7 +789,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.archiveChatTips(), entry) } @@ -807,7 +806,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.chatFolderTips(), entry) } @@ -816,12 +815,12 @@ public struct ApplicationSpecificNotice { } public static func setArchiveIntroDismissed(transaction: AccountManagerModifier, value: Bool) { - if let entry = CodableEntry(ApplicationSpecificVariantNotice(value: value)) { + if let entry = EngineCodableEntry(ApplicationSpecificVariantNotice(value: value)) { transaction.setNotice(ApplicationSpecificNoticeKeys.archiveIntroDismissed(), entry) } } - public static func archiveIntroDismissedKey() -> NoticeEntryKey { + public static func archiveIntroDismissedKey() -> EngineNoticeEntryKey { return ApplicationSpecificNoticeKeys.archiveIntroDismissed() } @@ -843,7 +842,7 @@ public struct ApplicationSpecificNotice { } currentValue += count - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.profileCallTips(), entry) } } @@ -861,7 +860,7 @@ public struct ApplicationSpecificNotice { public static func markAsSeenSetPublicChannelLink(accountManager: AccountManager) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: 1)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: 1)) { transaction.setNotice(ApplicationSpecificNoticeKeys.profileCallTips(), entry) } } @@ -879,13 +878,13 @@ public struct ApplicationSpecificNotice { public static func setProxyAdsAcknowledgment(accountManager: AccountManager) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.proxyAdsAcknowledgment(), entry) } } } - public static func getPsaAcknowledgment(accountManager: AccountManager, peerId: PeerId) -> Signal { + public static func getPsaAcknowledgment(accountManager: AccountManager, peerId: EnginePeer.Id) -> Signal { return accountManager.transaction { transaction -> Bool in if let _ = transaction.getNotice(ApplicationSpecificNoticeKeys.psaAdsAcknowledgment(peerId: peerId))?.get(ApplicationSpecificBoolNotice.self) { return true @@ -895,9 +894,9 @@ public struct ApplicationSpecificNotice { } } - public static func setPsaAcknowledgment(accountManager: AccountManager, peerId: PeerId) -> Signal { + public static func setPsaAcknowledgment(accountManager: AccountManager, peerId: EnginePeer.Id) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.psaAdsAcknowledgment(peerId: peerId), entry) } } @@ -915,13 +914,13 @@ public struct ApplicationSpecificNotice { public static func setPasscodeLockTips(accountManager: AccountManager) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.passcodeLockTips(), entry) } } } - public static func permissionWarningKey(permission: PermissionKind) -> NoticeEntryKey? { + public static func permissionWarningKey(permission: PermissionKind) -> EngineNoticeEntryKey? { return permission.noticeKey } @@ -930,13 +929,13 @@ public struct ApplicationSpecificNotice { return } let _ = (accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificTimestampNotice(value: value)) { + if let entry = EngineCodableEntry(ApplicationSpecificTimestampNotice(value: value)) { transaction.setNotice(noticeKey, entry) } }).start() } - public static func getTimestampValue(_ entry: CodableEntry) -> Int32? { + public static func getTimestampValue(_ entry: EngineCodableEntry) -> Int32? { if let value = entry.get(ApplicationSpecificTimestampNotice.self) { return value.value } else { @@ -956,7 +955,7 @@ public struct ApplicationSpecificNotice { public static func setVolumeButtonToUnmute(accountManager: AccountManager) { let _ = accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.volumeButtonToUnmuteTip(), entry) } }.start() @@ -981,7 +980,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += min(3, Int32(count)) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.callsTabTip(), entry) } @@ -991,7 +990,7 @@ public struct ApplicationSpecificNotice { public static func setCallsTabTip(accountManager: AccountManager) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.callsTabTip(), entry) } } @@ -1016,7 +1015,7 @@ public struct ApplicationSpecificNotice { } currentValue += count - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.chatMessageSearchResultsTip(), entry) } } @@ -1040,7 +1039,7 @@ public struct ApplicationSpecificNotice { } currentValue += count - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.chatMessageOptionsTip(), entry) } } @@ -1064,7 +1063,7 @@ public struct ApplicationSpecificNotice { } currentValue += count - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.chatTextSelectionTip(), entry) } } @@ -1088,7 +1087,7 @@ public struct ApplicationSpecificNotice { } currentValue += count - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.replyQuoteTextSelectionTip(), entry) } } @@ -1112,7 +1111,7 @@ public struct ApplicationSpecificNotice { } currentValue += count - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.messageViewsPrivacyTips(), entry) } } @@ -1130,7 +1129,7 @@ public struct ApplicationSpecificNotice { public static func markThemeChangeTipAsSeen(accountManager: AccountManager) { let _ = accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.themeChangeTip(), entry) } }.start() @@ -1154,7 +1153,7 @@ public struct ApplicationSpecificNotice { } currentValue += count - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.chatMessageOptionsTip(), entry) } } @@ -1178,7 +1177,7 @@ public struct ApplicationSpecificNotice { } currentValue += count - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.nextChatSuggestionTip(), entry) } } @@ -1202,7 +1201,7 @@ public struct ApplicationSpecificNotice { } currentValue += count - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.sharedMediaScrollingTooltip(), entry) } } @@ -1226,7 +1225,7 @@ public struct ApplicationSpecificNotice { } currentValue += count - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.sharedMediaFastScrollingTooltip(), entry) } } @@ -1250,7 +1249,7 @@ public struct ApplicationSpecificNotice { } currentValue += count - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.emojiTooltip(), entry) } } @@ -1269,7 +1268,7 @@ public struct ApplicationSpecificNotice { public static func setDismissedTrendingStickerPacks(accountManager: AccountManager, values: [Int64]) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificInt64ArrayNotice(values: values)) { + if let entry = EngineCodableEntry(ApplicationSpecificInt64ArrayNotice(values: values)) { transaction.setNotice(ApplicationSpecificNoticeKeys.dismissedTrendingStickerPacks(), entry) } } @@ -1288,7 +1287,7 @@ public struct ApplicationSpecificNotice { public static func setDismissedTrendingEmojiPacks(accountManager: AccountManager, values: [Int64]) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificInt64ArrayNotice(values: values)) { + if let entry = EngineCodableEntry(ApplicationSpecificInt64ArrayNotice(values: values)) { transaction.setNotice(ApplicationSpecificNoticeKeys.dismissedTrendingEmojiPacks(), entry) } } @@ -1313,7 +1312,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificTimestampAndCounterNotice(counter: currentValue, timestamp: timestamp)) { + if let entry = EngineCodableEntry(ApplicationSpecificTimestampAndCounterNotice(counter: currentValue, timestamp: timestamp)) { transaction.setNotice(ApplicationSpecificNoticeKeys.chatSpecificThemeLightPreviewTip(), entry) } @@ -1340,7 +1339,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificTimestampAndCounterNotice(counter: currentValue, timestamp: timestamp)) { + if let entry = EngineCodableEntry(ApplicationSpecificTimestampAndCounterNotice(counter: currentValue, timestamp: timestamp)) { transaction.setNotice(ApplicationSpecificNoticeKeys.chatSpecificThemeDarkPreviewTip(), entry) } @@ -1367,7 +1366,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificTimestampAndCounterNotice(counter: currentValue, timestamp: timestamp)) { + if let entry = EngineCodableEntry(ApplicationSpecificTimestampAndCounterNotice(counter: currentValue, timestamp: timestamp)) { transaction.setNotice(ApplicationSpecificNoticeKeys.chatWallpaperLightPreviewTip(), entry) } @@ -1394,7 +1393,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificTimestampAndCounterNotice(counter: currentValue, timestamp: timestamp)) { + if let entry = EngineCodableEntry(ApplicationSpecificTimestampAndCounterNotice(counter: currentValue, timestamp: timestamp)) { transaction.setNotice(ApplicationSpecificNoticeKeys.chatWallpaperDarkPreviewTip(), entry) } @@ -1421,7 +1420,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.chatForwardOptionsTip(), entry) } @@ -1448,7 +1447,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.chatReplyOptionsTip(), entry) } @@ -1468,7 +1467,7 @@ public struct ApplicationSpecificNotice { public static func setClearStorageDismissedTipSize(accountManager: AccountManager, value: Int32) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: value)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: value)) { transaction.setNotice(ApplicationSpecificNoticeKeys.clearStorageDismissedTipSize(), entry) } } @@ -1494,7 +1493,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificTimestampAndCounterNotice(counter: currentValue, timestamp: timestamp)) { + if let entry = EngineCodableEntry(ApplicationSpecificTimestampAndCounterNotice(counter: currentValue, timestamp: timestamp)) { transaction.setNotice(ApplicationSpecificNoticeKeys.interactiveEmojiSyncTip(), entry) } @@ -1502,7 +1501,7 @@ public struct ApplicationSpecificNotice { } } - public static func dismissedInvitationRequests(accountManager: AccountManager, peerId: PeerId) -> Signal<[Int64]?, NoError> { + public static func dismissedInvitationRequests(accountManager: AccountManager, peerId: EnginePeer.Id) -> Signal<[Int64]?, NoError> { return accountManager.noticeEntry(key: ApplicationSpecificNoticeKeys.dismissedInvitationRequestsNotice(peerId: peerId)) |> map { view -> [Int64]? in if let value = view.value?.get(ApplicationSpecificInt64ArrayNotice.self) { @@ -1513,15 +1512,15 @@ public struct ApplicationSpecificNotice { } } - public static func setDismissedInvitationRequests(accountManager: AccountManager, peerId: PeerId, values: [Int64]) -> Signal { + public static func setDismissedInvitationRequests(accountManager: AccountManager, peerId: EnginePeer.Id, values: [Int64]) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificInt64ArrayNotice(values: values)) { + if let entry = EngineCodableEntry(ApplicationSpecificInt64ArrayNotice(values: values)) { transaction.setNotice(ApplicationSpecificNoticeKeys.dismissedInvitationRequestsNotice(peerId: peerId), entry) } } } - public static func forcedPasswordSetupKey() -> NoticeEntryKey { + public static func forcedPasswordSetupKey() -> EngineNoticeEntryKey { return ApplicationSpecificNoticeKeys.forcedPasswordSetup() } @@ -1533,7 +1532,7 @@ public struct ApplicationSpecificNotice { return engine.notices.set(id: ApplicationSpecificNoticeKeys.forcedPasswordSetup(), item: item) } - public static func audioTranscriptionSuggestionKey() -> NoticeEntryKey { + public static func audioTranscriptionSuggestionKey() -> EngineNoticeEntryKey { return ApplicationSpecificNoticeKeys.audioTranscriptionSuggestion() } @@ -1556,7 +1555,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += count - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.audioTranscriptionSuggestion(), entry) } @@ -1590,7 +1589,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue = max(0, Int32(currentValue + count)) - if let entry = CodableEntry(ApplicationSpecificTimestampAndCounterNotice(counter: currentValue, timestamp: timestamp)) { + if let entry = EngineCodableEntry(ApplicationSpecificTimestampAndCounterNotice(counter: currentValue, timestamp: timestamp)) { transaction.setNotice(ApplicationSpecificNoticeKeys.translationSuggestionNotice(), entry) } @@ -1618,14 +1617,14 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += count - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.audioRateOptionsTip(), entry) } return previousValue } } - public static func dismissedPremiumGiftSuggestion(accountManager: AccountManager, peerId: PeerId) -> Signal { + public static func dismissedPremiumGiftSuggestion(accountManager: AccountManager, peerId: EnginePeer.Id) -> Signal { return accountManager.noticeEntry(key: ApplicationSpecificNoticeKeys.dismissedPremiumGiftNotice(peerId: peerId)) |> map { view -> Int32? in if let value = view.value?.get(ApplicationSpecificTimestampNotice.self) { @@ -1636,16 +1635,16 @@ public struct ApplicationSpecificNotice { } } - public static func incrementDismissedPremiumGiftSuggestion(accountManager: AccountManager, peerId: PeerId, timestamp: Int32) -> Signal { + public static func incrementDismissedPremiumGiftSuggestion(accountManager: AccountManager, peerId: EnginePeer.Id, timestamp: Int32) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificTimestampNotice(value: timestamp)) { + if let entry = EngineCodableEntry(ApplicationSpecificTimestampNotice(value: timestamp)) { transaction.setNotice(ApplicationSpecificNoticeKeys.dismissedPremiumGiftNotice(peerId: peerId), entry) } } |> ignoreValues } - public static func groupEmojiPackSuggestion(accountManager: AccountManager, peerId: PeerId) -> Signal { + public static func groupEmojiPackSuggestion(accountManager: AccountManager, peerId: EnginePeer.Id) -> Signal { return accountManager.noticeEntry(key: ApplicationSpecificNoticeKeys.groupEmojiPackNotice(peerId: peerId)) |> map { view -> Int32 in if let value = view.value?.get(ApplicationSpecificCounterNotice.self) { @@ -1656,7 +1655,7 @@ public struct ApplicationSpecificNotice { } } - public static func incrementGroupEmojiPackSuggestion(accountManager: AccountManager, peerId: PeerId, count: Int32 = 1) -> Signal { + public static func incrementGroupEmojiPackSuggestion(accountManager: AccountManager, peerId: EnginePeer.Id, count: Int32 = 1) -> Signal { return accountManager.transaction { transaction -> Int32 in var currentValue: Int32 = 0 if let value = transaction.getNotice(ApplicationSpecificNoticeKeys.groupEmojiPackNotice(peerId: peerId))?.get(ApplicationSpecificCounterNotice.self) { @@ -1665,7 +1664,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += count - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.groupEmojiPackNotice(peerId: peerId), entry) } return previousValue @@ -1690,7 +1689,7 @@ public struct ApplicationSpecificNotice { } currentValue += count - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.sendWhenOnlineTip(), entry) } } @@ -1709,7 +1708,7 @@ public struct ApplicationSpecificNotice { public static func setDisplayChatListContacts(accountManager: AccountManager) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.displayChatListContacts(), entry) } } @@ -1729,7 +1728,7 @@ public struct ApplicationSpecificNotice { public static func setDisplayChatListStoriesTooltip(accountManager: AccountManager) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.displayChatListStoriesTooltip(), entry) } } @@ -1745,7 +1744,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.storiesCameraTooltip(), entry) } @@ -1772,7 +1771,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.storiesDualCameraTooltip(), entry) } @@ -1799,7 +1798,7 @@ public struct ApplicationSpecificNotice { public static func setDisplayStoryReactionTooltip(accountManager: AccountManager) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.displayStoryReactionTooltip(), entry) } } @@ -1820,7 +1819,7 @@ public struct ApplicationSpecificNotice { public static func setDisplayChatListArchiveTooltip(accountManager: AccountManager) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.displayChatListArchiveTooltip(), entry) } } @@ -1846,7 +1845,7 @@ public struct ApplicationSpecificNotice { value = item.value } - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: value + 1)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: value + 1)) { transaction.setNotice(ApplicationSpecificNoticeKeys.storyStealthModeReplyCount(), entry) } } @@ -1862,7 +1861,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.viewOnceTooltip(), entry) } @@ -1872,7 +1871,7 @@ public struct ApplicationSpecificNotice { public static func setDisplayStoryUnmuteTooltip(accountManager: AccountManager) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.displayStoryUnmuteTooltip(), entry) } } @@ -1893,7 +1892,7 @@ public struct ApplicationSpecificNotice { public static func setDisplayStoryInteractionGuide(accountManager: AccountManager) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.displayStoryInteractionGuide(), entry) } } @@ -1931,7 +1930,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.multipleReactionsSuggestion(), entry) } @@ -1958,7 +1957,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.savedMessagesChatsSuggestion(), entry) } @@ -1985,7 +1984,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.voiceMessagesPlayOnceSuggestion(), entry) } @@ -2012,7 +2011,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.incomingVoiceMessagePlayOnceTip(), entry) } @@ -2039,7 +2038,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.outgoingVoiceMessagePlayOnceTip(), entry) } @@ -2066,7 +2065,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.videoMessagesPlayOnceSuggestion(), entry) } @@ -2093,7 +2092,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.incomingVideoMessagePlayOnceTip(), entry) } @@ -2120,7 +2119,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.outgoingVideoMessagePlayOnceTip(), entry) } @@ -2147,7 +2146,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.savedMessageTagLabelSuggestion(), entry) } @@ -2155,7 +2154,7 @@ public struct ApplicationSpecificNotice { } } - public static func dismissedBirthdayPremiumGiftTip(accountManager: AccountManager, peerId: PeerId) -> Signal { + public static func dismissedBirthdayPremiumGiftTip(accountManager: AccountManager, peerId: EnginePeer.Id) -> Signal { return accountManager.noticeEntry(key: ApplicationSpecificNoticeKeys.dismissedBirthdayPremiumGiftTip(peerId: peerId)) |> map { view -> Int32? in if let value = view.value?.get(ApplicationSpecificTimestampNotice.self) { @@ -2166,16 +2165,16 @@ public struct ApplicationSpecificNotice { } } - public static func incrementDismissedBirthdayPremiumGiftTip(accountManager: AccountManager, peerId: PeerId, timestamp: Int32) -> Signal { + public static func incrementDismissedBirthdayPremiumGiftTip(accountManager: AccountManager, peerId: EnginePeer.Id, timestamp: Int32) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificTimestampNotice(value: timestamp)) { + if let entry = EngineCodableEntry(ApplicationSpecificTimestampNotice(value: timestamp)) { transaction.setNotice(ApplicationSpecificNoticeKeys.dismissedBirthdayPremiumGiftTip(peerId: peerId), entry) } } |> ignoreValues } - public static func displayedPeerVerification(accountManager: AccountManager, peerId: PeerId) -> Signal { + public static func displayedPeerVerification(accountManager: AccountManager, peerId: EnginePeer.Id) -> Signal { return accountManager.noticeEntry(key: ApplicationSpecificNoticeKeys.displayedPeerVerification(peerId: peerId)) |> map { view -> Bool in if let _ = view.value?.get(ApplicationSpecificBoolNotice.self) { @@ -2186,16 +2185,16 @@ public struct ApplicationSpecificNotice { } } - public static func setDisplayedPeerVerification(accountManager: AccountManager, peerId: PeerId) -> Signal { + public static func setDisplayedPeerVerification(accountManager: AccountManager, peerId: EnginePeer.Id) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.displayedPeerVerification(peerId: peerId), entry) } } |> ignoreValues } - public static func dismissedPaidMessageWarningNamespace(accountManager: AccountManager, peerId: PeerId) -> Signal { + public static func dismissedPaidMessageWarningNamespace(accountManager: AccountManager, peerId: EnginePeer.Id) -> Signal { return accountManager.noticeEntry(key: ApplicationSpecificNoticeKeys.dismissedPaidMessageWarning(peerId: peerId)) |> map { view -> Int64? in if let counter = view.value?.get(ApplicationSpecificCounterNotice.self) { @@ -2206,9 +2205,9 @@ public struct ApplicationSpecificNotice { } } - public static func setDismissedPaidMessageWarningNamespace(accountManager: AccountManager, peerId: PeerId, amount: Int64?) -> Signal { + public static func setDismissedPaidMessageWarningNamespace(accountManager: AccountManager, peerId: EnginePeer.Id, amount: Int64?) -> Signal { return accountManager.transaction { transaction -> Void in - if let amount, let entry = CodableEntry(ApplicationSpecificCounterNotice(value: Int32(amount))) { + if let amount, let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: Int32(amount))) { transaction.setNotice(ApplicationSpecificNoticeKeys.dismissedPaidMessageWarning(peerId: peerId), entry) } else { transaction.setNotice(ApplicationSpecificNoticeKeys.dismissedPaidMessageWarning(peerId: peerId), nil) @@ -2219,7 +2218,7 @@ public struct ApplicationSpecificNotice { public static func setMonetizationIntroDismissed(accountManager: AccountManager) -> Signal { return accountManager.transaction { transaction -> Void in - if let entry = CodableEntry(ApplicationSpecificBoolNotice()) { + if let entry = EngineCodableEntry(ApplicationSpecificBoolNotice()) { transaction.setNotice(ApplicationSpecificNoticeKeys.monetizationIntroDismissed(), entry) } } @@ -2257,7 +2256,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.businessBotMessageTooltip(), entry) } @@ -2284,7 +2283,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.captionAboveMediaTooltip(), entry) } @@ -2311,7 +2310,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.channelSendGiftTooltip(), entry) } @@ -2338,7 +2337,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.channelSuggestTooltip(), entry) } @@ -2365,7 +2364,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.starGiftWearTips(), entry) } @@ -2392,7 +2391,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.multipleStoriesTooltip(), entry) } @@ -2419,7 +2418,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.voiceMessagesPauseSuggestion(), entry) } @@ -2446,7 +2445,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.videoMessagesPauseSuggestion(), entry) } @@ -2473,7 +2472,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.voiceMessagesResumeTrimWarning(), entry) } @@ -2500,7 +2499,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.globalPostsSearch(), entry) } @@ -2527,7 +2526,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.giftAuctionTips(), entry) } @@ -2554,7 +2553,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.giftCraftingTips(), entry) } @@ -2581,7 +2580,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.copyProtectionTips(), entry) } @@ -2608,7 +2607,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.aiTextProcessingStyleSelectionTips(), entry) } @@ -2635,7 +2634,7 @@ public struct ApplicationSpecificNotice { let previousValue = currentValue currentValue += Int32(count) - if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { + if let entry = EngineCodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) { transaction.setNotice(ApplicationSpecificNoticeKeys.savedMessagesChatListView(), entry) } diff --git a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift index 4b5d5bd0f7..54111d6125 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift @@ -3,7 +3,6 @@ import UIKit import Display import TelegramCore import TelegramUIPreferences -import Postbox import SwiftSignalKit public func selectDateFillStaticColor(theme: PresentationTheme, wallpaper: TelegramWallpaper) -> UIColor { @@ -1270,7 +1269,7 @@ public extension BuiltinWallpaperData { fileSize: 122246 ) - static func generate(account: Account) { + static func generate(network: Network) { let slugToName: [(String, String)] = [ ("fqv01SQemVIBAAAApND8LDRUhRU", "`default`"), ("Ye7DfT2kCVIKAAAAhzXfrkdOjxs", "legacy"), @@ -1292,7 +1291,7 @@ public extension BuiltinWallpaperData { var signals: [Signal] = [] for (slug, name) in slugToName { - signals.append(getWallpaper(network: account.network, slug: slug) + signals.append(getWallpaper(network: network, slug: slug) |> map { wallpaper -> String? in switch wallpaper { case let .file(file): @@ -1346,7 +1345,7 @@ public func defaultBuiltinWallpaper(data: BuiltinWallpaperData, colors: [UInt32] isDark: false, slug: data.slug, file: TelegramMediaFile( - fileId: MediaId(namespace: Namespaces.Media.CloudFile, id: data.fileId), + fileId: EngineMedia.Id(namespace: Namespaces.Media.CloudFile, id: data.fileId), partialReference: nil, resource: CloudDocumentMediaResource( datacenterId: data.datacenterId, diff --git a/submodules/TelegramUI/Components/Ads/AdsInfoScreen/BUILD b/submodules/TelegramUI/Components/Ads/AdsInfoScreen/BUILD index fabf9626cc..1dbdf28129 100644 --- a/submodules/TelegramUI/Components/Ads/AdsInfoScreen/BUILD +++ b/submodules/TelegramUI/Components/Ads/AdsInfoScreen/BUILD @@ -12,7 +12,6 @@ swift_library( deps = [ "//submodules/AsyncDisplayKit", "//submodules/Display", - "//submodules/Postbox", "//submodules/TelegramCore", "//submodules/SSignalKit/SwiftSignalKit", "//submodules/ComponentFlow", diff --git a/submodules/TelegramUI/Components/Ads/AdsInfoScreen/Sources/AdsInfoScreen.swift b/submodules/TelegramUI/Components/Ads/AdsInfoScreen/Sources/AdsInfoScreen.swift index a582b3979f..8b0c09230d 100644 --- a/submodules/TelegramUI/Components/Ads/AdsInfoScreen/Sources/AdsInfoScreen.swift +++ b/submodules/TelegramUI/Components/Ads/AdsInfoScreen/Sources/AdsInfoScreen.swift @@ -4,7 +4,6 @@ import Display import AsyncDisplayKit import ComponentFlow import SwiftSignalKit -import Postbox import TelegramCore import Markdown import TextFormat @@ -1378,7 +1377,7 @@ public class AdsInfoScreen: ViewController { private let context: AccountContext private let mode: Mode - private let message: Message? + private let message: EngineMessage? private let forceDark: Bool private var currentLayout: ContainerViewLayout? @@ -1388,7 +1387,7 @@ public class AdsInfoScreen: ViewController { public init( context: AccountContext, mode: Mode, - message: Message? = nil, + message: EngineMessage? = nil, forceDark: Bool = false ) { self.context = context diff --git a/submodules/TelegramUI/Components/Chat/ChatButtonKeyboardInputNode/Sources/ChatButtonKeyboardInputNode.swift b/submodules/TelegramUI/Components/Chat/ChatButtonKeyboardInputNode/Sources/ChatButtonKeyboardInputNode.swift index b5a68e6976..f9b1e28894 100644 --- a/submodules/TelegramUI/Components/Chat/ChatButtonKeyboardInputNode/Sources/ChatButtonKeyboardInputNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatButtonKeyboardInputNode/Sources/ChatButtonKeyboardInputNode.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import Display import AsyncDisplayKit -import Postbox import TelegramCore import SwiftSignalKit import TelegramPresentationData @@ -149,7 +148,7 @@ private final class ChatButtonKeyboardInputButtonNode: HighlightTrackingButtonNo maxTextWidth -= iconSize.width + iconSpacing var animationContent: EmojiStatusComponent.AnimationContent = .customEmoji(fileId: iconFileId) - if let file = message.associatedMedia[MediaId(namespace: Namespaces.Media.CloudFile, id: iconFileId)] as? TelegramMediaFile { + if let file = message.associatedMedia[EngineMedia.Id(namespace: Namespaces.Media.CloudFile, id: iconFileId)] as? TelegramMediaFile { animationContent = .file(file: file) } @@ -208,7 +207,7 @@ public final class ChatButtonKeyboardInputNode: ChatInputNode, UIScrollViewDeleg private let scrollNode: ASScrollNode private var buttonNodes: [ChatButtonKeyboardInputButtonNode] = [] - private var message: Message? + private var message: EngineMessage? private var theme: PresentationTheme? @@ -286,7 +285,7 @@ public final class ChatButtonKeyboardInputNode: ChatInputNode, UIScrollViewDeleg } } - self.message = interfaceState.keyboardButtonsMessage + self.message = interfaceState.keyboardButtonsMessage.flatMap(EngineMessage.init) if let markup = validatedMarkup, let message = self.message { let verticalInset: CGFloat = 18.0 @@ -325,7 +324,7 @@ public final class ChatButtonKeyboardInputNode: ChatInputNode, UIScrollViewDeleg let buttonFrame = CGRect(origin: CGPoint(x: sideInset + CGFloat(columnIndex) * (buttonWidth + columnSpacing), y: verticalOffset), size: CGSize(width: buttonWidth, height: buttonHeight)) buttonNode.frame = buttonFrame buttonNode.tintMaskView.frame = buttonFrame - buttonNode.update(context: self.context, size: buttonFrame.size, theme: interfaceState.theme, wallpaperBackgroundNode: self.controllerInteraction.presentationContext.backgroundNode, button: button, message: EngineMessage(message)) + buttonNode.update(context: self.context, size: buttonFrame.size, theme: interfaceState.theme, wallpaperBackgroundNode: self.controllerInteraction.presentationContext.backgroundNode, button: button, message: message) columnIndex += 1 } verticalOffset += buttonHeight + rowSpacing @@ -391,35 +390,35 @@ public final class ChatButtonKeyboardInputNode: ChatInputNode, UIScrollViewDeleg self.controllerInteraction.shareAccountContact() case .openWebApp: if let message = self.message { - self.controllerInteraction.requestMessageActionCallback(message, nil, true, false, nil) + self.controllerInteraction.requestMessageActionCallback(message._asMessage(), nil, true, false, nil) } case let .callback(requiresPassword, data): if let message = self.message { - self.controllerInteraction.requestMessageActionCallback(message, data, false, requiresPassword, nil) + self.controllerInteraction.requestMessageActionCallback(message._asMessage(), data, false, requiresPassword, nil) } case let .switchInline(samePeer, query, _): if let message = message { - var botPeer: Peer? - + var botPeer: EnginePeer? + var found = false for attribute in message.attributes { if let attribute = attribute as? InlineBotMessageAttribute, let peerId = attribute.peerId { - botPeer = message.peers[peerId] + botPeer = message.enginePeers[peerId] found = true } } if !found { botPeer = message.author } - - var peer: Peer? + + var peer: EnginePeer? if samePeer { - peer = message.peers[message.id.peerId] + peer = message.enginePeers[message.id.peerId] } else { peer = botPeer } if let peer = peer, let botPeer = botPeer, let addressName = botPeer.addressName { - self.controllerInteraction.openPeer(EnginePeer(peer), .chat(textInputState: ChatTextInputState(inputText: NSAttributedString(string: "@\(addressName) \(query)")), subject: nil, peekData: nil), nil, .default) + self.controllerInteraction.openPeer(peer, .chat(textInputState: ChatTextInputState(inputText: NSAttributedString(string: "@\(addressName) \(query)")), subject: nil, peekData: nil), nil, .default) } } case .payment: @@ -452,7 +451,7 @@ public final class ChatButtonKeyboardInputNode: ChatInputNode, UIScrollViewDeleg for attribute in message.attributes { if let attribute = attribute as? ReplyMarkupMessageAttribute { if attribute.flags.contains(.once) { - self.controllerInteraction.dismissReplyMarkupMessage(message) + self.controllerInteraction.dismissReplyMarkupMessage(message._asMessage()) } break } diff --git a/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/BUILD b/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/BUILD index 0d53fbe7c2..9271748454 100644 --- a/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/BUILD +++ b/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/BUILD @@ -13,7 +13,6 @@ swift_library( "//submodules/AsyncDisplayKit", "//submodules/Display", "//submodules/TelegramCore", - "//submodules/Postbox", "//submodules/SSignalKit/SwiftSignalKit", "//submodules/TelegramPresentationData", "//submodules/AlertUI", diff --git a/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/Sources/ChatChannelSubscriberInputPanelNode.swift b/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/Sources/ChatChannelSubscriberInputPanelNode.swift index 053026ef6c..f2ed195c59 100644 --- a/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/Sources/ChatChannelSubscriberInputPanelNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/Sources/ChatChannelSubscriberInputPanelNode.swift @@ -3,7 +3,6 @@ import UIKit import AsyncDisplayKit import Display import TelegramCore -import Postbox import SwiftSignalKit import TelegramPresentationData import AlertUI @@ -63,7 +62,7 @@ private func titleAndColorForAction(_ action: SubscriberAction, theme: Presentat } } -private func actionForPeer(context: AccountContext, peer: Peer, interfaceState: ChatPresentationInterfaceState, isJoining: Bool, isMuted: Bool) -> SubscriberAction? { +private func actionForPeer(context: AccountContext, peer: EnginePeer, interfaceState: ChatPresentationInterfaceState, isJoining: Bool, isMuted: Bool) -> SubscriberAction? { if case let .replyThread(message) = interfaceState.chatLocation, message.peerId == context.account.peerId { if let peer = interfaceState.savedMessagesTopicPeer { if case let .channel(channel) = peer { @@ -79,9 +78,9 @@ private func actionForPeer(context: AccountContext, peer: Peer, interfaceState: return .openChat } else if case .pinnedMessages = interfaceState.subject { var canManagePin = false - if let channel = peer as? TelegramChannel { + if case let .channel(channel) = peer { canManagePin = channel.hasPermission(.pinMessages) - } else if let group = peer as? TelegramGroup { + } else if case let .legacyGroup(group) = peer { switch group.role { case .creator, .admin: canManagePin = true @@ -92,7 +91,7 @@ private func actionForPeer(context: AccountContext, peer: Peer, interfaceState: canManagePin = true } } - } else if let _ = peer as? TelegramUser, interfaceState.explicitelyCanPinMessages { + } else if case .user = peer, interfaceState.explicitelyCanPinMessages { canManagePin = true } if canManagePin { @@ -101,7 +100,7 @@ private func actionForPeer(context: AccountContext, peer: Peer, interfaceState: return .hidePinnedMessages } } else { - if let channel = peer as? TelegramChannel { + if case let .channel(channel) = peer { if case .broadcast = channel.info, isJoining { if isMuted { return .unmuteNotifications @@ -401,7 +400,7 @@ public final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode { self.presentationInterfaceState = interfaceState var centerAction: (title: String, isAccent: Bool)? - if let context = self.context, let peer = interfaceState.renderedPeer?.peer, let action = actionForPeer(context: context, peer: peer, interfaceState: interfaceState, isJoining: self.isJoining, isMuted: interfaceState.peerIsMuted) { + if let context = self.context, let peer = interfaceState.renderedPeer?.peer, let action = actionForPeer(context: context, peer: EnginePeer(peer), interfaceState: interfaceState, isJoining: self.isJoining, isMuted: interfaceState.peerIsMuted) { self.action = action let (title, _) = titleAndColorForAction(action, theme: interfaceState.theme, strings: interfaceState.strings) diff --git a/submodules/TelegramUI/Components/Chat/ChatEmptyNode/BUILD b/submodules/TelegramUI/Components/Chat/ChatEmptyNode/BUILD index 0d443277ba..e07177bd3a 100644 --- a/submodules/TelegramUI/Components/Chat/ChatEmptyNode/BUILD +++ b/submodules/TelegramUI/Components/Chat/ChatEmptyNode/BUILD @@ -13,7 +13,6 @@ swift_library( "//submodules/AsyncDisplayKit", "//submodules/Display", "//submodules/SSignalKit/SwiftSignalKit", - "//submodules/Postbox", "//submodules/TelegramCore", "//submodules/TelegramPresentationData", "//submodules/AppBundle", diff --git a/submodules/TelegramUI/Components/Chat/ChatEmptyNode/Sources/ChatEmptyNode.swift b/submodules/TelegramUI/Components/Chat/ChatEmptyNode/Sources/ChatEmptyNode.swift index 79f11f91bb..669604b158 100644 --- a/submodules/TelegramUI/Components/Chat/ChatEmptyNode/Sources/ChatEmptyNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatEmptyNode/Sources/ChatEmptyNode.swift @@ -3,7 +3,6 @@ import UIKit import AsyncDisplayKit import Display import SwiftSignalKit -import Postbox import TelegramCore import TelegramPresentationData import AppBundle @@ -252,10 +251,10 @@ public final class ChatEmptyNodeGreetingChatContent: ASDisplayNode, ChatEmptyNod ) inputNodeInteraction.displayStickerPlaceholder = false - let index = ItemCollectionItemIndex(index: 0, id: 0) - let collectionId = ItemCollectionId(namespace: 0, id: 0) + let index = EngineItemCollectionItemIndex(index: 0, id: 0) + let collectionId = EngineItemCollectionId(namespace: 0, id: 0) let stickerPackItem = StickerPackItem(index: index, file: sticker, indexKeys: []) - let item = ChatMediaInputStickerGridItem(context: strongSelf.context, collectionId: collectionId, stickerPackInfo: nil, index: ItemCollectionViewEntryIndex(collectionIndex: 0, collectionId: collectionId, itemIndex: index), stickerItem: stickerPackItem, canManagePeerSpecificPack: nil, interfaceInteraction: nil, inputNodeInteraction: inputNodeInteraction, hasAccessory: false, theme: interfaceState.theme, large: true, selected: {}) + let item = ChatMediaInputStickerGridItem(context: strongSelf.context, collectionId: collectionId, stickerPackInfo: nil, index: EngineItemCollectionViewEntryIndex(collectionIndex: 0, collectionId: collectionId, itemIndex: index), stickerItem: stickerPackItem, canManagePeerSpecificPack: nil, interfaceInteraction: nil, inputNodeInteraction: inputNodeInteraction, hasAccessory: false, theme: interfaceState.theme, large: true, selected: {}) strongSelf.stickerItem = item if isFirstTime { diff --git a/submodules/TelegramUI/Components/Chat/ChatHistorySearchContainerNode/Sources/ChatHistorySearchContainerNode.swift b/submodules/TelegramUI/Components/Chat/ChatHistorySearchContainerNode/Sources/ChatHistorySearchContainerNode.swift index c87f824712..8e857273f7 100644 --- a/submodules/TelegramUI/Components/Chat/ChatHistorySearchContainerNode/Sources/ChatHistorySearchContainerNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatHistorySearchContainerNode/Sources/ChatHistorySearchContainerNode.swift @@ -353,13 +353,13 @@ public final class ChatHistorySearchContainerNode: SearchDisplayControllerConten } } - public func messageForGallery(_ id: MessageId) -> Message? { + public func messageForGallery(_ id: EngineMessage.Id) -> EngineMessage? { if let currentEntries = self.currentEntries { for entry in currentEntries { switch entry { case let .message(message, _, _, _, _): if message.id == id { - return message + return EngineMessage(message) } } } diff --git a/submodules/TelegramUI/Components/Chat/ChatLoadingNode/Sources/ChatLoadingNode.swift b/submodules/TelegramUI/Components/Chat/ChatLoadingNode/Sources/ChatLoadingNode.swift index bb9e9d0bd8..ecf7d27939 100644 --- a/submodules/TelegramUI/Components/Chat/ChatLoadingNode/Sources/ChatLoadingNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatLoadingNode/Sources/ChatLoadingNode.swift @@ -3,7 +3,6 @@ import UIKit import AsyncDisplayKit import SwiftSignalKit import Display -import Postbox import TelegramCore import TelegramPresentationData import ActivityIndicator @@ -421,16 +420,16 @@ public final class ChatLoadingPlaceholderNode: ASDisplayNode { case channel } private var chatType: ChatType = .channel - public func updatePresentationInterfaceState(renderedPeer: RenderedPeer?, chatLocation: ChatLocation) { + public func updatePresentationInterfaceState(renderedPeer: EngineRenderedPeer?, chatLocation: ChatLocation) { var chatType: ChatType = .channel if let peer = renderedPeer?.peer { - if peer is TelegramUser { + if case .user = peer { chatType = .user - } else if peer is TelegramGroup { + } else if case .legacyGroup = peer { chatType = .group - } else if let channel = peer as? TelegramChannel { + } else if case let .channel(channel) = peer { if channel.isMonoForum { - if let mainChannel = renderedPeer?.chatOrMonoforumMainPeer as? TelegramChannel, mainChannel.hasPermission(.manageDirect) { + if case let .channel(mainChannel) = renderedPeer?.chatOrMonoforumMainPeer, mainChannel.hasPermission(.manageDirect) { if chatLocation.threadId == nil { chatType = .group } else { diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageActionButtonsNode/BUILD b/submodules/TelegramUI/Components/Chat/ChatMessageActionButtonsNode/BUILD index 6256450503..f840e72c38 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageActionButtonsNode/BUILD +++ b/submodules/TelegramUI/Components/Chat/ChatMessageActionButtonsNode/BUILD @@ -13,7 +13,6 @@ swift_library( "//submodules/SSignalKit/SwiftSignalKit", "//submodules/AsyncDisplayKit", "//submodules/TelegramCore", - "//submodules/Postbox", "//submodules/Display", "//submodules/TelegramPresentationData", "//submodules/AccountContext", diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageActionButtonsNode/Sources/ChatMessageActionButtonsNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageActionButtonsNode/Sources/ChatMessageActionButtonsNode.swift index 4ee6c88de2..21e0c26601 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageActionButtonsNode/Sources/ChatMessageActionButtonsNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageActionButtonsNode/Sources/ChatMessageActionButtonsNode.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import AsyncDisplayKit import TelegramCore -import Postbox import Display import TelegramPresentationData import AccountContext @@ -221,7 +220,7 @@ private final class ChatMessageActionButtonNode: ASDisplayNode { } } - class func asyncLayout(_ maybeNode: ChatMessageActionButtonNode?) -> (_ context: AccountContext, _ theme: ChatPresentationThemeData, _ bubbleCorners: PresentationChatBubbleCorners, _ strings: PresentationStrings, _ backgroundNode: WallpaperBackgroundNode?, _ message: Message, _ button: ReplyMarkupButton, _ customInfo: ChatMessageActionButtonsNode.CustomInfo?, _ constrainedWidth: CGFloat, _ position: MessageBubbleActionButtonPosition) -> (minimumWidth: CGFloat, layout: ((CGFloat) -> (CGSize, (ListViewItemUpdateAnimation) -> ChatMessageActionButtonNode))) { + class func asyncLayout(_ maybeNode: ChatMessageActionButtonNode?) -> (_ context: AccountContext, _ theme: ChatPresentationThemeData, _ bubbleCorners: PresentationChatBubbleCorners, _ strings: PresentationStrings, _ backgroundNode: WallpaperBackgroundNode?, _ message: EngineMessage, _ button: ReplyMarkupButton, _ customInfo: ChatMessageActionButtonsNode.CustomInfo?, _ constrainedWidth: CGFloat, _ position: MessageBubbleActionButtonPosition) -> (minimumWidth: CGFloat, layout: ((CGFloat) -> (CGSize, (ListViewItemUpdateAnimation) -> ChatMessageActionButtonNode))) { let titleLayout = TextNode.asyncLayout(maybeNode?.titleNode) return { context, theme, bubbleCorners, strings, backgroundNode, message, button, customInfo, constrainedWidth, position in @@ -543,7 +542,7 @@ private final class ChatMessageActionButtonNode: ASDisplayNode { } var animationContent: EmojiStatusComponent.AnimationContent = .customEmoji(fileId: iconFileId) - if let file = message.associatedMedia[MediaId(namespace: Namespaces.Media.CloudFile, id: iconFileId)] as? TelegramMediaFile { + if let file = message.associatedMedia[EngineMedia.Id(namespace: Namespaces.Media.CloudFile, id: iconFileId)] as? TelegramMediaFile { animationContent = .file(file: file) } @@ -661,7 +660,7 @@ public final class ChatMessageActionButtonsNode: ASDisplayNode { } } - public class func asyncLayout(_ maybeNode: ChatMessageActionButtonsNode?) -> (_ context: AccountContext, _ theme: ChatPresentationThemeData, _ chatBubbleCorners: PresentationChatBubbleCorners, _ strings: PresentationStrings, _ backgroundNode: WallpaperBackgroundNode?, _ replyMarkup: ReplyMarkupMessageAttribute, _ customInfos: [MemoryBuffer: CustomInfo], _ message: Message, _ constrainedWidth: CGFloat) -> (minWidth: CGFloat, layout: (CGFloat) -> (CGSize, (_ animation: ListViewItemUpdateAnimation) -> ChatMessageActionButtonsNode)) { + public class func asyncLayout(_ maybeNode: ChatMessageActionButtonsNode?) -> (_ context: AccountContext, _ theme: ChatPresentationThemeData, _ chatBubbleCorners: PresentationChatBubbleCorners, _ strings: PresentationStrings, _ backgroundNode: WallpaperBackgroundNode?, _ replyMarkup: ReplyMarkupMessageAttribute, _ customInfos: [EngineMemoryBuffer: CustomInfo], _ message: EngineMessage, _ constrainedWidth: CGFloat) -> (minWidth: CGFloat, layout: (CGFloat) -> (CGSize, (_ animation: ListViewItemUpdateAnimation) -> ChatMessageActionButtonsNode)) { let currentButtonLayouts = maybeNode?.buttonNodes.map { ChatMessageActionButtonNode.asyncLayout($0) } ?? [] return { context, theme, chatBubbleCorners, strings, backgroundNode, replyMarkup, customInfos, message, constrainedWidth in diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode/Sources/ChatMessageAnimatedStickerItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode/Sources/ChatMessageAnimatedStickerItemNode.swift index 45786ac58b..e9fd395a8e 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode/Sources/ChatMessageAnimatedStickerItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode/Sources/ChatMessageAnimatedStickerItemNode.swift @@ -505,7 +505,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { var emojiFile: TelegramMediaFile? var emojiString: String? - if messageIsEligibleForLargeCustomEmoji(item.message) || messageIsEligibleForLargeEmoji(item.message) { + if messageIsEligibleForLargeCustomEmoji(EngineMessage(item.message)) || messageIsEligibleForLargeEmoji(EngineMessage(item.message)) { emojiString = item.message.text } @@ -1152,7 +1152,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { tonAmount = stakeTonAmount } - let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: item.message, dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: .regular, associatedData: item.associatedData) + let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: EngineMessage(item.message), dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: .regular, associatedData: item.associatedData) var isReplyThread = false if case .replyThread = item.chatLocation { @@ -1168,7 +1168,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { impressionCount: viewCount, dateText: dateText, type: statusType, - layoutInput: .standalone(reactionSettings: shouldDisplayInlineDateReactions(message: item.message, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.StandaloneReactionSettings() : nil), + layoutInput: .standalone(reactionSettings: shouldDisplayInlineDateReactions(message: EngineMessage(item.message), isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.StandaloneReactionSettings() : nil), constrainedSize: CGSize(width: params.width, height: CGFloat.greatestFiniteMagnitude), availableReactions: item.associatedData.availableReactions, savedMessageTags: item.associatedData.savedMessageTags, @@ -1183,7 +1183,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { tonAmount: tonAmount, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.message), + canViewReactionList: canViewMessageReactionList(message: EngineMessage(item.message)), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) @@ -1352,7 +1352,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { } } let availableWidth = max(60.0, availableContentWidth + 6.0) - forwardInfoSizeApply = makeForwardInfoLayout(item.context, item.presentationData, item.presentationData.strings, .standalone, forwardSource, forwardAuthorSignature, forwardPsaType, nil, CGSize(width: availableWidth, height: CGFloat.greatestFiniteMagnitude)) + forwardInfoSizeApply = makeForwardInfoLayout(item.context, item.presentationData, item.presentationData.strings, .standalone, forwardSource.flatMap(EnginePeer.init), forwardAuthorSignature, forwardPsaType, nil, CGSize(width: availableWidth, height: CGFloat.greatestFiniteMagnitude)) } var needsReplyBackground = false @@ -1370,7 +1370,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { var maxContentWidth = imageSize.width var actionButtonsFinalize: ((CGFloat) -> (CGSize, (_ animation: ListViewItemUpdateAnimation) -> ChatMessageActionButtonsNode))? if let replyMarkup = replyMarkup { - let (minWidth, buttonsLayout) = actionButtonsLayout(item.context, item.presentationData.theme, item.presentationData.chatBubbleCorners, item.presentationData.strings, item.controllerInteraction.presentationContext.backgroundNode, replyMarkup, [:], item.message, baseWidth) + let (minWidth, buttonsLayout) = actionButtonsLayout(item.context, item.presentationData.theme, item.presentationData.chatBubbleCorners, item.presentationData.strings, item.controllerInteraction.presentationContext.backgroundNode, replyMarkup, [:], EngineMessage(item.message), baseWidth) maxContentWidth = max(maxContentWidth, minWidth) actionButtonsFinalize = buttonsLayout } else if incoming, let attribute = item.message.attributes.first(where: { $0 is SuggestedPostMessageAttribute }) as? SuggestedPostMessageAttribute, attribute.state == nil { @@ -1419,7 +1419,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { ], flags: [], placeholder: nil - ), customInfos, item.message, baseWidth) + ), customInfos, EngineMessage(item.message), baseWidth) maxContentWidth = max(maxContentWidth, minWidth) actionButtonsFinalize = buttonsLayout } @@ -1430,7 +1430,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { } let reactions: ReactionsMessageAttribute - if shouldDisplayInlineDateReactions(message: item.message, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) { + if shouldDisplayInlineDateReactions(message: EngineMessage(item.message), isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) { reactions = ReactionsMessageAttribute(canViewList: false, isTags: false, reactions: [], recentPeers: [], topPeers: []) } else { reactions = mergedMessageReactions(attributes: item.message.attributes, isTags: item.message.areReactionsTags(accountPeerId: item.context.account.peerId)) ?? ReactionsMessageAttribute(canViewList: false, isTags: false, reactions: [], recentPeers: [], topPeers: []) @@ -1447,7 +1447,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { availableReactions: item.associatedData.availableReactions, savedMessageTags: item.associatedData.savedMessageTags, reactions: reactions, - message: item.message, + message: EngineMessage(item.message), associatedData: item.associatedData, accountPeer: item.associatedData.accountPeer, isIncoming: item.message.effectivelyIncoming(item.context.account.peerId), @@ -1712,7 +1712,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { strongSelf?.openQuickShare(node: node, gesture: gesture) } } - let buttonSize = updatedShareButtonNode.update(presentationData: item.presentationData, controllerInteraction: item.controllerInteraction, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: item.message, account: item.context.account) + let buttonSize = updatedShareButtonNode.update(presentationData: item.presentationData, controllerInteraction: item.controllerInteraction, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: EngineMessage(item.message), accountPeerId: item.context.account.peerId) animation.animator.updateFrame(layer: updatedShareButtonNode.layer, frame: CGRect(origin: CGPoint(x: !incoming ? updatedImageFrame.minX - buttonSize.width - 6.0 : updatedImageFrame.maxX + 8.0, y: updatedImageFrame.maxY - buttonSize.height - 4.0 + imageBottomPadding), size: buttonSize), completion: nil) } else if let shareButtonNode = strongSelf.shareButtonNode { shareButtonNode.removeFromSupernode() @@ -2076,7 +2076,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { case let .optionalAction(f): f() case let .openContextMenu(openContextMenu): - if canAddMessageReactions(message: item.message) { + if canAddMessageReactions(message: EngineMessage(item.message)) { item.controllerInteraction.updateMessageReaction(item.message, .default, false, nil) } else { item.controllerInteraction.openMessageContextMenu(openContextMenu.tapMessage, openContextMenu.selectAll, self, openContextMenu.subFrame, nil, nil) @@ -2085,7 +2085,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { } else if case .tap = gesture { item.controllerInteraction.clickThroughMessage(self.view, location) } else if case .doubleTap = gesture { - if canAddMessageReactions(message: item.message) { + if canAddMessageReactions(message: EngineMessage(item.message)) { item.controllerInteraction.updateMessageReaction(item.message, .default, false, nil) } } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageAttachedContentNode/Sources/ChatMessageAttachedContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageAttachedContentNode/Sources/ChatMessageAttachedContentNode.swift index 80cc53511c..4242a1cc39 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageAttachedContentNode/Sources/ChatMessageAttachedContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageAttachedContentNode/Sources/ChatMessageAttachedContentNode.swift @@ -714,7 +714,7 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode { } else { dateFormat = .regular } - let dateText = stringForMessageTimestampStatus(accountPeerId: context.account.peerId, message: message, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, strings: presentationData.strings, format: dateFormat, associatedData: associatedData) + let dateText = stringForMessageTimestampStatus(accountPeerId: context.account.peerId, message: EngineMessage(message), dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, strings: presentationData.strings, format: dateFormat, associatedData: associatedData) let statusType: ChatMessageDateAndStatusType if incoming { @@ -753,7 +753,7 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode { type: statusType, layoutInput: .trailingContent( contentWidth: trailingContentWidth, - reactionSettings: ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: shouldDisplayInlineDateReactions(message: message, isPremium: associatedData.isPremium, forceInline: associatedData.forceInlineReactions), preferAdditionalInset: false) + reactionSettings: ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: shouldDisplayInlineDateReactions(message: EngineMessage(message), isPremium: associatedData.isPremium, forceInline: associatedData.forceInlineReactions), preferAdditionalInset: false) ), constrainedSize: CGSize(width: maxStatusContentWidth, height: CGFloat.greatestFiniteMagnitude), availableReactions: associatedData.availableReactions, @@ -768,7 +768,7 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode { starsCount: starsCount, isPinned: message.tags.contains(.pinned) && !associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: message), + canViewReactionList: canViewMessageReactionList(message: EngineMessage(message)), animationCache: controllerInteraction.presentationContext.animationCache, animationRenderer: controllerInteraction.presentationContext.animationRenderer )) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift index 4a117bf8a0..31131d774c 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift @@ -258,7 +258,7 @@ private func contentNodeMessagesAndClassesForItem(_ item: ChatMessageItem) -> ([ } else if case .copyProtectionRequest = action.action { result.append((message, ChatMessageDisableCopyProtectionBubbleContentNode.self, itemAttributes, BubbleItemAttributes(isAttachment: false, neighborType: .text, neighborSpacing: .default))) } else { - if !canAddMessageReactions(message: message) { + if !canAddMessageReactions(message: EngineMessage(message)) { needReactions = false } result.append((message, ChatMessageActionBubbleContentNode.self, itemAttributes, BubbleItemAttributes(isAttachment: false, neighborType: .text, neighborSpacing: .default))) @@ -451,7 +451,7 @@ private func contentNodeMessagesAndClassesForItem(_ item: ChatMessageItem) -> ([ let firstMessage = item.content.firstMessage let reactionsAreInline: Bool - reactionsAreInline = shouldDisplayInlineDateReactions(message: firstMessage, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) + reactionsAreInline = shouldDisplayInlineDateReactions(message: EngineMessage(firstMessage), isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) if reactionsAreInline { needReactions = false } @@ -1566,9 +1566,9 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI rankBadgeLayout: (TextNodeLayoutArguments) -> (TextNodeLayout, () -> TextNode), boostBadgeLayout: (TextNodeLayoutArguments) -> (TextNodeLayout, () -> TextNode), threadInfoLayout: (ChatMessageThreadInfoNode.Arguments) -> (CGSize, (Bool) -> ChatMessageThreadInfoNode), - forwardInfoLayout: (AccountContext, ChatPresentationData, PresentationStrings, ChatMessageForwardInfoType, Peer?, String?, String?, ChatMessageForwardInfoNode.StoryData?, CGSize) -> (CGSize, (CGFloat) -> ChatMessageForwardInfoNode), + forwardInfoLayout: (AccountContext, ChatPresentationData, PresentationStrings, ChatMessageForwardInfoType, EnginePeer?, String?, String?, ChatMessageForwardInfoNode.StoryData?, CGSize) -> (CGSize, (CGFloat) -> ChatMessageForwardInfoNode), replyInfoLayout: (ChatMessageReplyInfoNode.Arguments) -> (CGSize, (CGSize, Bool, ListViewItemUpdateAnimation) -> ChatMessageReplyInfoNode), - actionButtonsLayout: (AccountContext, ChatPresentationThemeData, PresentationChatBubbleCorners, PresentationStrings, WallpaperBackgroundNode?, ReplyMarkupMessageAttribute, [MemoryBuffer: ChatMessageActionButtonsNode.CustomInfo], Message, CGFloat) -> (minWidth: CGFloat, layout: (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation) -> ChatMessageActionButtonsNode)), + actionButtonsLayout: (AccountContext, ChatPresentationThemeData, PresentationChatBubbleCorners, PresentationStrings, WallpaperBackgroundNode?, ReplyMarkupMessageAttribute, [EngineMemoryBuffer: ChatMessageActionButtonsNode.CustomInfo], EngineMessage, CGFloat) -> (minWidth: CGFloat, layout: (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation) -> ChatMessageActionButtonsNode)), reactionButtonsLayout: (ChatMessageReactionButtonsNode.Arguments) -> (minWidth: CGFloat, layout: (CGFloat) -> (size: CGSize, apply: (ListViewItemUpdateAnimation) -> ChatMessageReactionButtonsNode)), unlockButtonLayout: (ChatMessageUnlockMediaNode.Arguments) -> (CGSize, (Bool) -> ChatMessageUnlockMediaNode), mediaInfoLayout: (ChatMessageStarsMediaInfoNode.Arguments) -> (CGSize, (Bool) -> ChatMessageStarsMediaInfoNode), @@ -2531,7 +2531,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI } else { dateFormat = .regular } - let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: message, dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) + let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: EngineMessage(message), dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) let statusType: ChatMessageDateAndStatusType if incoming { @@ -2558,7 +2558,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI impressionCount: !item.presentationData.isPreview ? viewCount : nil, dateText: dateText, type: statusType, - layoutInput: .standalone(reactionSettings: shouldDisplayInlineDateReactions(message: item.message, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.StandaloneReactionSettings() : nil), + layoutInput: .standalone(reactionSettings: shouldDisplayInlineDateReactions(message: EngineMessage(item.message), isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.StandaloneReactionSettings() : nil), constrainedSize: CGSize(width: 200.0, height: CGFloat.greatestFiniteMagnitude), availableReactions: item.associatedData.availableReactions, savedMessageTags: item.associatedData.savedMessageTags, @@ -2572,7 +2572,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI starsCount: starsCount, isPinned: message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: message), + canViewReactionList: canViewMessageReactionList(message: EngineMessage(message)), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) @@ -2801,7 +2801,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI forwardAuthorSignature = forwardInfo.authorSignature } } - let sizeAndApply = forwardInfoLayout(item.context, item.presentationData, item.presentationData.strings, .bubble(incoming: incoming), forwardSource, forwardAuthorSignature, forwardPsaType, nil, CGSize(width: maximumNodeWidth - layoutConstants.text.bubbleInsets.left - layoutConstants.text.bubbleInsets.right, height: CGFloat.greatestFiniteMagnitude)) + let sizeAndApply = forwardInfoLayout(item.context, item.presentationData, item.presentationData.strings, .bubble(incoming: incoming), forwardSource.flatMap(EnginePeer.init), forwardAuthorSignature, forwardPsaType, nil, CGSize(width: maximumNodeWidth - layoutConstants.text.bubbleInsets.left - layoutConstants.text.bubbleInsets.right, height: CGFloat.greatestFiniteMagnitude)) forwardInfoSizeApply = (sizeAndApply.0, { width in sizeAndApply.1(width) }) headerSize.height += 2.0 @@ -2829,7 +2829,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI } } - let sizeAndApply = forwardInfoLayout(item.context, item.presentationData, item.presentationData.strings, .bubble(incoming: incoming), forwardSource, nil, nil, ChatMessageForwardInfoNode.StoryData(storyType: storyType), CGSize(width: maximumNodeWidth - layoutConstants.text.bubbleInsets.left - layoutConstants.text.bubbleInsets.right, height: CGFloat.greatestFiniteMagnitude)) + let sizeAndApply = forwardInfoLayout(item.context, item.presentationData, item.presentationData.strings, .bubble(incoming: incoming), forwardSource.flatMap(EnginePeer.init), nil, nil, ChatMessageForwardInfoNode.StoryData(storyType: storyType), CGSize(width: maximumNodeWidth - layoutConstants.text.bubbleInsets.left - layoutConstants.text.bubbleInsets.right, height: CGFloat.greatestFiniteMagnitude)) forwardInfoSizeApply = (sizeAndApply.0, { width in sizeAndApply.1(width) }) if storyType != .regular { @@ -2968,7 +2968,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI ], flags: [], placeholder: nil - ), [:], item.message, maximumNodeWidth) + ), [:], EngineMessage(item.message), maximumNodeWidth) maxContentWidth = max(maxContentWidth, minWidth) actionButtonsFinalize = buttonsLayout @@ -3013,7 +3013,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI ], flags: [], placeholder: nil - ), customInfos, item.message, baseWidth) + ), customInfos, EngineMessage(item.message), baseWidth) maxContentWidth = max(maxContentWidth, minWidth) actionButtonsFinalize = buttonsLayout @@ -3054,7 +3054,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI ], flags: [], placeholder: nil - ), customInfos, item.message, baseWidth) + ), customInfos, EngineMessage(item.message), baseWidth) maxContentWidth = max(maxContentWidth, minWidth) actionButtonsFinalize = buttonsLayout @@ -3106,13 +3106,13 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI ], flags: [], placeholder: nil - ), customInfos, item.message, baseWidth) + ), customInfos, EngineMessage(item.message), baseWidth) maxContentWidth = max(maxContentWidth, minWidth) actionButtonsFinalize = buttonsLayout lastNodeTopPosition = .None(.Both) } else if let replyMarkup = replyMarkup, !item.presentationData.isPreview { - let (minWidth, buttonsLayout) = actionButtonsLayout(item.context, item.presentationData.theme, item.presentationData.chatBubbleCorners, item.presentationData.strings, item.controllerInteraction.presentationContext.backgroundNode, replyMarkup, [:], item.message, maximumNodeWidth) + let (minWidth, buttonsLayout) = actionButtonsLayout(item.context, item.presentationData.theme, item.presentationData.chatBubbleCorners, item.presentationData.strings, item.controllerInteraction.presentationContext.backgroundNode, replyMarkup, [:], EngineMessage(item.message), maximumNodeWidth) maxContentWidth = max(maxContentWidth, minWidth) actionButtonsFinalize = buttonsLayout } else if item.content.firstMessageAttributes.displayContinueThreadFooter { @@ -3140,7 +3140,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI ], flags: [], placeholder: nil - ), customInfos, item.message, baseWidth) + ), customInfos, EngineMessage(item.message), baseWidth) maxContentWidth = max(maxContentWidth, minWidth) actionButtonsFinalize = buttonsLayout @@ -3177,7 +3177,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI availableReactions: item.associatedData.availableReactions, savedMessageTags: item.associatedData.savedMessageTags, reactions: bubbleReactions, - message: item.message, + message: EngineMessage(item.message), associatedData: item.associatedData, accountPeer: item.associatedData.accountPeer, isIncoming: incoming, @@ -3503,7 +3503,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI strings: item.presentationData.strings, context: item.context, controllerInteraction: item.controllerInteraction, - message: item.message, + message: EngineMessage(item.message), media: paidContent, constrainedSize: CGSize(width: maximumNodeWidth - layoutConstants.text.bubbleInsets.left - layoutConstants.text.bubbleInsets.right, height: CGFloat.greatestFiniteMagnitude), animationCache: item.controllerInteraction.presentationContext.animationCache, @@ -3514,7 +3514,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI let sizeAndApply = mediaInfoLayout(ChatMessageStarsMediaInfoNode.Arguments( presentationData: item.presentationData, context: item.context, - message: item.message, + message: EngineMessage(item.message), media: paidContent, constrainedSize: CGSize(width: maximumNodeWidth - layoutConstants.text.bubbleInsets.left - layoutConstants.text.bubbleInsets.right, height: CGFloat.greatestFiniteMagnitude), animationCache: item.controllerInteraction.presentationContext.animationCache, @@ -5254,7 +5254,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI strongSelf.messageAccessibilityArea.frame = backgroundFrame } if let summarizeButtonNode = strongSelf.summarizeButtonNode { - let buttonSize = summarizeButtonNode.update(presentationData: item.presentationData, controllerInteraction: item.controllerInteraction, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: item.message, account: item.context.account, disableComments: disablesComments, isSummarize: true) + let buttonSize = summarizeButtonNode.update(presentationData: item.presentationData, controllerInteraction: item.controllerInteraction, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: EngineMessage(item.message), accountPeerId: item.context.account.peerId, disableComments: disablesComments, isSummarize: true) var buttonFrame = CGRect(origin: CGPoint(x: !incoming ? backgroundFrame.minX - buttonSize.width - 8.0 : backgroundFrame.maxX + 8.0, y: backgroundFrame.minY + 1.0), size: buttonSize) @@ -5278,7 +5278,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI animation.animator.updateScale(layer: summarizeButtonNode.layer, scale: (isCurrentlyPlayingMedia || isSidePanelOpen) ? 0.001 : 1.0, completion: nil) } if let shareButtonNode = strongSelf.shareButtonNode { - let buttonSize = shareButtonNode.update(presentationData: item.presentationData, controllerInteraction: item.controllerInteraction, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: item.message, account: item.context.account, disableComments: disablesComments) + let buttonSize = shareButtonNode.update(presentationData: item.presentationData, controllerInteraction: item.controllerInteraction, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: EngineMessage(item.message), accountPeerId: item.context.account.peerId, disableComments: disablesComments) var buttonFrame = CGRect(origin: CGPoint(x: !incoming ? backgroundFrame.minX - buttonSize.width - 8.0 : backgroundFrame.maxX + 8.0, y: backgroundFrame.maxY - buttonSize.width - 1.0), size: buttonSize) @@ -5312,7 +5312,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI }*/ strongSelf.messageAccessibilityArea.frame = backgroundFrame if let summarizeButtonNode = strongSelf.summarizeButtonNode { - let buttonSize = summarizeButtonNode.update(presentationData: item.presentationData, controllerInteraction: item.controllerInteraction, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: item.message, account: item.context.account, disableComments: disablesComments, isSummarize: true) + let buttonSize = summarizeButtonNode.update(presentationData: item.presentationData, controllerInteraction: item.controllerInteraction, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: EngineMessage(item.message), accountPeerId: item.context.account.peerId, disableComments: disablesComments, isSummarize: true) var buttonFrame = CGRect(origin: CGPoint(x: !incoming ? backgroundFrame.minX - buttonSize.width - 8.0 : backgroundFrame.maxX + 8.0, y: backgroundFrame.minY + 1.0), size: buttonSize) @@ -5336,7 +5336,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI animation.animator.updateScale(layer: summarizeButtonNode.layer, scale: (isCurrentlyPlayingMedia || isSidePanelOpen) ? 0.001 : 1.0, completion: nil) } if let shareButtonNode = strongSelf.shareButtonNode { - let buttonSize = shareButtonNode.update(presentationData: item.presentationData, controllerInteraction: item.controllerInteraction, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: item.message, account: item.context.account, disableComments: disablesComments) + let buttonSize = shareButtonNode.update(presentationData: item.presentationData, controllerInteraction: item.controllerInteraction, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: EngineMessage(item.message), accountPeerId: item.context.account.peerId, disableComments: disablesComments) var buttonFrame = CGRect(origin: CGPoint(x: !incoming ? backgroundFrame.minX - buttonSize.width - 8.0 : backgroundFrame.maxX + 8.0, y: backgroundFrame.maxY - buttonSize.width - 1.0), size: buttonSize) @@ -5501,7 +5501,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI case let .optionalAction(f): f() case let .openContextMenu(openContextMenu): - if canAddMessageReactions(message: openContextMenu.tapMessage) { + if canAddMessageReactions(message: EngineMessage(openContextMenu.tapMessage)) { item.controllerInteraction.updateMessageReaction(openContextMenu.tapMessage, .default, false, nil) } else { item.controllerInteraction.openMessageContextMenu(openContextMenu.tapMessage, openContextMenu.selectAll, self, openContextMenu.subFrame, nil, nil) @@ -5510,7 +5510,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI } else if case .tap = gesture { item.controllerInteraction.clickThroughMessage(self.view, location) } else if case .doubleTap = gesture { - if canAddMessageReactions(message: item.message) { + if canAddMessageReactions(message: EngineMessage(item.message)) { item.controllerInteraction.updateMessageReaction(item.message, .default, false, nil) } } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageCallBubbleContentNode/BUILD b/submodules/TelegramUI/Components/Chat/ChatMessageCallBubbleContentNode/BUILD index 4f7d632f42..098ce23e19 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageCallBubbleContentNode/BUILD +++ b/submodules/TelegramUI/Components/Chat/ChatMessageCallBubbleContentNode/BUILD @@ -14,7 +14,6 @@ swift_library( "//submodules/AsyncDisplayKit", "//submodules/Display", "//submodules/TelegramCore", - "//submodules/Postbox", "//submodules/TelegramPresentationData", "//submodules/AppBundle", "//submodules/TelegramUI/Components/Chat/ChatMessageBubbleContentNode", diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageCallBubbleContentNode/Sources/ChatMessageCallBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageCallBubbleContentNode/Sources/ChatMessageCallBubbleContentNode.swift index 60cca730c9..d294658e77 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageCallBubbleContentNode/Sources/ChatMessageCallBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageCallBubbleContentNode/Sources/ChatMessageCallBubbleContentNode.swift @@ -3,7 +3,6 @@ import UIKit import AsyncDisplayKit import Display import TelegramCore -import Postbox import TelegramPresentationData import AppBundle import ChatMessageBubbleContentNode @@ -108,7 +107,7 @@ public class ChatMessageCallBubbleContentNode: ChatMessageBubbleContentNode { let messageTheme = incoming ? item.presentationData.theme.theme.chat.message.incoming : item.presentationData.theme.theme.chat.message.outgoing var peopleTextString: String? - var peopleAvatars: [Peer] = [] + var peopleAvatars: [EnginePeer] = [] var titleString: String? var callDuration: Int32? @@ -155,11 +154,11 @@ public class ChatMessageCallBubbleContentNode: ChatMessageBubbleContentNode { if conferenceCall.otherParticipants.count > 0 { peopleTextString = item.presentationData.strings.Chat_CallMessage_GroupCallParticipantCount(Int32(conferenceCall.otherParticipants.count + 1)) if let peer = item.message.author { - peopleAvatars.append(peer) + peopleAvatars.append(EnginePeer(peer)) } for id in conferenceCall.otherParticipants { if let peer = item.message.peers[id] { - peopleAvatars.append(peer) + peopleAvatars.append(EnginePeer(peer)) } } } @@ -239,7 +238,7 @@ public class ChatMessageCallBubbleContentNode: ChatMessageBubbleContentNode { } } - let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: item.message, dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, associatedData: item.associatedData) + let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: EngineMessage(item.message), dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, associatedData: item.associatedData) var statusText: String if let callDuration = callDuration, callDuration > 1 { @@ -319,7 +318,7 @@ public class ChatMessageCallBubbleContentNode: ChatMessageBubbleContentNode { strongSelf.addSubnode(peopleAvatarsNode) } - let peopleAvatarsContent = peopleAvatarsContext.update(peers: peopleAvatars.prefix(3).map(EnginePeer.init), animated: false) + let peopleAvatarsContent = peopleAvatarsContext.update(peers: Array(peopleAvatars.prefix(3)), animated: false) let peopleAvatarsSize = peopleAvatarsNode.update(context: item.context, content: peopleAvatarsContent, itemSize: CGSize(width: peopleAvatarSize, height: peopleAvatarSize), customSpacing: peopleAvatarSize - peopleAvatarSpacing, font: avatarFont, animated: false, synchronousLoad: false) peopleAvatarsNode.frame = CGRect(origin: CGPoint(x: labelFrame.maxX + avatarsLeftInset, y: labelFrame.minY - 1.0), size: peopleAvatarsSize) } else { diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageCommentFooterContentNode/Sources/ChatMessageCommentFooterContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageCommentFooterContentNode/Sources/ChatMessageCommentFooterContentNode.swift index 99d4e8c196..ed68fc8ae6 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageCommentFooterContentNode/Sources/ChatMessageCommentFooterContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageCommentFooterContentNode/Sources/ChatMessageCommentFooterContentNode.swift @@ -1,6 +1,5 @@ import Foundation import UIKit -import Postbox import Display import AsyncDisplayKit import SwiftSignalKit @@ -126,13 +125,13 @@ public final class ChatMessageCommentFooterContentNode: ChatMessageBubbleContent let horizontalInset = layoutConstants.text.bubbleInsets.left + layoutConstants.text.bubbleInsets.right var dateReplies = 0 - var replyPeers: [Peer] = [] + var replyPeers: [EnginePeer] = [] var hasUnseenReplies = false for attribute in item.message.attributes { if let attribute = attribute as? ReplyThreadMessageAttribute { dateReplies = Int(attribute.count) - replyPeers = attribute.latestUsers.compactMap { peerId -> Peer? in - return item.message.peers[peerId] + replyPeers = attribute.latestUsers.compactMap { peerId -> EnginePeer? in + return item.message.peers[peerId].flatMap(EnginePeer.init) } if let maxMessageId = attribute.maxMessageId, let maxReadMessageId = attribute.maxReadMessageId { hasUnseenReplies = maxMessageId > maxReadMessageId @@ -358,7 +357,7 @@ public final class ChatMessageCommentFooterContentNode: ChatMessageBubbleContent } } - let avatarContent = strongSelf.avatarsContext.update(peers: replyPeers.map(EnginePeer.init), animated: animation.isAnimated) + let avatarContent = strongSelf.avatarsContext.update(peers: replyPeers, animated: animation.isAnimated) let avatarsSize = strongSelf.avatarsNode.update(context: item.context, content: avatarContent, animated: animation.isAnimated, synchronousLoad: synchronousLoad) let iconAlpha: CGFloat = avatarsSize.width.isZero ? 1.0 : 0.0 diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageContactBubbleContentNode/BUILD b/submodules/TelegramUI/Components/Chat/ChatMessageContactBubbleContentNode/BUILD index ce75d53b14..3f390d0119 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageContactBubbleContentNode/BUILD +++ b/submodules/TelegramUI/Components/Chat/ChatMessageContactBubbleContentNode/BUILD @@ -13,7 +13,6 @@ swift_library( "//submodules/AsyncDisplayKit", "//submodules/Display", "//submodules/SSignalKit/SwiftSignalKit", - "//submodules/Postbox", "//submodules/TelegramCore", "//submodules/TelegramPresentationData", "//submodules/AvatarNode", diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageContactBubbleContentNode/Sources/ChatMessageContactBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageContactBubbleContentNode/Sources/ChatMessageContactBubbleContentNode.swift index b668005ce7..b1a13bcd82 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageContactBubbleContentNode/Sources/ChatMessageContactBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageContactBubbleContentNode/Sources/ChatMessageContactBubbleContentNode.swift @@ -3,7 +3,6 @@ import UIKit import AsyncDisplayKit import Display import SwiftSignalKit -import Postbox import TelegramCore import TelegramPresentationData import AvatarNode @@ -112,9 +111,9 @@ public class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode { } - var contactPeer: Peer? + var contactPeer: EnginePeer? if let peerId = selectedContact?.peerId, let peer = item.message.peers[peerId] { - contactPeer = peer + contactPeer = EnginePeer(peer) } let nameColors: PeerNameColors.Colors? @@ -260,7 +259,7 @@ public class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode { } } - let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: item.message, dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, associatedData: item.associatedData) + let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: EngineMessage(item.message), dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, associatedData: item.associatedData) let statusType: ChatMessageDateAndStatusType? if case .customChatContents = item.associatedData.subject { @@ -301,7 +300,7 @@ public class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode { impressionCount: viewCount, dateText: dateText, type: statusType, - layoutInput: .trailingContent(contentWidth: 1000.0, reactionSettings: shouldDisplayInlineDateReactions(message: item.message, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: true, preferAdditionalInset: false) : nil), + layoutInput: .trailingContent(contentWidth: 1000.0, reactionSettings: shouldDisplayInlineDateReactions(message: EngineMessage(item.message), isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: true, preferAdditionalInset: false) : nil), constrainedSize: CGSize(width: constrainedSize.width - sideInsets, height: .greatestFiniteMagnitude), availableReactions: item.associatedData.availableReactions, savedMessageTags: item.associatedData.savedMessageTags, @@ -315,7 +314,7 @@ public class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode { starsCount: starsCount, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && isReplyThread, hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.topMessage), + canViewReactionList: canViewMessageReactionList(message: EngineMessage(item.topMessage)), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) @@ -484,7 +483,7 @@ public class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode { pattern = MessageInlineBlockBackgroundView.Pattern( context: item.context, fileId: backgroundEmojiId, - file: item.message.associatedMedia[MediaId( + file: item.message.associatedMedia[EngineMedia.Id( namespace: Namespaces.Media.CloudFile, id: backgroundEmojiId )] as? TelegramMediaFile diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/BUILD b/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/BUILD index 4bd08bf312..2dcdf04510 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/BUILD +++ b/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/BUILD @@ -11,7 +11,6 @@ swift_library( ], deps = [ "//submodules/AsyncDisplayKit", - "//submodules/Postbox", "//submodules/TelegramCore", "//submodules/Display", "//submodules/SSignalKit/SwiftSignalKit", diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/ChatMessageDateAndStatusNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/ChatMessageDateAndStatusNode.swift index d537ad2a1c..9d9387274a 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/ChatMessageDateAndStatusNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/ChatMessageDateAndStatusNode.swift @@ -1,7 +1,6 @@ import Foundation import UIKit import AsyncDisplayKit -import Postbox import TelegramCore import Display import SwiftSignalKit @@ -1471,6 +1470,6 @@ public class ChatMessageDateAndStatusNode: ASDisplayNode { } } -public func shouldDisplayInlineDateReactions(message: Message, isPremium: Bool, forceInline: Bool) -> Bool { +public func shouldDisplayInlineDateReactions(message: EngineMessage, isPremium: Bool, forceInline: Bool) -> Bool { return false } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/StringForMessageTimestampStatus.swift b/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/StringForMessageTimestampStatus.swift index eb5493531f..7e252d709c 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/StringForMessageTimestampStatus.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/StringForMessageTimestampStatus.swift @@ -1,5 +1,4 @@ import Foundation -import Postbox import TelegramCore import TelegramPresentationData import TelegramUIPreferences @@ -62,7 +61,7 @@ private func monthAtIndex(_ index: Int, strings: PresentationStrings) -> String } } -public func stringForMessageTimestampStatus(accountPeerId: PeerId, message: Message, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, strings: PresentationStrings, format: MessageTimestampStatusFormat = .regular, associatedData: ChatMessageItemAssociatedData, ignoreAuthor: Bool = false) -> String { +public func stringForMessageTimestampStatus(accountPeerId: EnginePeer.Id, message: EngineMessage, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, strings: PresentationStrings, format: MessageTimestampStatusFormat = .regular, associatedData: ChatMessageItemAssociatedData, ignoreAuthor: Bool = false) -> String { if let adAttribute = message.adAttribute { switch adAttribute.messageType { case .sponsored: @@ -155,11 +154,11 @@ public func stringForMessageTimestampStatus(accountPeerId: PeerId, message: Mess } var authorTitle: String? - if let author = message.author as? TelegramUser { + if let author = message.author, case .user = author { if let peer = message.peers[message.id.peerId] as? TelegramChannel, case .broadcast = peer.info { if let channel = message.peers[message.id.peerId] as? TelegramChannel, case let .broadcast(info) = channel.info, message.author?.id != channel.id, info.flags.contains(.messagesShouldHaveProfiles) { } else { - authorTitle = EnginePeer(author).displayTitle(strings: strings, displayOrder: nameDisplayOrder) + authorTitle = author.displayTitle(strings: strings, displayOrder: nameDisplayOrder) } } else if let forwardInfo = message.forwardInfo, forwardInfo.sourceMessageId?.peerId.namespace == Namespaces.Peer.CloudChannel { authorTitle = forwardInfo.authorSignature diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageFactCheckBubbleContentNode/Sources/ChatMessageFactCheckBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageFactCheckBubbleContentNode/Sources/ChatMessageFactCheckBubbleContentNode.swift index d706e501b1..6fa45a6da9 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageFactCheckBubbleContentNode/Sources/ChatMessageFactCheckBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageFactCheckBubbleContentNode/Sources/ChatMessageFactCheckBubbleContentNode.swift @@ -325,7 +325,7 @@ public class ChatMessageFactCheckBubbleContentNode: ChatMessageBubbleContentNode } else { dateFormat = .regular } - let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: item.message, dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) + let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: EngineMessage(item.message), dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) let statusType: ChatMessageDateAndStatusType? if case .customChatContents = item.associatedData.subject { @@ -440,7 +440,7 @@ public class ChatMessageFactCheckBubbleContentNode: ChatMessageBubbleContentNode impressionCount: !item.presentationData.isPreview ? viewCount : nil, dateText: dateText, type: statusType, - layoutInput: .trailingContent(contentWidth: nil, reactionSettings: item.presentationData.isPreview ? nil : ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: shouldDisplayInlineDateReactions(message: message, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions), preferAdditionalInset: false)), + layoutInput: .trailingContent(contentWidth: nil, reactionSettings: item.presentationData.isPreview ? nil : ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: shouldDisplayInlineDateReactions(message: EngineMessage(message), isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions), preferAdditionalInset: false)), constrainedSize: textConstrainedSize, availableReactions: item.associatedData.availableReactions, savedMessageTags: item.associatedData.savedMessageTags, @@ -454,7 +454,7 @@ public class ChatMessageFactCheckBubbleContentNode: ChatMessageBubbleContentNode starsCount: starsCount, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && isReplyThread, hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.topMessage), + canViewReactionList: canViewMessageReactionList(message: EngineMessage(item.topMessage)), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageForwardInfoNode/BUILD b/submodules/TelegramUI/Components/Chat/ChatMessageForwardInfoNode/BUILD index 9eb97d563e..5bedf2a16f 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageForwardInfoNode/BUILD +++ b/submodules/TelegramUI/Components/Chat/ChatMessageForwardInfoNode/BUILD @@ -11,7 +11,6 @@ swift_library( ], deps = [ "//submodules/AsyncDisplayKit", - "//submodules/Postbox", "//submodules/Display", "//submodules/TelegramCore", "//submodules/SSignalKit/SwiftSignalKit", diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageForwardInfoNode/Sources/ChatMessageForwardInfoNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageForwardInfoNode/Sources/ChatMessageForwardInfoNode.swift index 4afdb9e74d..d6070d30b8 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageForwardInfoNode/Sources/ChatMessageForwardInfoNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageForwardInfoNode/Sources/ChatMessageForwardInfoNode.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import AsyncDisplayKit import Display -import Postbox import TelegramCore import TelegramPresentationData import LocalizedPeerData @@ -91,7 +90,7 @@ public class ChatMessageForwardInfoNode: ASDisplayNode { private var linkProgressView: TextLoadingEffectView? private var linkProgressDisposable: Disposable? - private var previousPeer: Peer? + private var previousPeer: EnginePeer? public var openPsa: ((String, ASDisplayNode) -> Void)? @@ -279,7 +278,7 @@ public class ChatMessageForwardInfoNode: ASDisplayNode { } } - public static func asyncLayout(_ maybeNode: ChatMessageForwardInfoNode?) -> (_ context: AccountContext, _ presentationData: ChatPresentationData, _ strings: PresentationStrings, _ type: ChatMessageForwardInfoType, _ peer: Peer?, _ authorName: String?, _ psaType: String?, _ storyData: StoryData?, _ constrainedSize: CGSize) -> (CGSize, (CGFloat) -> ChatMessageForwardInfoNode) { + public static func asyncLayout(_ maybeNode: ChatMessageForwardInfoNode?) -> (_ context: AccountContext, _ presentationData: ChatPresentationData, _ strings: PresentationStrings, _ type: ChatMessageForwardInfoType, _ peer: EnginePeer?, _ authorName: String?, _ psaType: String?, _ storyData: StoryData?, _ constrainedSize: CGSize) -> (CGSize, (CGFloat) -> ChatMessageForwardInfoNode) { let titleNodeLayout = TextNode.asyncLayout(maybeNode?.titleNode) let nameNodeLayout = TextNode.asyncLayout(maybeNode?.nameNode) @@ -295,10 +294,10 @@ public class ChatMessageForwardInfoNode: ASDisplayNode { let peerString: String if let peer = peer { - if let authorName = authorName, originalPeer === peer { - peerString = "\(EnginePeer(peer).displayTitle(strings: strings, displayOrder: presentationData.nameDisplayOrder)) (\(authorName))" + if let authorName = authorName, originalPeer == peer { + peerString = "\(peer.displayTitle(strings: strings, displayOrder: presentationData.nameDisplayOrder)) (\(authorName))" } else { - peerString = EnginePeer(peer).displayTitle(strings: strings, displayOrder: presentationData.nameDisplayOrder) + peerString = peer.displayTitle(strings: strings, displayOrder: presentationData.nameDisplayOrder) } } else if let authorName = authorName { peerString = authorName @@ -409,7 +408,7 @@ public class ChatMessageForwardInfoNode: ASDisplayNode { var currentCredibilityIconImage: UIImage? var highlight = true if let peer = peer { - if let channel = peer as? TelegramChannel, channel.addressName == nil { + if case let .channel(channel) = peer, channel.addressName == nil { if case let .broadcast(info) = channel.info, info.flags.contains(.hasDiscussionGroup) { } else if case .member = channel.participationStatus { } else { @@ -539,9 +538,9 @@ public class ChatMessageForwardInfoNode: ASDisplayNode { avatarNode.updateSize(size: avatarSize) if let peer { if peer.smallProfileImage != nil { - avatarNode.setPeerV2(context: context, theme: presentationData.theme.theme, peer: EnginePeer(peer), displayDimensions: avatarSize) + avatarNode.setPeerV2(context: context, theme: presentationData.theme.theme, peer: peer, displayDimensions: avatarSize) } else { - avatarNode.setPeer(context: context, theme: presentationData.theme.theme, peer: EnginePeer(peer), displayDimensions: avatarSize) + avatarNode.setPeer(context: context, theme: presentationData.theme.theme, peer: peer, displayDimensions: avatarSize) } } else if let authorName, !authorName.isEmpty { avatarNode.setCustomLetters([String(authorName[authorName.startIndex])]) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageGiveawayBubbleContentNode/Sources/ChatMessageGiveawayBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageGiveawayBubbleContentNode/Sources/ChatMessageGiveawayBubbleContentNode.swift index b07a753691..c48d216161 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageGiveawayBubbleContentNode/Sources/ChatMessageGiveawayBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageGiveawayBubbleContentNode/Sources/ChatMessageGiveawayBubbleContentNode.swift @@ -533,7 +533,7 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode, } else { dateFormat = .regular } - let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: item.message, dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) + let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: EngineMessage(item.message), dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) let statusType: ChatMessageDateAndStatusType? switch position { @@ -567,7 +567,7 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode, impressionCount: !item.presentationData.isPreview ? viewCount : nil, dateText: dateText, type: statusType, - layoutInput: .trailingContent(contentWidth: 1000.0, reactionSettings: shouldDisplayInlineDateReactions(message: item.message, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: true, preferAdditionalInset: false) : nil), + layoutInput: .trailingContent(contentWidth: 1000.0, reactionSettings: shouldDisplayInlineDateReactions(message: EngineMessage(item.message), isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: true, preferAdditionalInset: false) : nil), constrainedSize: CGSize(width: constrainedSize.width - sideInsets, height: .greatestFiniteMagnitude), availableReactions: item.associatedData.availableReactions, savedMessageTags: item.associatedData.savedMessageTags, @@ -581,7 +581,7 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode, starsCount: nil, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && isReplyThread, hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.topMessage), + canViewReactionList: canViewMessageReactionList(message: EngineMessage(item.topMessage)), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageInstantVideoItemNode/Sources/ChatMessageInstantVideoItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageInstantVideoItemNode/Sources/ChatMessageInstantVideoItemNode.swift index e1a44d039f..2e3e9876cf 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageInstantVideoItemNode/Sources/ChatMessageInstantVideoItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInstantVideoItemNode/Sources/ChatMessageInstantVideoItemNode.swift @@ -578,7 +578,7 @@ public class ChatMessageInstantVideoItemNode: ChatMessageItemView, ASGestureReco } } let availableWidth = max(60.0, availableContentWidth - normalDisplaySize.width + 6.0) - forwardInfoSizeApply = makeForwardInfoLayout(item.context, item.presentationData, item.presentationData.strings, .standalone, forwardSource, forwardAuthorSignature, forwardPsaType, nil, CGSize(width: availableWidth, height: CGFloat.greatestFiniteMagnitude)) + forwardInfoSizeApply = makeForwardInfoLayout(item.context, item.presentationData, item.presentationData.strings, .standalone, forwardSource.flatMap(EnginePeer.init), forwardAuthorSignature, forwardPsaType, nil, CGSize(width: availableWidth, height: CGFloat.greatestFiniteMagnitude)) } if replyInfoApply != nil || viaBotApply != nil || forwardInfoSizeApply != nil { @@ -594,7 +594,7 @@ public class ChatMessageInstantVideoItemNode: ChatMessageItemView, ASGestureReco var maxContentWidth = normalDisplaySize.width var actionButtonsFinalize: ((CGFloat) -> (CGSize, (_ animation: ListViewItemUpdateAnimation) -> ChatMessageActionButtonsNode))? if let replyMarkup = replyMarkup { - let (minWidth, buttonsLayout) = actionButtonsLayout(item.context, item.presentationData.theme, item.presentationData.chatBubbleCorners, item.presentationData.strings, item.controllerInteraction.presentationContext.backgroundNode, replyMarkup, [:], item.message, maxContentWidth) + let (minWidth, buttonsLayout) = actionButtonsLayout(item.context, item.presentationData.theme, item.presentationData.chatBubbleCorners, item.presentationData.strings, item.controllerInteraction.presentationContext.backgroundNode, replyMarkup, [:], EngineMessage(item.message), maxContentWidth) maxContentWidth = max(maxContentWidth, minWidth) actionButtonsFinalize = buttonsLayout } @@ -605,7 +605,7 @@ public class ChatMessageInstantVideoItemNode: ChatMessageItemView, ASGestureReco } let reactions: ReactionsMessageAttribute - if shouldDisplayInlineDateReactions(message: item.message, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) { + if shouldDisplayInlineDateReactions(message: EngineMessage(item.message), isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) { reactions = ReactionsMessageAttribute(canViewList: false, isTags: false, reactions: [], recentPeers: [], topPeers: []) } else { reactions = mergedMessageReactions(attributes: item.message.attributes, isTags: item.message.areReactionsTags(accountPeerId: item.context.account.peerId)) ?? ReactionsMessageAttribute(canViewList: false, isTags: false, reactions: [], recentPeers: [], topPeers: []) @@ -623,7 +623,7 @@ public class ChatMessageInstantVideoItemNode: ChatMessageItemView, ASGestureReco availableReactions: item.associatedData.availableReactions, savedMessageTags: item.associatedData.savedMessageTags, reactions: reactions, - message: item.message, + message: EngineMessage(item.message), associatedData: item.associatedData, accountPeer: item.associatedData.accountPeer, isIncoming: item.message.effectivelyIncoming(item.context.account.peerId), @@ -706,7 +706,7 @@ public class ChatMessageInstantVideoItemNode: ChatMessageItemView, ASGestureReco strongSelf?.shareButtonPressed() } } - let buttonSize = updatedShareButtonNode.update(presentationData: item.presentationData, controllerInteraction: item.controllerInteraction, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: item.message, account: item.context.account) + let buttonSize = updatedShareButtonNode.update(presentationData: item.presentationData, controllerInteraction: item.controllerInteraction, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: EngineMessage(item.message), accountPeerId: item.context.account.peerId) updatedShareButtonNode.frame = CGRect(origin: CGPoint(x: min(params.width - buttonSize.width - 8.0, videoFrame.maxX - 7.0), y: videoFrame.maxY - 24.0 - buttonSize.height), size: buttonSize) } else if let shareButtonNode = strongSelf.shareButtonNode { shareButtonNode.removeFromSupernode() diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/Sources/ChatMessageInteractiveFileNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/Sources/ChatMessageInteractiveFileNode.swift index 318593351f..c94fad0851 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/Sources/ChatMessageInteractiveFileNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/Sources/ChatMessageInteractiveFileNode.swift @@ -360,7 +360,7 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode { let presentationData = context.sharedContext.currentPresentationData.with { $0 } let premiumConfiguration = PremiumConfiguration.with(appConfiguration: arguments.context.currentAppConfiguration.with { $0 }) - let transcriptionText = self.forcedAudioTranscriptionText ?? transcribedText(message: message) + let transcriptionText = self.forcedAudioTranscriptionText ?? transcribedText(message: EngineMessage(message)) if transcriptionText == nil && !arguments.associatedData.alwaysDisplayTranscribeButton.providedByGroupBoost { if premiumConfiguration.audioTransciptionTrialCount > 0 { if !arguments.associatedData.isPremium { @@ -402,7 +402,7 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode { if case .expanded = self.audioTranscriptionState { shouldExpandNow = true } else { - if let result = transcribedText(message: message) { + if let result = transcribedText(message: EngineMessage(message)) { shouldExpandNow = true if case let .success(_, isPending) = result { @@ -789,7 +789,7 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode { } } - let transcribedText = forcedAudioTranscriptionText ?? transcribedText(message: arguments.message) + let transcribedText = forcedAudioTranscriptionText ?? transcribedText(message: EngineMessage(arguments.message)) switch audioTranscriptionState { case .inProgress: @@ -931,9 +931,9 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode { } else { dateFormat = .regular } - let dateText = stringForMessageTimestampStatus(accountPeerId: arguments.context.account.peerId, message: arguments.message, dateTimeFormat: arguments.presentationData.dateTimeFormat, nameDisplayOrder: arguments.presentationData.nameDisplayOrder, strings: arguments.presentationData.strings, format: dateFormat, associatedData: arguments.associatedData) + let dateText = stringForMessageTimestampStatus(accountPeerId: arguments.context.account.peerId, message: EngineMessage(arguments.message), dateTimeFormat: arguments.presentationData.dateTimeFormat, nameDisplayOrder: arguments.presentationData.nameDisplayOrder, strings: arguments.presentationData.strings, format: dateFormat, associatedData: arguments.associatedData) - let displayReactionsInline = shouldDisplayInlineDateReactions(message: arguments.message, isPremium: arguments.associatedData.isPremium, forceInline: arguments.associatedData.forceInlineReactions) + let displayReactionsInline = shouldDisplayInlineDateReactions(message: EngineMessage(arguments.message), isPremium: arguments.associatedData.isPremium, forceInline: arguments.associatedData.forceInlineReactions) var reactionSettings: ChatMessageDateAndStatusNode.TrailingReactionSettings? if displayReactionsInline || arguments.displayReactions { @@ -968,7 +968,7 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode { starsCount: starsCount, isPinned: arguments.isPinned && !arguments.associatedData.isInPinnedListMode, hasAutoremove: arguments.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: arguments.topMessage), + canViewReactionList: canViewMessageReactionList(message: EngineMessage(arguments.topMessage)), animationCache: arguments.controllerInteraction.presentationContext.animationCache, animationRenderer: arguments.controllerInteraction.presentationContext.animationRenderer )) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift index b6b8530047..e200998393 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift @@ -455,7 +455,7 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { } } let availableWidth: CGFloat = max(60.0, availableContentWidth - 220.0 + 6.0) - forwardInfoSizeApply = makeForwardInfoLayout(item.context, item.presentationData, item.presentationData.strings, .standalone, forwardSource, forwardAuthorSignature, forwardPsaType, nil, CGSize(width: availableWidth, height: CGFloat.greatestFiniteMagnitude)) + forwardInfoSizeApply = makeForwardInfoLayout(item.context, item.presentationData, item.presentationData.strings, .standalone, forwardSource.flatMap(EnginePeer.init), forwardAuthorSignature, forwardPsaType, nil, CGSize(width: availableWidth, height: CGFloat.greatestFiniteMagnitude)) } var notConsumed = false @@ -552,7 +552,7 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { } else { dateFormat = .regular } - let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: item.message, dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData, ignoreAuthor: item.presentationData.isPreview) + let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: EngineMessage(item.message), dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData, ignoreAuthor: item.presentationData.isPreview) let maxDateAndStatusWidth: CGFloat if case .bubble = statusDisplayType { @@ -579,7 +579,7 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { impressionCount: !item.presentationData.isPreview ? viewCount : nil, dateText: dateText, type: statusType, - layoutInput: .standalone(reactionSettings: shouldDisplayInlineDateReactions(message: item.message, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.StandaloneReactionSettings() : nil), + layoutInput: .standalone(reactionSettings: shouldDisplayInlineDateReactions(message: EngineMessage(item.message), isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.StandaloneReactionSettings() : nil), constrainedSize: CGSize(width: max(1.0, maxDateAndStatusWidth), height: CGFloat.greatestFiniteMagnitude), availableReactions: item.associatedData.availableReactions, savedMessageTags: item.associatedData.savedMessageTags, @@ -593,7 +593,7 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { starsCount: starsCount, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.topMessage), + canViewReactionList: canViewMessageReactionList(message: EngineMessage(item.topMessage)), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) @@ -617,7 +617,7 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { let result = ChatMessageInstantVideoItemLayoutResult(contentSize: contentSize, overflowLeft: 0.0, overflowRight: dateAndStatusOverflow ? 0.0 : (max(0.0, floorToScreenPixels(videoFrame.midX) + 55.0 + dateAndStatusSize.width - videoFrame.width))) var updatedAudioTranscriptionState: AudioTranscriptionButtonComponent.TranscriptionState? - let transcribedText = transcribedText(message: item.message) + let transcribedText = transcribedText(message: EngineMessage(item.message)) switch audioTranscriptionState { case .inProgress: @@ -763,7 +763,7 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { } durationNode.defaultDuration = telegramFile.duration.flatMap(Double.init) - let streamVideo = automaticDownload && isMediaStreamable(message: item.message, media: telegramFile) && telegramFile.id?.namespace != Namespaces.Media.LocalFile + let streamVideo = automaticDownload && isMediaStreamable(message: EngineMessage(item.message), media: telegramFile) && telegramFile.id?.namespace != Namespaces.Media.LocalFile if let videoNode = strongSelf.videoNode { videoNode.layer.allowsGroupOpacity = true videoNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.5, delay: 0.2, removeOnCompletion: false, completion: { [weak videoNode] _ in @@ -1246,7 +1246,7 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { self.infoBackgroundNode.isHidden = isViewOnceMessage var isBuffering: Bool? - if let message = self.item?.message, let media = self.media, isMediaStreamable(message: message, media: media) && (self.automaticDownload ?? false) { + if let message = self.item?.message, let media = self.media, isMediaStreamable(message: EngineMessage(message), media: media) && (self.automaticDownload ?? false) { if let playerStatus = self.playerStatus, case .buffering = playerStatus.status { isBuffering = true } else { @@ -1831,7 +1831,7 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { let presentationData = item.context.sharedContext.currentPresentationData.with { $0 } let premiumConfiguration = PremiumConfiguration.with(appConfiguration: item.context.currentAppConfiguration.with { $0 }) - let transcriptionText = transcribedText(message: item.message) + let transcriptionText = transcribedText(message: EngineMessage(item.message)) if transcriptionText == nil && !item.associatedData.alwaysDisplayTranscribeButton.providedByGroupBoost { if premiumConfiguration.audioTransciptionTrialCount > 0 { if !item.associatedData.isPremium { @@ -1874,7 +1874,7 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { if case .expanded = self.audioTranscriptionState { shouldExpandNow = true } else { - if let result = transcribedText(message: item.message) { + if let result = transcribedText(message: EngineMessage(item.message)) { shouldExpandNow = true if case let .success(_, isPending) = result { diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift index 28097ae4cb..f2177bb634 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift @@ -1117,7 +1117,7 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr impressionCount: !presentationData.isPreview ? dateAndStatus.viewCount : nil, dateText: dateAndStatus.dateText, type: dateAndStatus.type, - layoutInput: .standalone(reactionSettings: shouldDisplayInlineDateReactions(message: message, isPremium: associatedData.isPremium, forceInline: associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.StandaloneReactionSettings() : nil), + layoutInput: .standalone(reactionSettings: shouldDisplayInlineDateReactions(message: EngineMessage(message), isPremium: associatedData.isPremium, forceInline: associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.StandaloneReactionSettings() : nil), constrainedSize: CGSize(width: nativeSize.width - 30.0, height: CGFloat.greatestFiniteMagnitude), availableReactions: associatedData.availableReactions, savedMessageTags: associatedData.savedMessageTags, @@ -1131,7 +1131,7 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr starsCount: dateAndStatus.starsCount, isPinned: dateAndStatus.isPinned, hasAutoremove: message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: message), + canViewReactionList: canViewMessageReactionList(message: EngineMessage(message)), animationCache: presentationContext.animationCache, animationRenderer: presentationContext.animationRenderer )) @@ -1985,7 +1985,7 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr strongSelf.videoNodeDecoration = decoration let mediaManager = context.sharedContext.mediaManager - let streamVideo = isMediaStreamable(message: message, media: updatedVideoFile) + let streamVideo = isMediaStreamable(message: EngineMessage(message), media: updatedVideoFile) let loopVideo = updatedVideoFile.isAnimated let videoContent: UniversalVideoContent @@ -2805,7 +2805,7 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr } if let duration = file.duration, !message.flags.contains(.Unsent) { let durationString = file.isAnimated ? gifTitle : stringForDuration(playerDuration > 0 ? playerDuration : Int32(duration), position: playerPosition) - if isMediaStreamable(message: message, media: file) { + if isMediaStreamable(message: EngineMessage(message), media: file) { badgeContent = .mediaDownload(backgroundColor: messageTheme.mediaDateAndStatusFillColor, foregroundColor: messageTheme.mediaDateAndStatusTextColor, duration: durationString, size: active ? sizeString : nil, muted: muted, active: active) mediaDownloadState = .fetching(progress: automaticPlayback ? nil : adjustedProgress) if self.playerStatus?.status == .playing { @@ -2831,11 +2831,11 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr badgeContent = .mediaDownload(backgroundColor: messageTheme.mediaDateAndStatusFillColor, foregroundColor: messageTheme.mediaDateAndStatusTextColor, duration: strings.Conversation_Processing, size: nil, muted: false, active: false) } } - if file.isAnimated && isMediaStreamable(message: message, media: file) { + if file.isAnimated && isMediaStreamable(message: EngineMessage(message), media: file) { state = automaticPlayback ? .none : state } } else { - if isMediaStreamable(message: message, media: file), let fileSize = file.size, fileSize > 0 && fileSize != .max { + if isMediaStreamable(message: EngineMessage(message), media: file), let fileSize = file.size, fileSize > 0 && fileSize != .max { let sizeString = "\(dataSizeString(Int64(Float(fileSize) * progress), forceDecimal: true, formatting: formatting)) / \(dataSizeString(fileSize, forceDecimal: true, formatting: formatting))" if message.flags.contains(.Unsent), let duration = file.duration { @@ -2911,7 +2911,7 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr do { let durationString = file.isAnimated ? gifTitle : stringForDuration(playerDuration > 0 ? playerDuration : (file.duration.flatMap { Int32(floor($0)) } ?? 0), position: playerPosition) if wideLayout { - if isMediaStreamable(message: message, media: file), let fileSize = file.size, fileSize > 0 && fileSize != .max { + if isMediaStreamable(message: EngineMessage(message), media: file), let fileSize = file.size, fileSize > 0 && fileSize != .max { state = automaticPlayback ? .none : .play(messageTheme.mediaOverlayControlColors.foregroundColor) badgeContent = .mediaDownload(backgroundColor: messageTheme.mediaDateAndStatusFillColor, foregroundColor: messageTheme.mediaDateAndStatusTextColor, duration: durationString, size: dataSizeString(fileSize, formatting: formatting), muted: muted, active: true) mediaDownloadState = .remote @@ -2920,7 +2920,7 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr badgeContent = .mediaDownload(backgroundColor: messageTheme.mediaDateAndStatusFillColor, foregroundColor: messageTheme.mediaDateAndStatusTextColor, duration: durationString, size: nil, muted: muted, active: false) } } else { - if isMediaStreamable(message: message, media: file) { + if isMediaStreamable(message: EngineMessage(message), media: file) { state = automaticPlayback ? .none : .play(messageTheme.mediaOverlayControlColors.foregroundColor) badgeContent = .text(inset: 12.0, backgroundColor: messageTheme.mediaDateAndStatusFillColor, foregroundColor: messageTheme.mediaDateAndStatusTextColor, text: NSAttributedString(string: durationString), iconName: nil) mediaDownloadState = .compactRemote diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageItemCommon/BUILD b/submodules/TelegramUI/Components/Chat/ChatMessageItemCommon/BUILD index 0d4b817002..a8832059b6 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageItemCommon/BUILD +++ b/submodules/TelegramUI/Components/Chat/ChatMessageItemCommon/BUILD @@ -11,7 +11,6 @@ swift_library( ], deps = [ "//submodules/Display", - "//submodules/Postbox", "//submodules/TelegramCore", "//submodules/Emoji", ], diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageItemCommon/Sources/ChatMessageItemCommon.swift b/submodules/TelegramUI/Components/Chat/ChatMessageItemCommon/Sources/ChatMessageItemCommon.swift index 3b2669fc44..fc189879a3 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageItemCommon/Sources/ChatMessageItemCommon.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageItemCommon/Sources/ChatMessageItemCommon.swift @@ -1,7 +1,6 @@ import Foundation import UIKit import Display -import Postbox import TelegramCore import Emoji @@ -160,7 +159,7 @@ public struct ChatMessageItemLayoutConstants { } } -public func canViewMessageReactionList(message: Message) -> Bool { +public func canViewMessageReactionList(message: EngineMessage) -> Bool { var found = false var canViewList = false for attribute in message.attributes { @@ -209,7 +208,7 @@ public enum TranscribedText: Equatable { case error(AudioTranscriptionMessageAttribute.TranscriptionError) } -public func transcribedText(message: Message) -> TranscribedText? { +public func transcribedText(message: EngineMessage) -> TranscribedText? { for attribute in message.attributes { if let attribute = attribute as? AudioTranscriptionMessageAttribute { if !attribute.text.isEmpty { @@ -226,7 +225,7 @@ public func transcribedText(message: Message) -> TranscribedText? { return nil } -public func isPollEffectivelyClosed(message: Message, poll: TelegramMediaPoll) -> Bool { +public func isPollEffectivelyClosed(message: EngineMessage, poll: TelegramMediaPoll) -> Bool { if poll.isClosed { return true } else { @@ -235,12 +234,12 @@ public func isPollEffectivelyClosed(message: Message, poll: TelegramMediaPoll) - } public extension ChatReplyThreadMessage { - var effectiveTopId: MessageId { - return self.channelMessageId ?? MessageId(peerId: self.peerId, namespace: Namespaces.Message.Cloud, id: Int32(clamping: self.threadId)) + var effectiveTopId: EngineMessage.Id { + return self.channelMessageId ?? EngineMessage.Id(peerId: self.peerId, namespace: Namespaces.Message.Cloud, id: Int32(clamping: self.threadId)) } } -public func messageIsEligibleForLargeEmoji(_ message: Message) -> Bool { +public func messageIsEligibleForLargeEmoji(_ message: EngineMessage) -> Bool { if !message.text.isEmpty && message.text.containsOnlyEmoji { if !(message.textEntitiesAttribute?.entities.isEmpty ?? true) { return false @@ -251,7 +250,7 @@ public func messageIsEligibleForLargeEmoji(_ message: Message) -> Bool { } } -public func messageIsEligibleForLargeCustomEmoji(_ message: Message) -> Bool { +public func messageIsEligibleForLargeCustomEmoji(_ message: EngineMessage) -> Bool { let text = message.text.replacingOccurrences(of: "\n", with: "").replacingOccurrences(of: " ", with: "") guard !text.isEmpty && text.containsOnlyEmoji else { return false @@ -262,7 +261,7 @@ public func messageIsEligibleForLargeCustomEmoji(_ message: Message) -> Bool { } for entity in entities { if case let .CustomEmoji(_, fileId) = entity.type { - if let _ = message.associatedMedia[MediaId(namespace: Namespaces.Media.CloudFile, id: fileId)] as? TelegramMediaFile { + if let _ = message.associatedMedia[EngineMedia.Id(namespace: Namespaces.Media.CloudFile, id: fileId)] as? TelegramMediaFile { } else { return false @@ -274,7 +273,7 @@ public func messageIsEligibleForLargeCustomEmoji(_ message: Message) -> Bool { return true } -public func canAddMessageReactions(message: Message) -> Bool { +public func canAddMessageReactions(message: EngineMessage) -> Bool { if message.id.namespace != Namespaces.Message.Cloud { return false } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageMapBubbleContentNode/Sources/ChatMessageMapBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageMapBubbleContentNode/Sources/ChatMessageMapBubbleContentNode.swift index 484d9a2312..53993ce16c 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageMapBubbleContentNode/Sources/ChatMessageMapBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageMapBubbleContentNode/Sources/ChatMessageMapBubbleContentNode.swift @@ -225,7 +225,7 @@ public class ChatMessageMapBubbleContentNode: ChatMessageBubbleContentNode { } else { dateFormat = .regular } - let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: item.message, dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) + let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: EngineMessage(item.message), dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) let statusType: ChatMessageDateAndStatusType? if case .customChatContents = item.associatedData.subject { @@ -279,7 +279,7 @@ public class ChatMessageMapBubbleContentNode: ChatMessageBubbleContentNode { impressionCount: !item.presentationData.isPreview ? viewCount : nil, dateText: dateText, type: statusType, - layoutInput: .standalone(reactionSettings: shouldDisplayInlineDateReactions(message: item.message, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.StandaloneReactionSettings() : nil), + layoutInput: .standalone(reactionSettings: shouldDisplayInlineDateReactions(message: EngineMessage(item.message), isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.StandaloneReactionSettings() : nil), constrainedSize: CGSize(width: constrainedSize.width, height: CGFloat.greatestFiniteMagnitude), availableReactions: item.associatedData.availableReactions, savedMessageTags: item.associatedData.savedMessageTags, @@ -293,7 +293,7 @@ public class ChatMessageMapBubbleContentNode: ChatMessageBubbleContentNode { starsCount: starsCount, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.topMessage), + canViewReactionList: canViewMessageReactionList(message: EngineMessage(item.topMessage)), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageMediaBubbleContentNode/Sources/ChatMessageMediaBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageMediaBubbleContentNode/Sources/ChatMessageMediaBubbleContentNode.swift index 61af684c63..fa752abe2d 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageMediaBubbleContentNode/Sources/ChatMessageMediaBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageMediaBubbleContentNode/Sources/ChatMessageMediaBubbleContentNode.swift @@ -378,7 +378,7 @@ public class ChatMessageMediaBubbleContentNode: ChatMessageBubbleContentNode { } else { dateFormat = .regular } - let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: item.message, dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) + let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: EngineMessage(item.message), dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) let statusType: ChatMessageDateAndStatusType? if case .customChatContents = item.associatedData.subject { diff --git a/submodules/TelegramUI/Components/Chat/ChatMessagePollBubbleContentNode/Sources/ChatMessagePollBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessagePollBubbleContentNode/Sources/ChatMessagePollBubbleContentNode.swift index 1be7762dff..da1944f34d 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessagePollBubbleContentNode/Sources/ChatMessagePollBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessagePollBubbleContentNode/Sources/ChatMessagePollBubbleContentNode.swift @@ -2460,7 +2460,7 @@ public class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode { } else { dateFormat = .regular } - let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: item.message, dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) + let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: EngineMessage(item.message), dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) let statusType: ChatMessageDateAndStatusType? if case .customChatContents = item.associatedData.subject { @@ -2499,7 +2499,7 @@ public class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode { impressionCount: viewCount, dateText: dateText, type: statusType, - layoutInput: .trailingContent(contentWidth: 1000.0, reactionSettings: shouldDisplayInlineDateReactions(message: item.message, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: true, preferAdditionalInset: false) : nil), + layoutInput: .trailingContent(contentWidth: 1000.0, reactionSettings: shouldDisplayInlineDateReactions(message: EngineMessage(item.message), isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: true, preferAdditionalInset: false) : nil), constrainedSize: textConstrainedSize, availableReactions: item.associatedData.availableReactions, savedMessageTags: item.associatedData.savedMessageTags, @@ -2513,7 +2513,7 @@ public class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode { starsCount: starsCount, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.topMessage), + canViewReactionList: canViewMessageReactionList(message: EngineMessage(item.topMessage)), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) @@ -2576,7 +2576,7 @@ public class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode { } } - if let poll = poll, isPollEffectivelyClosed(message: message, poll: poll) { + if let poll = poll, isPollEffectivelyClosed(message: EngineMessage(message), poll: poll) { typeText = item.presentationData.strings.MessagePoll_LabelClosed } else if let poll = poll { switch poll.kind { @@ -2676,7 +2676,7 @@ public class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode { let isClosed: Bool if let poll = poll { - isClosed = isPollEffectivelyClosed(message: message, poll: poll) + isClosed = isPollEffectivelyClosed(message: EngineMessage(message), poll: poll) } else { isClosed = false } @@ -3330,7 +3330,7 @@ public class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode { } } - let isClosed = isPollEffectivelyClosed(message: item.message, poll: poll) + let isClosed = isPollEffectivelyClosed(message: EngineMessage(item.message), poll: poll) let canAlwaysViewResults = !poll.hideResultsUntilClose && poll.isCreator var hasAnyVotes = false diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/BUILD b/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/BUILD index 5b4f65efeb..e4708fee31 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/BUILD +++ b/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/BUILD @@ -10,7 +10,6 @@ swift_library( "-warnings-as-errors", ], deps = [ - "//submodules/Postbox", "//submodules/Display", "//submodules/AsyncDisplayKit", "//submodules/SSignalKit/SwiftSignalKit", diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/Sources/ChatMessageReactionsFooterContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/Sources/ChatMessageReactionsFooterContentNode.swift index 12db046140..194c2467b9 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/Sources/ChatMessageReactionsFooterContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/Sources/ChatMessageReactionsFooterContentNode.swift @@ -1,6 +1,5 @@ import Foundation import UIKit -import Postbox import Display import AsyncDisplayKit import SwiftSignalKit @@ -62,7 +61,7 @@ public final class MessageReactionButtonsNode: ASDisplayNode { savedMessageTags: SavedMessageTags?, reactions: ReactionsMessageAttribute, accountPeer: EnginePeer?, - message: Message, + message: EngineMessage, associatedData: ChatMessageItemAssociatedData, alignment: DisplayAlignment, constrainedWidth: CGFloat, @@ -632,7 +631,7 @@ public final class ChatMessageReactionsFooterContentNode: ChatMessageBubbleConte context: item.context, presentationData: item.presentationData, presentationContext: item.controllerInteraction.presentationContext, - availableReactions: item.associatedData.availableReactions, savedMessageTags: item.associatedData.savedMessageTags, reactions: reactionsAttribute, accountPeer: item.associatedData.accountPeer, message: item.message, associatedData: item.associatedData, alignment: .left, constrainedWidth: constrainedSize.width - layoutConstants.text.bubbleInsets.left - layoutConstants.text.bubbleInsets.right, type: item.message.effectivelyIncoming(item.context.account.peerId) ? .incoming : .outgoing) + availableReactions: item.associatedData.availableReactions, savedMessageTags: item.associatedData.savedMessageTags, reactions: reactionsAttribute, accountPeer: item.associatedData.accountPeer, message: EngineMessage(item.message), associatedData: item.associatedData, alignment: .left, constrainedWidth: constrainedSize.width - layoutConstants.text.bubbleInsets.left - layoutConstants.text.bubbleInsets.right, type: item.message.effectivelyIncoming(item.context.account.peerId) ? .incoming : .outgoing) return (layoutConstants.text.bubbleInsets.left + layoutConstants.text.bubbleInsets.right + buttonsUpdate.proposedWidth, { boundingWidth in var boundingSize = CGSize() @@ -712,13 +711,13 @@ public final class ChatMessageReactionButtonsNode: ASDisplayNode { public let availableReactions: AvailableReactions? public let savedMessageTags: SavedMessageTags? public let reactions: ReactionsMessageAttribute - public let message: Message + public let message: EngineMessage public let associatedData: ChatMessageItemAssociatedData public let accountPeer: EnginePeer? public let isIncoming: Bool public let constrainedWidth: CGFloat public let centerAligned: Bool - + public init( context: AccountContext, presentationData: ChatPresentationData, @@ -726,7 +725,7 @@ public final class ChatMessageReactionButtonsNode: ASDisplayNode { availableReactions: AvailableReactions?, savedMessageTags: SavedMessageTags?, reactions: ReactionsMessageAttribute, - message: Message, + message: EngineMessage, associatedData: ChatMessageItemAssociatedData, accountPeer: EnginePeer?, isIncoming: Bool, diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageRestrictedBubbleContentNode/Sources/ChatMessageRestrictedBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageRestrictedBubbleContentNode/Sources/ChatMessageRestrictedBubbleContentNode.swift index c7727b7f26..f7c9e0a48b 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageRestrictedBubbleContentNode/Sources/ChatMessageRestrictedBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageRestrictedBubbleContentNode/Sources/ChatMessageRestrictedBubbleContentNode.swift @@ -76,7 +76,7 @@ public class ChatMessageRestrictedBubbleContentNode: ChatMessageBubbleContentNod } } - let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: item.message, dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, associatedData: item.associatedData) + let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: EngineMessage(item.message), dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, associatedData: item.associatedData) let statusType: ChatMessageDateAndStatusType? if case .customChatContents = item.associatedData.subject { @@ -132,7 +132,7 @@ public class ChatMessageRestrictedBubbleContentNode: ChatMessageBubbleContentNod impressionCount: viewCount, dateText: dateText, type: statusType, - layoutInput: .trailingContent(contentWidth: textLayout.trailingLineWidth, reactionSettings: ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: shouldDisplayInlineDateReactions(message: message, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions), preferAdditionalInset: false)), + layoutInput: .trailingContent(contentWidth: textLayout.trailingLineWidth, reactionSettings: ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: shouldDisplayInlineDateReactions(message: EngineMessage(message), isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions), preferAdditionalInset: false)), constrainedSize: textConstrainedSize, availableReactions: item.associatedData.availableReactions, savedMessageTags: item.associatedData.savedMessageTags, @@ -146,7 +146,7 @@ public class ChatMessageRestrictedBubbleContentNode: ChatMessageBubbleContentNod starsCount: starsCount, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && isReplyThread, hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.topMessage), + canViewReactionList: canViewMessageReactionList(message: EngineMessage(item.topMessage)), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageShareButton/BUILD b/submodules/TelegramUI/Components/Chat/ChatMessageShareButton/BUILD index 70a8cb9400..cde8bb8e85 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageShareButton/BUILD +++ b/submodules/TelegramUI/Components/Chat/ChatMessageShareButton/BUILD @@ -16,7 +16,6 @@ swift_library( "//submodules/TelegramUI/Components/ChatControllerInteraction", "//submodules/AccountContext", "//submodules/TelegramCore", - "//submodules/Postbox", "//submodules/WallpaperBackgroundNode", "//submodules/TelegramUI/Components/Chat/ChatMessageItemCommon", "//submodules/ContextUI", diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageShareButton/Sources/ChatMessageShareButton.swift b/submodules/TelegramUI/Components/Chat/ChatMessageShareButton/Sources/ChatMessageShareButton.swift index 7e38d33ef3..3509bfad43 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageShareButton/Sources/ChatMessageShareButton.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageShareButton/Sources/ChatMessageShareButton.swift @@ -6,7 +6,6 @@ import TelegramPresentationData import ChatControllerInteraction import AccountContext import TelegramCore -import Postbox import WallpaperBackgroundNode import ChatMessageItemCommon import ContextUI @@ -107,7 +106,7 @@ public class ChatMessageShareButton: ASDisplayNode { self.morePressed?() } - public func update(presentationData: ChatPresentationData, controllerInteraction: ChatControllerInteraction, chatLocation: ChatLocation, subject: ChatControllerSubject?, message: Message, account: Account, disableComments: Bool = false, isSummarize: Bool = false) -> CGSize { + public func update(presentationData: ChatPresentationData, controllerInteraction: ChatControllerInteraction, chatLocation: ChatLocation, subject: ChatControllerSubject?, message: EngineMessage, accountPeerId: EnginePeer.Id, disableComments: Bool = false, isSummarize: Bool = false) -> CGSize { var isReplies = false var isNavigate = false var replyCount = 0 @@ -176,7 +175,7 @@ public class ChatMessageShareButton: ASDisplayNode { updatedIconOffset = CGPoint(x: UIScreenPixel, y: 1.0) } else if isReplies { updatedIconImage = PresentationResourcesChat.chatFreeCommentButtonIcon(presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper) - } else if message.id.peerId.isRepliesOrSavedMessages(accountPeerId: account.peerId) { + } else if message.id.peerId.isRepliesOrSavedMessages(accountPeerId: accountPeerId) { updatedIconImage = PresentationResourcesChat.chatFreeNavigateButtonIcon(presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper) updatedIconOffset = CGPoint(x: UIScreenPixel, y: 1.0) } else { diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageStarsMediaInfoNode/BUILD b/submodules/TelegramUI/Components/Chat/ChatMessageStarsMediaInfoNode/BUILD index 85588cbecc..c238287b4f 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageStarsMediaInfoNode/BUILD +++ b/submodules/TelegramUI/Components/Chat/ChatMessageStarsMediaInfoNode/BUILD @@ -11,7 +11,6 @@ swift_library( ], deps = [ "//submodules/AsyncDisplayKit", - "//submodules/Postbox", "//submodules/Display", "//submodules/TelegramCore", "//submodules/SSignalKit/SwiftSignalKit", diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageStarsMediaInfoNode/Sources/ChatMessageStarsMediaInfoNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageStarsMediaInfoNode/Sources/ChatMessageStarsMediaInfoNode.swift index 25836a51b2..be8ec426e9 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageStarsMediaInfoNode/Sources/ChatMessageStarsMediaInfoNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageStarsMediaInfoNode/Sources/ChatMessageStarsMediaInfoNode.swift @@ -1,7 +1,6 @@ import Foundation import UIKit import AsyncDisplayKit -import Postbox import Display import TelegramCore import SwiftSignalKit @@ -178,7 +177,7 @@ public class ChatMessageStarsMediaInfoNode: ASDisplayNode { public class Arguments { public let presentationData: ChatPresentationData public let context: AccountContext - public let message: Message + public let message: EngineMessage public let media: TelegramMediaPaidContent public let constrainedSize: CGSize public let animationCache: AnimationCache? @@ -187,7 +186,7 @@ public class ChatMessageStarsMediaInfoNode: ASDisplayNode { public init( presentationData: ChatPresentationData, context: AccountContext, - message: Message, + message: EngineMessage, media: TelegramMediaPaidContent, constrainedSize: CGSize, animationCache: AnimationCache?, diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageStickerItemNode/Sources/ChatMessageStickerItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageStickerItemNode/Sources/ChatMessageStickerItemNode.swift index bbea729223..b43b5d001e 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageStickerItemNode/Sources/ChatMessageStickerItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageStickerItemNode/Sources/ChatMessageStickerItemNode.swift @@ -229,7 +229,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView { } } - if let item = strongSelf.item, item.presentationData.largeEmoji && messageIsEligibleForLargeEmoji(item.message) { + if let item = strongSelf.item, item.presentationData.largeEmoji && messageIsEligibleForLargeEmoji(EngineMessage(item.message)) { if strongSelf.imageNode.frame.contains(point) { return .waitForDoubleTap } @@ -456,7 +456,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView { var textLayoutAndApply: (TextNodeLayout, () -> TextNode)? var isEmoji = false - if item.presentationData.largeEmoji && messageIsEligibleForLargeEmoji(item.message) { + if item.presentationData.largeEmoji && messageIsEligibleForLargeEmoji(EngineMessage(item.message)) { let attributedText = NSAttributedString(string: item.message.text, font: item.presentationData.messageEmojiFont, textColor: .black) textLayoutAndApply = textLayout(TextNodeLayoutArguments(attributedString: attributedText, backgroundColor: nil, maximumNumberOfLines: 0, truncationType: .end, constrainedSize: CGSize(width: params.width, height: 90.0), alignment: .natural)) @@ -643,7 +643,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView { } else { dateFormat = .regular } - let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: item.message, dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) + let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: EngineMessage(item.message), dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) var isReplyThread = false if case .replyThread = item.chatLocation { @@ -657,7 +657,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView { impressionCount: viewCount, dateText: dateText, type: statusType, - layoutInput: .standalone(reactionSettings: shouldDisplayInlineDateReactions(message: item.message, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.StandaloneReactionSettings() : nil), + layoutInput: .standalone(reactionSettings: shouldDisplayInlineDateReactions(message: EngineMessage(item.message), isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.StandaloneReactionSettings() : nil), constrainedSize: CGSize(width: params.width, height: CGFloat.greatestFiniteMagnitude), availableReactions: item.associatedData.availableReactions, savedMessageTags: item.associatedData.savedMessageTags, @@ -671,7 +671,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView { starsCount: starsCount, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.message), + canViewReactionList: canViewMessageReactionList(message: EngineMessage(item.message)), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) @@ -839,7 +839,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView { } } let availableForwardWidth = max(60.0, availableWidth + 6.0) - forwardInfoSizeApply = makeForwardInfoLayout(item.context, item.presentationData, item.presentationData.strings, .standalone, forwardSource, forwardAuthorSignature, forwardPsaType, nil, CGSize(width: availableForwardWidth, height: CGFloat.greatestFiniteMagnitude)) + forwardInfoSizeApply = makeForwardInfoLayout(item.context, item.presentationData, item.presentationData.strings, .standalone, forwardSource.flatMap(EnginePeer.init), forwardAuthorSignature, forwardPsaType, nil, CGSize(width: availableForwardWidth, height: CGFloat.greatestFiniteMagnitude)) } var needsReplyBackground = false @@ -857,7 +857,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView { var maxContentWidth = imageSize.width var actionButtonsFinalize: ((CGFloat) -> (CGSize, (_ animation: ListViewItemUpdateAnimation) -> ChatMessageActionButtonsNode))? if let replyMarkup = replyMarkup { - let (minWidth, buttonsLayout) = actionButtonsLayout(item.context, item.presentationData.theme, item.presentationData.chatBubbleCorners, item.presentationData.strings, item.controllerInteraction.presentationContext.backgroundNode, replyMarkup, [:], item.message, baseWidth) + let (minWidth, buttonsLayout) = actionButtonsLayout(item.context, item.presentationData.theme, item.presentationData.chatBubbleCorners, item.presentationData.strings, item.controllerInteraction.presentationContext.backgroundNode, replyMarkup, [:], EngineMessage(item.message), baseWidth) maxContentWidth = max(maxContentWidth, minWidth) actionButtonsFinalize = buttonsLayout } else if incoming, let attribute = item.message.attributes.first(where: { $0 is SuggestedPostMessageAttribute }) as? SuggestedPostMessageAttribute, attribute.state == nil { @@ -906,7 +906,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView { ], flags: [], placeholder: nil - ), customInfos, item.message, baseWidth) + ), customInfos, EngineMessage(item.message), baseWidth) maxContentWidth = max(maxContentWidth, minWidth) actionButtonsFinalize = buttonsLayout } @@ -917,7 +917,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView { } let reactions: ReactionsMessageAttribute - if shouldDisplayInlineDateReactions(message: item.message, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) { + if shouldDisplayInlineDateReactions(message: EngineMessage(item.message), isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) { reactions = ReactionsMessageAttribute(canViewList: false, isTags: false, reactions: [], recentPeers: [], topPeers: []) } else { reactions = mergedMessageReactions(attributes: item.message.attributes, isTags: item.message.areReactionsTags(accountPeerId: item.context.account.peerId)) ?? ReactionsMessageAttribute(canViewList: false, isTags: false, reactions: [], recentPeers: [], topPeers: []) @@ -935,7 +935,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView { availableReactions: item.associatedData.availableReactions, savedMessageTags: item.associatedData.savedMessageTags, reactions: reactions, - message: item.message, + message: EngineMessage(item.message), associatedData: item.associatedData, accountPeer: item.associatedData.accountPeer, isIncoming: item.message.effectivelyIncoming(item.context.account.peerId), @@ -1119,7 +1119,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView { strongSelf?.openQuickShare(node: node, gesture: gesture) } } - let buttonSize = updatedShareButtonNode.update(presentationData: item.presentationData, controllerInteraction: item.controllerInteraction, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: item.message, account: item.context.account) + let buttonSize = updatedShareButtonNode.update(presentationData: item.presentationData, controllerInteraction: item.controllerInteraction, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: EngineMessage(item.message), accountPeerId: item.context.account.peerId) let shareButtonFrame = CGRect(origin: CGPoint(x: baseShareButtonFrame.minX, y: baseShareButtonFrame.maxY - buttonSize.height), size: buttonSize) transition.updateFrame(node: updatedShareButtonNode, frame: shareButtonFrame) } else if let shareButtonNode = strongSelf.shareButtonNode { @@ -1512,7 +1512,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView { case let .optionalAction(f): f() case let .openContextMenu(openContextMenu): - if canAddMessageReactions(message: item.message) { + if canAddMessageReactions(message: EngineMessage(item.message)) { item.controllerInteraction.updateMessageReaction(openContextMenu.tapMessage, .default, false, nil) } else { item.controllerInteraction.openMessageContextMenu(openContextMenu.tapMessage, openContextMenu.selectAll, self, openContextMenu.subFrame, nil, nil) @@ -1807,7 +1807,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView { let incoming = item.content.effectivelyIncoming(item.context.account.peerId, associatedData: item.associatedData) var isEmoji = false - if let item = self.item, item.presentationData.largeEmoji && messageIsEligibleForLargeEmoji(item.message) { + if let item = self.item, item.presentationData.largeEmoji && messageIsEligibleForLargeEmoji(EngineMessage(item.message)) { isEmoji = true } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift index 988d9d96fc..54aff3aa0d 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift @@ -338,7 +338,7 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode { } else { dateFormat = .regular } - let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: item.message, dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) + let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: EngineMessage(item.message), dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) let statusType: ChatMessageDateAndStatusType? var displayStatus = false @@ -754,7 +754,7 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode { } let dateLayoutInput: ChatMessageDateAndStatusNode.LayoutInput - dateLayoutInput = .trailingContent(contentWidth: trailingWidthToMeasure, reactionSettings: ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: shouldDisplayInlineDateReactions(message: item.message, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions), preferAdditionalInset: false)) + dateLayoutInput = .trailingContent(contentWidth: trailingWidthToMeasure, reactionSettings: ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: shouldDisplayInlineDateReactions(message: EngineMessage(item.message), isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions), preferAdditionalInset: false)) statusSuggestedWidthAndContinue = statusLayout(ChatMessageDateAndStatusNode.Arguments( context: item.context, @@ -777,7 +777,7 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode { starsCount: starsCount, isPinned: item.message.tags.contains(.pinned) && (!item.associatedData.isInPinnedListMode || isReplyThread), hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.topMessage), + canViewReactionList: canViewMessageReactionList(message: EngineMessage(item.topMessage)), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageThreadInfoNode/BUILD b/submodules/TelegramUI/Components/Chat/ChatMessageThreadInfoNode/BUILD index 6b225f349c..a5f51cc610 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageThreadInfoNode/BUILD +++ b/submodules/TelegramUI/Components/Chat/ChatMessageThreadInfoNode/BUILD @@ -11,7 +11,6 @@ swift_library( ], deps = [ "//submodules/AsyncDisplayKit", - "//submodules/Postbox", "//submodules/Display", "//submodules/TelegramCore", "//submodules/SSignalKit/SwiftSignalKit", diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageThreadInfoNode/Sources/ChatMessageThreadInfoNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageThreadInfoNode/Sources/ChatMessageThreadInfoNode.swift index 7f82b824f6..2bfce1647c 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageThreadInfoNode/Sources/ChatMessageThreadInfoNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageThreadInfoNode/Sources/ChatMessageThreadInfoNode.swift @@ -1,7 +1,6 @@ import Foundation import UIKit import AsyncDisplayKit -import Postbox import Display import TelegramCore import SwiftSignalKit @@ -187,7 +186,7 @@ public class ChatMessageThreadInfoNode: ASDisplayNode { public let type: ChatMessageThreadInfoType public let peer: EnginePeer? public let threadId: Int64? - public let parentMessage: Message + public let parentMessage: EngineMessage public let constrainedSize: CGSize public let animationCache: AnimationCache? public let animationRenderer: MultiAnimationRenderer? @@ -200,7 +199,7 @@ public class ChatMessageThreadInfoNode: ASDisplayNode { type: ChatMessageThreadInfoType, peer: EnginePeer?, threadId: Int64?, - parentMessage: Message, + parentMessage: EngineMessage, constrainedSize: CGSize, animationCache: AnimationCache?, animationRenderer: MultiAnimationRenderer? diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageTodoBubbleContentNode/Sources/ChatMessageTodoBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageTodoBubbleContentNode/Sources/ChatMessageTodoBubbleContentNode.swift index f4df239aa5..bdc4c7dc8d 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageTodoBubbleContentNode/Sources/ChatMessageTodoBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageTodoBubbleContentNode/Sources/ChatMessageTodoBubbleContentNode.swift @@ -1138,7 +1138,7 @@ public class ChatMessageTodoBubbleContentNode: ChatMessageBubbleContentNode { } else { dateFormat = .regular } - let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: item.message, dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) + let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: EngineMessage(item.message), dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat, associatedData: item.associatedData) let statusType: ChatMessageDateAndStatusType? if case .customChatContents = item.associatedData.subject { @@ -1177,7 +1177,7 @@ public class ChatMessageTodoBubbleContentNode: ChatMessageBubbleContentNode { impressionCount: viewCount, dateText: dateText, type: statusType, - layoutInput: .trailingContent(contentWidth: 1000.0, reactionSettings: shouldDisplayInlineDateReactions(message: item.message, isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: true, preferAdditionalInset: false) : nil), + layoutInput: .trailingContent(contentWidth: 1000.0, reactionSettings: shouldDisplayInlineDateReactions(message: EngineMessage(item.message), isPremium: item.associatedData.isPremium, forceInline: item.associatedData.forceInlineReactions) ? ChatMessageDateAndStatusNode.TrailingReactionSettings(displayInline: true, preferAdditionalInset: false) : nil), constrainedSize: textConstrainedSize, availableReactions: item.associatedData.availableReactions, savedMessageTags: item.associatedData.savedMessageTags, @@ -1191,7 +1191,7 @@ public class ChatMessageTodoBubbleContentNode: ChatMessageBubbleContentNode { starsCount: starsCount, isPinned: item.message.tags.contains(.pinned) && !item.associatedData.isInPinnedListMode && !isReplyThread, hasAutoremove: item.message.isSelfExpiring, - canViewReactionList: canViewMessageReactionList(message: item.topMessage), + canViewReactionList: canViewMessageReactionList(message: EngineMessage(item.topMessage)), animationCache: item.controllerInteraction.presentationContext.animationCache, animationRenderer: item.controllerInteraction.presentationContext.animationRenderer )) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageUnlockMediaNode/BUILD b/submodules/TelegramUI/Components/Chat/ChatMessageUnlockMediaNode/BUILD index a031cda0e1..d932de0377 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageUnlockMediaNode/BUILD +++ b/submodules/TelegramUI/Components/Chat/ChatMessageUnlockMediaNode/BUILD @@ -11,7 +11,6 @@ swift_library( ], deps = [ "//submodules/AsyncDisplayKit", - "//submodules/Postbox", "//submodules/Display", "//submodules/TelegramCore", "//submodules/SSignalKit/SwiftSignalKit", diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageUnlockMediaNode/Sources/ChatMessageUnlockMediaNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageUnlockMediaNode/Sources/ChatMessageUnlockMediaNode.swift index 91b51a70a9..232f625e96 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageUnlockMediaNode/Sources/ChatMessageUnlockMediaNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageUnlockMediaNode/Sources/ChatMessageUnlockMediaNode.swift @@ -1,7 +1,6 @@ import Foundation import UIKit import AsyncDisplayKit -import Postbox import Display import TelegramCore import SwiftSignalKit @@ -24,7 +23,7 @@ public class ChatMessageUnlockMediaNode: ASDisplayNode { public let strings: PresentationStrings public let context: AccountContext public let controllerInteraction: ChatControllerInteraction - public let message: Message + public let message: EngineMessage public let media: TelegramMediaPaidContent public let constrainedSize: CGSize public let animationCache: AnimationCache? @@ -35,7 +34,7 @@ public class ChatMessageUnlockMediaNode: ASDisplayNode { strings: PresentationStrings, context: AccountContext, controllerInteraction: ChatControllerInteraction, - message: Message, + message: EngineMessage, media: TelegramMediaPaidContent, constrainedSize: CGSize, animationCache: AnimationCache?, @@ -150,7 +149,7 @@ public class ChatMessageUnlockMediaNode: ASDisplayNode { } node.pressed = { - let _ = arguments.controllerInteraction.openMessage(arguments.message, OpenMessageParams(mode: .default)) + let _ = arguments.controllerInteraction.openMessage(arguments.message._asMessage(), OpenMessageParams(mode: .default)) } node.textNode?.textNode.displaysAsynchronously = !arguments.presentationData.isPreview diff --git a/submodules/TelegramUI/Components/EntityKeyboardGifContent/Sources/GifContext.swift b/submodules/TelegramUI/Components/EntityKeyboardGifContent/Sources/GifContext.swift index 10f296469b..c022173264 100644 --- a/submodules/TelegramUI/Components/EntityKeyboardGifContent/Sources/GifContext.swift +++ b/submodules/TelegramUI/Components/EntityKeyboardGifContent/Sources/GifContext.swift @@ -1,6 +1,5 @@ import Foundation import SwiftSignalKit -import Postbox import TelegramCore import AccountContext import MultiplexedVideoNode @@ -96,7 +95,7 @@ public func paneGifSearchForQuery(context: AccountContext, query: String, offset if let content = externalReference.content { imageResource = content.resource if let resource = content.resource as? WebFileReferenceMediaResource { - uniqueId = Int64(HashFunctions.murMurHash32(resource.url)) + uniqueId = Int64(EngineHashFunctions.murMurHash32(resource.url)) } } if let thumbnail = externalReference.thumbnail { diff --git a/submodules/TelegramUI/Components/Gifts/GiftStoreScreen/BUILD b/submodules/TelegramUI/Components/Gifts/GiftStoreScreen/BUILD index 8c45e836c9..9eedd1221b 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftStoreScreen/BUILD +++ b/submodules/TelegramUI/Components/Gifts/GiftStoreScreen/BUILD @@ -12,7 +12,6 @@ swift_library( deps = [ "//submodules/AsyncDisplayKit", "//submodules/Display", - "//submodules/Postbox", "//submodules/TelegramCore", "//submodules/SSignalKit/SwiftSignalKit", "//submodules/ComponentFlow", diff --git a/submodules/TelegramUI/Components/Gifts/GiftStoreScreen/Sources/GiftAttributeListContextItem.swift b/submodules/TelegramUI/Components/Gifts/GiftStoreScreen/Sources/GiftAttributeListContextItem.swift index ac2c3e8a56..933d7da6bc 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftStoreScreen/Sources/GiftAttributeListContextItem.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftStoreScreen/Sources/GiftAttributeListContextItem.swift @@ -3,7 +3,6 @@ import UIKit import AsyncDisplayKit import Display import SwiftSignalKit -import Postbox import TelegramCore import AccountContext import TelegramPresentationData @@ -518,20 +517,20 @@ private final class GiftAttributeListContextItemNode: ASDisplayNode, ContextMenu } -private func stringTokens(_ string: String) -> [ValueBoxKey] { +private func stringTokens(_ string: String) -> [EngineDataBuffer] { 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: [EngineDataBuffer] = [] - var addedTokens = Set() + var addedTokens = Set() while tokenType != [] { let currentTokenRange = CFStringTokenizerGetCurrentTokenRange(tokenizer) if currentTokenRange.location >= 0 && currentTokenRange.length != 0 { - let token = ValueBoxKey(length: currentTokenRange.length * 2) + let token = EngineDataBuffer(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) @@ -544,7 +543,7 @@ private func stringTokens(_ string: String) -> [ValueBoxKey] { return tokens } -private func matchStringTokens(_ tokens: [ValueBoxKey], with other: [ValueBoxKey]) -> Bool { +private func matchStringTokens(_ tokens: [EngineDataBuffer], with other: [EngineDataBuffer]) -> Bool { if other.isEmpty { return false } else if other.count == 1 { diff --git a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift index 2e66874c1f..3888683dc1 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import Display import AsyncDisplayKit -import Postbox import TelegramCore import SwiftSignalKit import AccountContext @@ -751,8 +750,8 @@ private final class GiftViewSheetContent: CombinedComponent { case let .message(message): if let action = message.media.first(where: { $0 is TelegramMediaAction }) as? TelegramMediaAction, case let .starGiftUnique(gift, isUpgrade, isTransferred, savedToProfile, canExportDate, transferStars, isRefunded, isPrepaidUpgrade, peerId, senderId, savedId, resaleAmount, canTransferDate, canResaleDate, _, assigned, fromOffer, canCraftAt, isCrafted) = action.action, case let .unique(uniqueGift) = gift { let updatedAttributes = uniqueGift.attributes.filter { $0.attributeType != .originalInfo } - let updatedMedia: [Media] = [ - TelegramMediaAction( + let updatedMedia: [EngineMedia] = [ + .action(TelegramMediaAction( action: .starGiftUnique( gift: .unique(uniqueGift.withAttributes(updatedAttributes)), isUpgrade: isUpgrade, @@ -774,15 +773,15 @@ private final class GiftViewSheetContent: CombinedComponent { canCraftAt: canCraftAt, isCrafted: isCrafted ) - ) + )) ] - var mappedPeers: [PeerId: EnginePeer] = [:] + var mappedPeers: [EnginePeer.Id: EnginePeer] = [:] for (id, peer) in message.peers { mappedPeers[id] = EnginePeer(peer) } - var mappedAssociatedMessages: [MessageId: EngineMessage] = [:] + var mappedAssociatedMessages: [EngineMessage.Id: EngineMessage] = [:] for (id, message) in message.associatedMessages { mappedAssociatedMessages[id] = EngineMessage(message) } @@ -805,7 +804,7 @@ private final class GiftViewSheetContent: CombinedComponent { author: message.author, text: message.text, attributes: message.attributes, - media: updatedMedia.map { EngineMedia($0) }, + media: updatedMedia, peers: mappedPeers, associatedMessages: mappedAssociatedMessages, associatedMessageIds: message.associatedMessageIds, @@ -5062,7 +5061,7 @@ private final class GiftViewSheetContent: CombinedComponent { delay = true } - let upgradeMessageId = MessageId(peerId: peerId, namespace: originalMessageId.namespace, id: upgradeMessageIdId) + let upgradeMessageId = EngineMessage.Id(peerId: peerId, namespace: originalMessageId.namespace, id: upgradeMessageIdId) let buttonTitle = strings.Gift_View_ViewUpgraded buttonChild = button.update( component: ButtonComponent( diff --git a/submodules/TelegramUI/Components/JoinSubjectScreen/Sources/JoinSubjectScreen.swift b/submodules/TelegramUI/Components/JoinSubjectScreen/Sources/JoinSubjectScreen.swift index 145b14eac8..8153b4a429 100644 --- a/submodules/TelegramUI/Components/JoinSubjectScreen/Sources/JoinSubjectScreen.swift +++ b/submodules/TelegramUI/Components/JoinSubjectScreen/Sources/JoinSubjectScreen.swift @@ -12,7 +12,6 @@ import BalancedTextComponent import ButtonComponent import BundleIconComponent import Markdown -import Postbox import TelegramCore import AvatarNode import TelegramStringFormatting @@ -894,7 +893,7 @@ private final class JoinSubjectScreenComponent: Component { |> deliverOnMainQueue).startStandalone(next: { value in var value: PresentationGroupCallPersistentSettings = value?.get(PresentationGroupCallPersistentSettings.self) ?? PresentationGroupCallPersistentSettings.default value.isMicrophoneEnabledByDefault = callMicrophoneIsEnabled - if let entry = CodableEntry(value) { + if let entry = EngineCodableEntry(value) { context.engine.calls.setGroupCallPersistentSettings(callId: groupCall.id, value: entry) } }) diff --git a/submodules/TelegramUI/Components/LegacyCamera/BUILD b/submodules/TelegramUI/Components/LegacyCamera/BUILD index 7ba810fb22..50c465fdca 100644 --- a/submodules/TelegramUI/Components/LegacyCamera/BUILD +++ b/submodules/TelegramUI/Components/LegacyCamera/BUILD @@ -16,7 +16,6 @@ swift_library( "//submodules/LegacyComponents", "//submodules/Display", "//submodules/TelegramCore", - "//submodules/Postbox", "//submodules/AccountContext", "//submodules/ShareController", "//submodules/LegacyUI", diff --git a/submodules/TelegramUI/Components/LegacyCamera/Sources/LegacyCamera.swift b/submodules/TelegramUI/Components/LegacyCamera/Sources/LegacyCamera.swift index 0eb250bf4d..64f26b5236 100644 --- a/submodules/TelegramUI/Components/LegacyCamera/Sources/LegacyCamera.swift +++ b/submodules/TelegramUI/Components/LegacyCamera/Sources/LegacyCamera.swift @@ -3,7 +3,6 @@ import UIKit import LegacyComponents import Display import TelegramCore -import Postbox import SSignalKit import SwiftSignalKit import AccountContext @@ -11,7 +10,7 @@ import ShareController import LegacyUI import LegacyMediaPickerUI -public func presentedLegacyCamera(context: AccountContext, peer: Peer?, chatLocation: ChatLocation, cameraView: TGAttachmentCameraView?, menuController: TGMenuSheetController?, parentController: ViewController, attachmentController: ViewController? = nil, editingMedia: Bool, saveCapturedPhotos: Bool, mediaGrouping: Bool, initialCaption: NSAttributedString, hasSchedule: Bool, enablePhoto: Bool, enableVideo: Bool, sendPaidMessageStars: Int64 = 0, sendMessagesWithSignals: @escaping ([Any]?, Bool, Int32, ChatSendMessageActionSheetController.SendParameters?) -> Void, recognizedQRCode: @escaping (String) -> Void = { _ in }, presentSchedulePicker: @escaping (Bool, @escaping (Int32, Bool) -> Void) -> Void, presentTimerPicker: @escaping (@escaping (Int32) -> Void) -> Void, getCaptionPanelView: @escaping () -> TGCaptionPanelView?, dismissedWithResult: @escaping () -> Void = {}, finishedTransitionIn: @escaping () -> Void = {}) { +public func presentedLegacyCamera(context: AccountContext, peer: EnginePeer?, chatLocation: ChatLocation, cameraView: TGAttachmentCameraView?, menuController: TGMenuSheetController?, parentController: ViewController, attachmentController: ViewController? = nil, editingMedia: Bool, saveCapturedPhotos: Bool, mediaGrouping: Bool, initialCaption: NSAttributedString, hasSchedule: Bool, enablePhoto: Bool, enableVideo: Bool, sendPaidMessageStars: Int64 = 0, sendMessagesWithSignals: @escaping ([Any]?, Bool, Int32, ChatSendMessageActionSheetController.SendParameters?) -> Void, recognizedQRCode: @escaping (String) -> Void = { _ in }, presentSchedulePicker: @escaping (Bool, @escaping (Int32, Bool) -> Void) -> Void, presentTimerPicker: @escaping (@escaping (Int32) -> Void) -> Void, getCaptionPanelView: @escaping () -> TGCaptionPanelView?, dismissedWithResult: @escaping () -> Void = {}, finishedTransitionIn: @escaping () -> Void = {}) { let presentationData = context.sharedContext.currentPresentationData.with { $0 } let legacyController = LegacyController(presentation: .custom, theme: presentationData.theme) legacyController.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .portrait, compactSize: .portrait) @@ -92,9 +91,9 @@ public func presentedLegacyCamera(context: AccountContext, peer: Peer?, chatLoca controller.inhibitDocumentCaptions = false if let peer { - controller.recipientName = EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder) + controller.recipientName = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder) if peer.id != context.account.peerId { - if peer is TelegramUser { + if case .user = peer { controller.hasTimer = hasSchedule } controller.hasSilentPosting = true diff --git a/submodules/TelegramUI/Components/LiveLocationHeaderPanelComponent/BUILD b/submodules/TelegramUI/Components/LiveLocationHeaderPanelComponent/BUILD index fa7ab63ca6..61888dcbd4 100644 --- a/submodules/TelegramUI/Components/LiveLocationHeaderPanelComponent/BUILD +++ b/submodules/TelegramUI/Components/LiveLocationHeaderPanelComponent/BUILD @@ -15,7 +15,6 @@ swift_library( "//submodules/TelegramPresentationData", "//submodules/AccountContext", "//submodules/TelegramCore", - "//submodules/Postbox", "//submodules/Components/ComponentDisplayAdapters", "//submodules/TelegramUIPreferences", "//submodules/SSignalKit/SwiftSignalKit", diff --git a/submodules/TelegramUI/Components/LiveLocationHeaderPanelComponent/Sources/LiveLocationHeaderPanelComponent.swift b/submodules/TelegramUI/Components/LiveLocationHeaderPanelComponent/Sources/LiveLocationHeaderPanelComponent.swift index 4b3d93258b..325d2c451b 100644 --- a/submodules/TelegramUI/Components/LiveLocationHeaderPanelComponent/Sources/LiveLocationHeaderPanelComponent.swift +++ b/submodules/TelegramUI/Components/LiveLocationHeaderPanelComponent/Sources/LiveLocationHeaderPanelComponent.swift @@ -141,7 +141,7 @@ public final class LiveLocationHeaderPanelComponent: Component { } if let beginTimeAndTimeout { - items.append(LocationBroadcastActionSheetItem(context: component.context, peer: peer, title: EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), beginTimestamp: beginTimeAndTimeout.0, timeout: beginTimeAndTimeout.1, strings: presentationData.strings, action: { [weak self] in + items.append(LocationBroadcastActionSheetItem(context: component.context, peer: EnginePeer(peer), title: EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), beginTimestamp: beginTimeAndTimeout.0, timeout: beginTimeAndTimeout.1, strings: presentationData.strings, action: { [weak self] in dismissAction() guard let self, let component = self.component, let controller = component.controller() else { diff --git a/submodules/TelegramUI/Components/LiveLocationHeaderPanelComponent/Sources/LocationBroadcastActionSheetItem.swift b/submodules/TelegramUI/Components/LiveLocationHeaderPanelComponent/Sources/LocationBroadcastActionSheetItem.swift index 30bdac8506..105be70e18 100644 --- a/submodules/TelegramUI/Components/LiveLocationHeaderPanelComponent/Sources/LocationBroadcastActionSheetItem.swift +++ b/submodules/TelegramUI/Components/LiveLocationHeaderPanelComponent/Sources/LocationBroadcastActionSheetItem.swift @@ -3,7 +3,6 @@ import UIKit import AsyncDisplayKit import Display import TelegramCore -import Postbox import TelegramPresentationData import AccountContext import LiveLocationTimerNode @@ -11,14 +10,14 @@ import AvatarNode public class LocationBroadcastActionSheetItem: ActionSheetItem { public let context: AccountContext - public let peer: Peer + public let peer: EnginePeer public let title: String public let beginTimestamp: Double public let timeout: Double public let strings: PresentationStrings public let action: () -> Void - public init(context: AccountContext, peer: Peer, title: String, beginTimestamp: Double, timeout: Double, strings: PresentationStrings, action: @escaping () -> Void) { + public init(context: AccountContext, peer: EnginePeer, title: String, beginTimestamp: Double, timeout: Double, strings: PresentationStrings, action: @escaping () -> Void) { self.context = context self.peer = peer self.title = title @@ -105,7 +104,7 @@ public class LocationBroadcastActionSheetItemNode: ActionSheetItemNode { let textColor: UIColor = self.theme.primaryTextColor self.label.attributedText = NSAttributedString(string: item.title, font: defaultFont, textColor: textColor) - self.avatarNode.setPeer(context: item.context, theme: (item.context.sharedContext.currentPresentationData.with { $0 }).theme, peer: EnginePeer(item.peer)) + self.avatarNode.setPeer(context: item.context, theme: (item.context.sharedContext.currentPresentationData.with { $0 }).theme, peer: item.peer) self.timerNode.update(backgroundColor: self.theme.controlAccentColor.withAlphaComponent(0.4), foregroundColor: self.theme.controlAccentColor, textColor: self.theme.controlAccentColor, beginTimestamp: item.beginTimestamp, timeout: Int32(item.timeout) == liveLocationIndefinitePeriod ? -1.0 : item.timeout, strings: item.strings) } diff --git a/submodules/TelegramUI/Components/MediaEditor/Sources/Drawing/DrawingLinkEntity.swift b/submodules/TelegramUI/Components/MediaEditor/Sources/Drawing/DrawingLinkEntity.swift index 684aa37810..69bab76f69 100644 --- a/submodules/TelegramUI/Components/MediaEditor/Sources/Drawing/DrawingLinkEntity.swift +++ b/submodules/TelegramUI/Components/MediaEditor/Sources/Drawing/DrawingLinkEntity.swift @@ -3,7 +3,6 @@ import UIKit import Display import AccountContext import TextFormat -import Postbox import TelegramCore public final class DrawingLinkEntity: DrawingEntity, Codable { @@ -121,7 +120,7 @@ public final class DrawingLinkEntity: DrawingEntity, Codable { self.style = try container.decode(Style.self, forKey: .style) if let webpageData = try container.decodeIfPresent(Data.self, forKey: .webpage) { - self.webpage = PostboxDecoder(buffer: MemoryBuffer(data: webpageData)).decodeRootObject() as? TelegramMediaWebpage + self.webpage = EnginePostboxDecoder(buffer: EngineMemoryBuffer(data: webpageData)).decodeRootObject() as? TelegramMediaWebpage } else { self.webpage = nil } @@ -157,7 +156,7 @@ public final class DrawingLinkEntity: DrawingEntity, Codable { try container.encodeIfPresent(self.largeMedia, forKey: .largeMedia) if let webpage = self.webpage { - let encoder = PostboxEncoder() + let encoder = EnginePostboxEncoder() encoder.encodeRootObject(webpage) let webpageData = encoder.makeData() try container.encode(webpageData, forKey: .webpage) diff --git a/submodules/TelegramUI/Components/MediaEditor/Sources/Drawing/DrawingLocationEntity.swift b/submodules/TelegramUI/Components/MediaEditor/Sources/Drawing/DrawingLocationEntity.swift index d9eb6d0ea4..5e144c7115 100644 --- a/submodules/TelegramUI/Components/MediaEditor/Sources/Drawing/DrawingLocationEntity.swift +++ b/submodules/TelegramUI/Components/MediaEditor/Sources/Drawing/DrawingLocationEntity.swift @@ -3,7 +3,6 @@ import UIKit import Display import AccountContext import TextFormat -import Postbox import TelegramCore public final class DrawingLocationEntity: DrawingEntity, Codable { @@ -106,13 +105,13 @@ public final class DrawingLocationEntity: DrawingEntity, Codable { self.hasCustomColor = try container.decodeIfPresent(Bool.self, forKey: .hasCustomColor) ?? false if let locationData = try container.decodeIfPresent(Data.self, forKey: .location) { - self.location = PostboxDecoder(buffer: MemoryBuffer(data: locationData)).decodeRootObject() as! TelegramMediaMap + self.location = EnginePostboxDecoder(buffer: EngineMemoryBuffer(data: locationData)).decodeRootObject() as! TelegramMediaMap } else { fatalError() } if let iconData = try container.decodeIfPresent(Data.self, forKey: .icon) { - self.icon = PostboxDecoder(buffer: MemoryBuffer(data: iconData)).decodeRootObject() as? TelegramMediaFile + self.icon = EnginePostboxDecoder(buffer: EngineMemoryBuffer(data: iconData)).decodeRootObject() as? TelegramMediaFile } self.queryId = try container.decodeIfPresent(Int64.self, forKey: .queryId) @@ -136,13 +135,13 @@ public final class DrawingLocationEntity: DrawingEntity, Codable { try container.encode(self.color, forKey: .color) try container.encode(self.hasCustomColor, forKey: .hasCustomColor) - var encoder = PostboxEncoder() + var encoder = EnginePostboxEncoder() encoder.encodeRootObject(self.location) let locationData = encoder.makeData() try container.encode(locationData, forKey: .location) if let icon = self.icon { - encoder = PostboxEncoder() + encoder = EnginePostboxEncoder() encoder.encodeRootObject(icon) let iconData = encoder.makeData() try container.encode(iconData, forKey: .icon) diff --git a/submodules/TelegramUI/Components/MediaEditor/Sources/Drawing/DrawingWeatherEntity.swift b/submodules/TelegramUI/Components/MediaEditor/Sources/Drawing/DrawingWeatherEntity.swift index ed4f63ef73..cfdaef8cb8 100644 --- a/submodules/TelegramUI/Components/MediaEditor/Sources/Drawing/DrawingWeatherEntity.swift +++ b/submodules/TelegramUI/Components/MediaEditor/Sources/Drawing/DrawingWeatherEntity.swift @@ -3,7 +3,6 @@ import UIKit import Display import AccountContext import TextFormat -import Postbox import TelegramCore public final class DrawingWeatherEntity: DrawingEntity, Codable { @@ -101,7 +100,7 @@ public final class DrawingWeatherEntity: DrawingEntity, Codable { self.hasCustomColor = try container.decodeIfPresent(Bool.self, forKey: .hasCustomColor) ?? false if let iconData = try container.decodeIfPresent(Data.self, forKey: .icon) { - self.icon = PostboxDecoder(buffer: MemoryBuffer(data: iconData)).decodeRootObject() as? TelegramMediaFile + self.icon = EnginePostboxDecoder(buffer: EngineMemoryBuffer(data: iconData)).decodeRootObject() as? TelegramMediaFile } self.referenceDrawingSize = try container.decode(CGSize.self, forKey: .referenceDrawingSize) @@ -123,9 +122,9 @@ public final class DrawingWeatherEntity: DrawingEntity, Codable { try container.encode(self.color, forKey: .color) try container.encode(self.hasCustomColor, forKey: .hasCustomColor) - var encoder = PostboxEncoder() + var encoder = EnginePostboxEncoder() if let icon = self.icon { - encoder = PostboxEncoder() + encoder = EnginePostboxEncoder() encoder.encodeRootObject(icon) let iconData = encoder.makeData() try container.encode(iconData, forKey: .icon) diff --git a/submodules/TelegramUI/Components/MediaEditor/Sources/DrawingMessageRenderer.swift b/submodules/TelegramUI/Components/MediaEditor/Sources/DrawingMessageRenderer.swift index e0d6fa0fbd..38447c846e 100644 --- a/submodules/TelegramUI/Components/MediaEditor/Sources/DrawingMessageRenderer.swift +++ b/submodules/TelegramUI/Components/MediaEditor/Sources/DrawingMessageRenderer.swift @@ -3,7 +3,6 @@ import UIKit import AsyncDisplayKit import Display import SwiftSignalKit -import Postbox import TelegramCore import TelegramPresentationData import AccountContext @@ -83,7 +82,7 @@ public final class DrawingWallpaperRenderer { public final class DrawingMessageRenderer { final class ContainerNode: ASDisplayNode { private let context: AccountContext - private let messages: [Message] + private let messages: [EngineMessage] private let isNight: Bool private let isOverlay: Bool private let isLink: Bool @@ -96,7 +95,7 @@ public final class DrawingMessageRenderer { init( context: AccountContext, - messages: [Message], + messages: [EngineMessage], isNight: Bool = false, isOverlay: Bool = false, isLink: Bool = false, @@ -223,17 +222,17 @@ public final class DrawingMessageRenderer { let avatarHeaderItem: ListViewItemHeader? if let author = self.messages.first?.author { - let avatarPeer: Peer - if let peer = self.messages.first!.peers[author.id] { + let avatarPeer: EnginePeer + if let peer = self.messages.first!.enginePeers[author.id] { avatarPeer = peer } else { avatarPeer = author } - avatarHeaderItem = self.context.sharedContext.makeChatMessageAvatarHeaderItem(context: self.context, timestamp: self.messages.first?.timestamp ?? 0, peer: avatarPeer, message: self.messages.first!, theme: theme, strings: presentationData.strings, wallpaper: presentationData.chatWallpaper, fontSize: presentationData.chatFontSize, chatBubbleCorners: chatBubbleCorners, dateTimeFormat: presentationData.dateTimeFormat, nameOrder: presentationData.nameDisplayOrder) + avatarHeaderItem = self.context.sharedContext.makeChatMessageAvatarHeaderItem(context: self.context, timestamp: self.messages.first?.timestamp ?? 0, peer: avatarPeer._asPeer(), message: self.messages.first!._asMessage(), theme: theme, strings: presentationData.strings, wallpaper: presentationData.chatWallpaper, fontSize: presentationData.chatFontSize, chatBubbleCorners: chatBubbleCorners, dateTimeFormat: presentationData.dateTimeFormat, nameOrder: presentationData.nameDisplayOrder) } else { avatarHeaderItem = nil } - let items: [ListViewItem] = [self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, messages: self.messages, theme: theme, strings: presentationData.strings, wallpaper: presentationData.theme.chat.defaultWallpaper, fontSize: presentationData.chatFontSize, chatBubbleCorners: chatBubbleCorners, dateTimeFormat: presentationData.dateTimeFormat, nameOrder: presentationData.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: nil, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil)] + let items: [ListViewItem] = [self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, messages: self.messages.map { $0._asMessage() }, theme: theme, strings: presentationData.strings, wallpaper: presentationData.theme.chat.defaultWallpaper, fontSize: presentationData.chatFontSize, chatBubbleCorners: chatBubbleCorners, dateTimeFormat: presentationData.dateTimeFormat, nameOrder: presentationData.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: nil, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false, rank: nil, rankRole: nil)] let inset: CGFloat = 16.0 var leftInset: CGFloat = 37.0 @@ -356,15 +355,15 @@ public final class DrawingMessageRenderer { } private let context: AccountContext - private let messages: [Message] - + private let messages: [EngineMessage] + private let dayContainerNode: ContainerNode private let nightContainerNode: ContainerNode private let overlayContainerNode: ContainerNode - + public init( context: AccountContext, - messages: [Message], + messages: [EngineMessage], parentView: UIView, isLink: Bool = false, isGift: Bool = false, diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/CreateLinkScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/CreateLinkScreen.swift index 32b6146976..30dc339a9a 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/CreateLinkScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/CreateLinkScreen.swift @@ -497,7 +497,7 @@ private final class CreateLinkSheetComponent: CombinedComponent { let completion = controller.completion - let renderer = DrawingMessageRenderer(context: self.context, messages: [message], parentView: controller.view, isLink: true) + let renderer = DrawingMessageRenderer(context: self.context, messages: [EngineMessage(message)], parentView: controller.view, isLink: true) renderer.render(completion: { result in completion( CreateLinkScreen.Result( diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/EditStories.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/EditStories.swift index 2f2b0b57ea..471c075009 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/EditStories.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/EditStories.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import Display import SwiftSignalKit -import Postbox import TelegramCore import AccountContext import TextFormat @@ -51,7 +50,7 @@ public extension MediaEditorScreenImpl { duration = file.duration } let symlinkPath = data.path + ".mp4" - if fileSize(symlinkPath) == nil { + if engineFileSize(symlinkPath) == nil { let _ = try? FileManager.default.linkItem(atPath: data.path, toPath: symlinkPath) } return .single(nil) @@ -183,9 +182,9 @@ public extension MediaEditorScreenImpl { case let .image(image, dimensions): updateProgressImpl?(0.0) - 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 imageData = compressImageToJPEG(image, quality: 0.7, tempFilePath: tempFile.path) { update((context.engine.messages.editStory(peerId: peer.id, id: storyItem.id, media: .image(dimensions: dimensions, data: imageData, stickers: result.stickers), mediaAreas: result.mediaAreas, text: updatedText, entities: updatedEntities, privacy: nil) @@ -208,8 +207,8 @@ public extension MediaEditorScreenImpl { updateProgressImpl?(0.0) if let valuesData = try? JSONEncoder().encode(values) { - let data = MemoryBuffer(data: valuesData) - let digest = MemoryBuffer(data: data.md5Digest()) + let data = EngineMemoryBuffer(data: valuesData) + let digest = EngineMemoryBuffer(data: data.md5Digest()) let adjustments = VideoMediaResourceAdjustments(data: data, digest: digest, isStory: true) let resource: TelegramMediaResource @@ -222,13 +221,13 @@ public extension MediaEditorScreenImpl { resource = VideoLibraryMediaResource(localIdentifier: localIdentifier, conversion: .compress(adjustments)) } - let tempFile = TempBox.shared.tempFile(fileName: "file") + let tempFile = EngineTempBox.shared.tempFile(fileName: "file") defer { - TempBox.shared.dispose(tempFile) + EngineTempBox.shared.dispose(tempFile) } let firstFrameImageData = firstFrameImage.flatMap { compressImageToJPEG($0, quality: 0.6, tempFilePath: tempFile.path) } - let firstFrameFile = firstFrameImageData.flatMap { data -> TempBoxFile? in - let file = TempBox.shared.tempFile(fileName: "image.jpg") + let firstFrameFile = firstFrameImageData.flatMap { data -> EngineTempBoxFile? in + let file = EngineTempBox.shared.tempFile(fileName: "image.jpg") if let _ = try? data.write(to: URL(fileURLWithPath: file.path)) { return file } else { diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift index bf33c6725c..1a30ad00b4 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift @@ -3785,7 +3785,7 @@ public final class MediaEditorScreenImpl: ViewController, MediaEditorScreen, UID guard let self else { return } - let renderer = DrawingMessageRenderer(context: self.context, messages: messages, parentView: self.view, isGift: isGift, wallpaperDayColor: wallpaperColors.0, wallpaperNightColor: wallpaperColors.1) + let renderer = DrawingMessageRenderer(context: self.context, messages: messages.map(EngineMessage.init), parentView: self.view, isGift: isGift, wallpaperDayColor: wallpaperColors.0, wallpaperNightColor: wallpaperColors.1) renderer.render(completion: { result in if isDraft, let existingEntityView = self.entitiesView.getView(where: { entityView in if let stickerEntityView = entityView as? DrawingStickerEntityView { diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoChatListPaneNode/Sources/PeerInfoChatListPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoChatListPaneNode/Sources/PeerInfoChatListPaneNode.swift index 16a1c5d10e..7c2686c79b 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoChatListPaneNode/Sources/PeerInfoChatListPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoChatListPaneNode/Sources/PeerInfoChatListPaneNode.swift @@ -4,7 +4,6 @@ import AsyncDisplayKit import Display import TelegramCore import SwiftSignalKit -import Postbox import TelegramPresentationData import AccountContext import ContextUI @@ -488,7 +487,7 @@ public final class PeerInfoChatListPaneNode: ASDisplayNode, PeerInfoPaneNode, AS } } - public func ensureMessageIsVisible(id: MessageId) { + public func ensureMessageIsVisible(id: EngineMessage.Id) { } public func scrollToTop() -> Bool { @@ -508,7 +507,7 @@ public final class PeerInfoChatListPaneNode: ASDisplayNode, PeerInfoPaneNode, AS public func brieflyDisableTouchActions() { } - public func findLoadedMessage(id: MessageId) -> Message? { + public func findLoadedMessage(id: EngineMessage.Id) -> EngineMessage? { return nil } @@ -521,7 +520,7 @@ public final class PeerInfoChatListPaneNode: ASDisplayNode, PeerInfoPaneNode, AS public func cancelPreviewGestures() { } - public func transitionNodeForGallery(messageId: MessageId, media: Media) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { + public func transitionNodeForGallery(messageId: EngineMessage.Id, media: EngineMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { return nil } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoChatPaneNode/Sources/PeerInfoChatPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoChatPaneNode/Sources/PeerInfoChatPaneNode.swift index de84f76dcd..b78538b44d 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoChatPaneNode/Sources/PeerInfoChatPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoChatPaneNode/Sources/PeerInfoChatPaneNode.swift @@ -3,7 +3,6 @@ import AsyncDisplayKit import Display import TelegramCore import SwiftSignalKit -import Postbox import TelegramPresentationData import AccountContext import TelegramStringFormatting @@ -141,7 +140,7 @@ public final class PeerInfoChatPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScro private var presentationData: PresentationData private var presentationDataDisposable: Disposable? - public init(context: AccountContext, chatLocation: ChatLocation, tag: MessageTags?, navigationController: @escaping () -> NavigationController?) { + public init(context: AccountContext, chatLocation: ChatLocation, tag: EngineMessage.Tags?, navigationController: @escaping () -> NavigationController?) { self.context = context self.navigationController = navigationController self.presentationData = context.sharedContext.currentPresentationData.with { $0 } @@ -224,7 +223,7 @@ public final class PeerInfoChatPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScro self.presentationDataDisposable?.dispose() } - public func ensureMessageIsVisible(id: MessageId) { + public func ensureMessageIsVisible(id: EngineMessage.Id) { } public func scrollToTop() -> Bool { @@ -238,7 +237,7 @@ public final class PeerInfoChatPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScro public func brieflyDisableTouchActions() { } - public func findLoadedMessage(id: MessageId) -> Message? { + public func findLoadedMessage(id: EngineMessage.Id) -> EngineMessage? { return nil } @@ -254,7 +253,7 @@ public final class PeerInfoChatPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScro public func cancelPreviewGestures() { } - public func transitionNodeForGallery(messageId: MessageId, media: Media) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { + public func transitionNodeForGallery(messageId: EngineMessage.Id, media: EngineMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { return nil } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoPaneNode/Sources/PeerInfoPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoPaneNode/Sources/PeerInfoPaneNode.swift index 964e7ba8b2..9fa63eaa2c 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoPaneNode/Sources/PeerInfoPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoPaneNode/Sources/PeerInfoPaneNode.swift @@ -1,5 +1,4 @@ import SwiftSignalKit -import Postbox import TelegramCore import AsyncDisplayKit import UIKit @@ -109,12 +108,12 @@ public protocol PeerInfoPaneNode: ASDisplayNode { func scrollToTop() -> Bool func transferVelocity(_ velocity: CGFloat) func cancelPreviewGestures() - func findLoadedMessage(id: MessageId) -> Message? - func transitionNodeForGallery(messageId: MessageId, media: Media) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? + func findLoadedMessage(id: EngineMessage.Id) -> EngineMessage? + func transitionNodeForGallery(messageId: EngineMessage.Id, media: EngineMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? func addToTransitionSurface(view: UIView) func updateHiddenMedia() func updateSelectedMessages(animated: Bool) - func ensureMessageIsVisible(id: MessageId) + func ensureMessageIsVisible(id: EngineMessage.Id) } public extension PeerInfoPaneNode { diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/ListItems/PeerInfoScreenCallListItem.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/ListItems/PeerInfoScreenCallListItem.swift index f85773787d..7f987fbf21 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/ListItems/PeerInfoScreenCallListItem.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/ListItems/PeerInfoScreenCallListItem.swift @@ -6,17 +6,17 @@ import TelegramPresentationData import ItemListAddressItem import SwiftSignalKit import AccountContext -import Postbox +import TelegramCore import PeerInfoUI import ItemListUI final class PeerInfoScreenCallListItem: PeerInfoScreenItem { let id: AnyHashable - let messages: [Message] - + let messages: [EngineMessage] + init( id: AnyHashable, - messages: [Message] + messages: [EngineMessage] ) { self.id = id self.messages = messages diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/ListItems/PeerInfoScreenPersonalChannelItem.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/ListItems/PeerInfoScreenPersonalChannelItem.swift index 02862baafc..74035b1f59 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/ListItems/PeerInfoScreenPersonalChannelItem.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/ListItems/PeerInfoScreenPersonalChannelItem.swift @@ -9,7 +9,6 @@ import TelegramStringFormatting import ContextUI import TelegramCore import ChatListUI -import Postbox import StoryContainerScreen import AvatarNode @@ -560,10 +559,10 @@ private final class PeerInfoScreenPersonalChannelItemNode: PeerInfoScreenItemNod let isLoading = item.data.isLoading if !isLoading, !item.data.topMessages.isEmpty { - index = EngineChatList.Item.Index.chatList(ChatListIndex(pinningIndex: nil, messageIndex: item.data.topMessages[0].index)) + index = EngineChatList.Item.Index.chatList(EngineChatListIndex(pinningIndex: nil, messageIndex: item.data.topMessages[0].index)) messages = item.data.topMessages } else { - index = EngineChatList.Item.Index.chatList(ChatListIndex(pinningIndex: nil, messageIndex: MessageIndex(id: MessageId(peerId: item.data.peer.peerId, namespace: Namespaces.Message.Cloud, id: 1), timestamp: 0))) + index = EngineChatList.Item.Index.chatList(EngineChatListIndex(pinningIndex: nil, messageIndex: EngineMessage.Index(id: EngineMessage.Id(peerId: item.data.peer.peerId, namespace: Namespaces.Message.Cloud, id: 1), timestamp: 0))) messages = [] } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoGifPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoGifPaneNode.swift index 45d5961580..c4fa7bddf6 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoGifPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoGifPaneNode.swift @@ -131,7 +131,7 @@ private final class VisualMediaItemNode: ASDisplayNode { if let media = media { if let file = media as? TelegramMediaFile { - if isMediaStreamable(message: item.message, media: file) { + if isMediaStreamable(message: EngineMessage(item.message), media: file) { self.interaction.openMessage(item.message) } else { self.progressPressed() @@ -235,7 +235,7 @@ private final class VisualMediaItemNode: ASDisplayNode { if let strongSelf = self, let (item, _, _, _) = strongSelf.item { strongSelf.resourceStatus = status - let isStreamable = isMediaStreamable(message: item.message, media: file) + let isStreamable = isMediaStreamable(message: EngineMessage(item.message), media: file) var statusState: RadialStatusNodeState = .none if isStreamable || file.isAnimated { @@ -751,7 +751,7 @@ final class PeerInfoGifPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScrollViewDe self.hiddenMediaDisposable?.dispose() } - func ensureMessageIsVisible(id: MessageId) { + func ensureMessageIsVisible(id: EngineMessage.Id) { let activeRect = self.scrollNode.bounds for item in self.mediaItems { if item.message.id == id { @@ -816,10 +816,10 @@ final class PeerInfoGifPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScrollViewDe } } - func findLoadedMessage(id: MessageId) -> Message? { + func findLoadedMessage(id: EngineMessage.Id) -> EngineMessage? { for item in self.mediaItems { if item.message.id == id { - return item.message + return EngineMessage(item.message) } } return nil @@ -881,7 +881,7 @@ final class PeerInfoGifPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScrollViewDe } } - func transitionNodeForGallery(messageId: MessageId, media: Media) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { + func transitionNodeForGallery(messageId: EngineMessage.Id, media: EngineMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { for item in self.mediaItems { if item.message.id == messageId { if let itemNode = self.visibleMediaItems[item.message.stableId] { diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoGroupsInCommonPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoGroupsInCommonPaneNode.swift index 483ae0b683..cb27d285c6 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoGroupsInCommonPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoGroupsInCommonPaneNode.swift @@ -4,7 +4,6 @@ import AsyncDisplayKit import Display import TelegramCore import SwiftSignalKit -import Postbox import TelegramPresentationData import AccountContext import ContextUI @@ -27,7 +26,7 @@ private struct GroupsInCommonListEntry: Comparable, Identifiable { var index: Int var peer: EnginePeer - var stableId: PeerId { + var stableId: EnginePeer.Id { return self.peer.id } @@ -63,7 +62,7 @@ private func preparedTransition(from fromEntries: [GroupsInCommonListEntry], to final class PeerInfoGroupsInCommonPaneNode: ASDisplayNode, PeerInfoPaneNode { private let context: AccountContext - private let peerId: PeerId + private let peerId: EnginePeer.Id private let chatControllerInteraction: ChatControllerInteraction private let openPeerContextAction: (Bool, EnginePeer, ASDisplayNode, ContextGesture?) -> Void private let groupsInCommonContext: GroupsInCommonContext @@ -106,7 +105,7 @@ final class PeerInfoGroupsInCommonPaneNode: ASDisplayNode, PeerInfoPaneNode { private var disposable: Disposable? - init(context: AccountContext, peerId: PeerId, chatControllerInteraction: ChatControllerInteraction, openPeerContextAction: @escaping (Bool, EnginePeer, ASDisplayNode, ContextGesture?) -> Void, groupsInCommonContext: GroupsInCommonContext) { + init(context: AccountContext, peerId: EnginePeer.Id, chatControllerInteraction: ChatControllerInteraction, openPeerContextAction: @escaping (Bool, EnginePeer, ASDisplayNode, ContextGesture?) -> Void, groupsInCommonContext: GroupsInCommonContext) { self.context = context self.peerId = peerId self.chatControllerInteraction = chatControllerInteraction @@ -180,7 +179,7 @@ final class PeerInfoGroupsInCommonPaneNode: ASDisplayNode, PeerInfoPaneNode { self.disposable?.dispose() } - func ensureMessageIsVisible(id: MessageId) { + func ensureMessageIsVisible(id: EngineMessage.Id) { } func scrollToTop() -> Bool { @@ -292,7 +291,7 @@ final class PeerInfoGroupsInCommonPaneNode: ASDisplayNode, PeerInfoPaneNode { transition.updateFrame(view: self.listMaskView, frame: listMaskFrame) } - func findLoadedMessage(id: MessageId) -> Message? { + func findLoadedMessage(id: EngineMessage.Id) -> EngineMessage? { return nil } @@ -308,7 +307,7 @@ final class PeerInfoGroupsInCommonPaneNode: ASDisplayNode, PeerInfoPaneNode { func cancelPreviewGestures() { } - func transitionNodeForGallery(messageId: MessageId, media: Media) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { + func transitionNodeForGallery(messageId: EngineMessage.Id, media: EngineMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { return nil } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoListPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoListPaneNode.swift index 5faf856184..774651c5c4 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoListPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoListPaneNode.swift @@ -188,7 +188,7 @@ final class PeerInfoListPaneNode: ASDisplayNode, PeerInfoPaneNode { self.playlistPreloadDisposable?.dispose() } - func ensureMessageIsVisible(id: MessageId) { + func ensureMessageIsVisible(id: EngineMessage.Id) { } @@ -482,7 +482,7 @@ final class PeerInfoListPaneNode: ASDisplayNode, PeerInfoPaneNode { self.listNode.scrollEnabled = !isScrollingLockedAtTop } - func findLoadedMessage(id: MessageId) -> Message? { + func findLoadedMessage(id: EngineMessage.Id) -> EngineMessage? { self.listNode.messageInCurrentHistoryView(id) } @@ -503,11 +503,12 @@ final class PeerInfoListPaneNode: ASDisplayNode, PeerInfoPaneNode { func cancelPreviewGestures() { } - func transitionNodeForGallery(messageId: MessageId, media: Media) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { + func transitionNodeForGallery(messageId: EngineMessage.Id, media: EngineMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { var transitionNode: (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? + let rawMedia = media._asMedia() self.listNode.forEachItemNode { itemNode in if let itemNode = itemNode as? ListMessageNode { - if let result = itemNode.transitionNode(id: messageId, media: media, adjustRect: false) { + if let result = itemNode.transitionNode(id: messageId, media: rawMedia, adjustRect: false) { transitionNode = result } } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoMembersPane.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoMembersPane.swift index 240e6fb2f4..82f9ed6b50 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoMembersPane.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoMembersPane.swift @@ -4,7 +4,6 @@ import AsyncDisplayKit import Display import TelegramCore import SwiftSignalKit -import Postbox import TelegramPresentationData import AccountContext import ContextUI @@ -37,7 +36,7 @@ enum PeerMembersListAction { private enum PeerMembersListEntryStableId: Hashable { case addMember - case peer(PeerId) + case peer(EnginePeer.Id) } private enum PeerMembersListEntry: Comparable, Identifiable { @@ -317,7 +316,7 @@ final class PeerInfoMembersPaneNode: ASDisplayNode, PeerInfoPaneNode { private var disposable: Disposable? - init(context: AccountContext, peerId: PeerId, membersContext: PeerInfoMembersContext, addMemberAction: @escaping () -> Void, action: @escaping (PeerInfoMember, PeerMembersListAction) -> Void) { + init(context: AccountContext, peerId: EnginePeer.Id, membersContext: PeerInfoMembersContext, addMemberAction: @escaping () -> Void, action: @escaping (PeerInfoMember, PeerMembersListAction) -> Void) { self.context = context self.membersContext = membersContext self.addMemberAction = addMemberAction @@ -394,7 +393,7 @@ final class PeerInfoMembersPaneNode: ASDisplayNode, PeerInfoPaneNode { self.disposable?.dispose() } - func ensureMessageIsVisible(id: MessageId) { + func ensureMessageIsVisible(id: EngineMessage.Id) { } func scrollToTop() -> Bool { @@ -542,7 +541,7 @@ final class PeerInfoMembersPaneNode: ASDisplayNode, PeerInfoPaneNode { transition.updateFrame(view: self.listMaskView, frame: listMaskFrame) } - func findLoadedMessage(id: MessageId) -> Message? { + func findLoadedMessage(id: EngineMessage.Id) -> EngineMessage? { return nil } @@ -558,7 +557,7 @@ final class PeerInfoMembersPaneNode: ASDisplayNode, PeerInfoPaneNode { func cancelPreviewGestures() { } - func transitionNodeForGallery(messageId: MessageId, media: Media) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { + func transitionNodeForGallery(messageId: EngineMessage.Id, media: EngineMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { return nil } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoRecommendedPeersPane.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoRecommendedPeersPane.swift index 4bb5725e15..c518841d85 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoRecommendedPeersPane.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/Panes/PeerInfoRecommendedPeersPane.swift @@ -5,7 +5,6 @@ import Display import ComponentFlow import TelegramCore import SwiftSignalKit -import Postbox import TelegramPresentationData import AccountContext import ContextUI @@ -31,7 +30,7 @@ private struct RecommendedPeersListTransaction { private enum RecommendedPeersListEntryStableId: Hashable { case addMember - case peer(PeerId) + case peer(EnginePeer.Id) } private enum RecommendedPeersListEntry: Comparable, Identifiable { @@ -152,7 +151,7 @@ final class PeerInfoRecommendedPeersPaneNode: ASDisplayNode, PeerInfoPaneNode { private var disposable: Disposable? - init(context: AccountContext, peerId: PeerId, chatControllerInteraction: ChatControllerInteraction, openPeerContextAction: @escaping (Bool, EnginePeer, ASDisplayNode, ContextGesture?) -> Void) { + init(context: AccountContext, peerId: EnginePeer.Id, chatControllerInteraction: ChatControllerInteraction, openPeerContextAction: @escaping (Bool, EnginePeer, ASDisplayNode, ContextGesture?) -> Void) { self.context = context self.chatControllerInteraction = chatControllerInteraction self.openPeerContextAction = openPeerContextAction @@ -208,7 +207,7 @@ final class PeerInfoRecommendedPeersPaneNode: ASDisplayNode, PeerInfoPaneNode { self.disposable?.dispose() } - func ensureMessageIsVisible(id: MessageId) { + func ensureMessageIsVisible(id: EngineMessage.Id) { } func scrollToTop() -> Bool { @@ -455,7 +454,7 @@ final class PeerInfoRecommendedPeersPaneNode: ASDisplayNode, PeerInfoPaneNode { }) } - func findLoadedMessage(id: MessageId) -> Message? { + func findLoadedMessage(id: EngineMessage.Id) -> EngineMessage? { return nil } @@ -471,7 +470,7 @@ final class PeerInfoRecommendedPeersPaneNode: ASDisplayNode, PeerInfoPaneNode { func cancelPreviewGestures() { } - func transitionNodeForGallery(messageId: MessageId, media: Media) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { + func transitionNodeForGallery(messageId: EngineMessage.Id, media: EngineMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { return nil } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderEditingContentNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderEditingContentNode.swift index dafef8e000..e9598a7c68 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderEditingContentNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderEditingContentNode.swift @@ -4,7 +4,6 @@ import AsyncDisplayKit import TelegramPresentationData import AccountContext import Display -import Postbox import TelegramCore import SwiftSignalKit @@ -49,7 +48,7 @@ final class PeerInfoHeaderEditingContentNode: ASDisplayNode { self.itemNodes[key]?.layer.addShakeAnimation() } - func update(width: CGFloat, safeInset: CGFloat, statusBarHeight: CGFloat, navigationHeight: CGFloat, isModalOverlay: Bool, peer: EnginePeer?, threadData: MessageHistoryThreadData?, chatLocation: ChatLocation, cachedData: CachedPeerData?, isContact: Bool, isSettings: Bool, presentationData: PresentationData, transition: ContainedViewLayoutTransition) -> CGFloat { + func update(width: CGFloat, safeInset: CGFloat, statusBarHeight: CGFloat, navigationHeight: CGFloat, isModalOverlay: Bool, peer: EnginePeer?, threadData: MessageHistoryThreadData?, chatLocation: ChatLocation, cachedData: EngineCachedPeerData?, isContact: Bool, isSettings: Bool, presentationData: PresentationData, transition: ContainedViewLayoutTransition) -> CGFloat { let avatarSize: CGFloat = isModalOverlay ? 200.0 : 100.0 let avatarFrame = CGRect(origin: CGPoint(x: floor((width - avatarSize) / 2.0), y: statusBarHeight + 22.0), size: CGSize(width: avatarSize, height: avatarSize)) transition.updateFrameAdditiveToCenter(node: self.avatarNode, frame: CGRect(origin: avatarFrame.center, size: CGSize())) diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift index e767664904..b0d90b7108 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import AsyncDisplayKit import Display -import Postbox import TelegramCore import AvatarNode import AccountContext @@ -493,7 +492,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { private var currentStatusIcon: CredibilityIcon? private var currentPanelStatusData: PeerInfoStatusData? - func update(width: CGFloat, containerHeight: CGFloat, containerInset: CGFloat, statusBarHeight: CGFloat, navigationHeight: CGFloat, isModalOverlay: Bool, isMediaOnly: Bool, contentOffset: CGFloat, paneContainerY: CGFloat, presentationData: PresentationData, peer: EnginePeer?, cachedData: CachedPeerData?, threadData: MessageHistoryThreadData?, peerNotificationSettings: TelegramPeerNotificationSettings?, threadNotificationSettings: TelegramPeerNotificationSettings?, globalNotificationSettings: EngineGlobalNotificationSettings?, statusData: PeerInfoStatusData?, panelStatusData: (PeerInfoStatusData?, PeerInfoStatusData?, CGFloat?), isSecretChat: Bool, isContact: Bool, isSettings: Bool, state: PeerInfoState, profileGiftsContext: ProfileGiftsContext?, screenData: PeerInfoScreenData?, isSearching: Bool, metrics: LayoutMetrics, deviceMetrics: DeviceMetrics, transition: ContainedViewLayoutTransition, additive: Bool, animateHeader: Bool) -> CGFloat { + func update(width: CGFloat, containerHeight: CGFloat, containerInset: CGFloat, statusBarHeight: CGFloat, navigationHeight: CGFloat, isModalOverlay: Bool, isMediaOnly: Bool, contentOffset: CGFloat, paneContainerY: CGFloat, presentationData: PresentationData, peer: EnginePeer?, cachedData: EngineCachedPeerData?, threadData: MessageHistoryThreadData?, peerNotificationSettings: TelegramPeerNotificationSettings?, threadNotificationSettings: TelegramPeerNotificationSettings?, globalNotificationSettings: EngineGlobalNotificationSettings?, statusData: PeerInfoStatusData?, panelStatusData: (PeerInfoStatusData?, PeerInfoStatusData?, CGFloat?), isSecretChat: Bool, isContact: Bool, isSettings: Bool, state: PeerInfoState, profileGiftsContext: ProfileGiftsContext?, screenData: PeerInfoScreenData?, isSearching: Bool, metrics: LayoutMetrics, deviceMetrics: DeviceMetrics, transition: ContainedViewLayoutTransition, additive: Bool, animateHeader: Bool) -> CGFloat { if self.appliedCustomNavigationContentNode !== self.customNavigationContentNode { if let previous = self.appliedCustomNavigationContentNode { ComponentTransition(transition).setAlpha(view: previous.view, alpha: 0.0, completion: { [weak previous] _ in diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoMembers.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoMembers.swift index 1e504b10fb..67d2a2d875 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoMembers.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoMembers.swift @@ -14,8 +14,8 @@ enum PeerInfoMemberRole { enum PeerInfoMember: Equatable { case channelMember(participant: RenderedChannelParticipant, storyStats: PeerStoryStats?) case legacyGroupMember(peer: RenderedPeer, role: PeerInfoMemberRole, invitedBy: PeerId?, presence: TelegramUserPresence?, storyStats: PeerStoryStats?, rank: String?) - case account(peer: RenderedPeer) - + case account(peer: EngineRenderedPeer) + var id: PeerId { switch self { case let .channelMember(participant, _): @@ -26,7 +26,7 @@ enum PeerInfoMember: Equatable { return peer.peerId } } - + var peer: EnginePeer { switch self { case let .channelMember(participant, _): @@ -34,7 +34,7 @@ enum PeerInfoMember: Equatable { case let .legacyGroupMember(peer, _, _, _, _, _): return EnginePeer(peer.peers[peer.peerId]!) case let .account(peer): - return EnginePeer(peer.peers[peer.peerId]!) + return peer.peer! } } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoPaneContainerNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoPaneContainerNode.swift index 6496e23c80..97789b516e 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoPaneContainerNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoPaneContainerNode.swift @@ -4,7 +4,6 @@ import AsyncDisplayKit import Display import SwiftSignalKit import TelegramPresentationData -import Postbox import TelegramCore import AccountContext import ContextUI @@ -411,7 +410,7 @@ private final class PeerInfoPendingPane { openPeerContextAction: @escaping (Bool, EnginePeer, ASDisplayNode, ContextGesture?) -> Void, openAddMemberAction: @escaping () -> Void, requestPerformPeerMemberAction: @escaping (PeerInfoMember, PeerMembersListAction) -> Void, - peerId: PeerId, + peerId: EnginePeer.Id, chatLocation: ChatLocation, chatLocationContextHolder: Atomic, sharedMediaFromForumTopic: (EnginePeer.Id, Int64)?, @@ -582,7 +581,7 @@ private final class PeerInfoPendingPane { final class PeerInfoPaneContainerNode: ASDisplayNode, ASGestureRecognizerDelegate { private let context: AccountContext - private let peerId: PeerId + private let peerId: EnginePeer.Id private let chatLocation: ChatLocation private let chatLocationContextHolder: Atomic private let isMediaOnly: Bool @@ -657,7 +656,7 @@ final class PeerInfoPaneContainerNode: ASDisplayNode, ASGestureRecognizerDelegat private let initialPaneKey: PeerInfoPaneKey? - init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal)?, peerId: PeerId, chatLocation: ChatLocation, sharedMediaFromForumTopic: (EnginePeer.Id, Int64)?, chatLocationContextHolder: Atomic, isMediaOnly: Bool, initialPaneKey: PeerInfoPaneKey?, initialStoryFolderId: Int64?, initialGiftCollectionId: Int64?, switchToMediaTarget: PeerInfoSwitchToMediaTarget?) { + init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal)?, peerId: EnginePeer.Id, chatLocation: ChatLocation, sharedMediaFromForumTopic: (EnginePeer.Id, Int64)?, chatLocationContextHolder: Atomic, isMediaOnly: Bool, initialPaneKey: PeerInfoPaneKey?, initialStoryFolderId: Int64?, initialGiftCollectionId: Int64?, switchToMediaTarget: PeerInfoSwitchToMediaTarget?) { self.context = context self.updatedPresentationData = updatedPresentationData self.peerId = peerId @@ -823,7 +822,7 @@ final class PeerInfoPaneContainerNode: ASDisplayNode, ASGestureRecognizerDelegat } } - func findLoadedMessage(id: MessageId) -> Message? { + func findLoadedMessage(id: EngineMessage.Id) -> EngineMessage? { return self.currentPane?.node.findLoadedMessage(id: id) } @@ -831,11 +830,11 @@ final class PeerInfoPaneContainerNode: ASDisplayNode, ASGestureRecognizerDelegat self.currentPane?.node.updateHiddenMedia() } - func transitionNodeForGallery(messageId: MessageId, media: Media) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { + func transitionNodeForGallery(messageId: EngineMessage.Id, media: EngineMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { return self.currentPane?.node.transitionNodeForGallery(messageId: messageId, media: media) } - func updateSelectedMessageIds(_ selectedMessageIds: Set?, animated: Bool) { + func updateSelectedMessageIds(_ selectedMessageIds: Set?, animated: Bool) { for (_, pane) in self.currentPanes { pane.node.updateSelectedMessages(animated: animated) } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoProfileItems.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoProfileItems.swift index be77e08247..e98f24d93c 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoProfileItems.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoProfileItems.swift @@ -4,7 +4,6 @@ import Display import AccountContext import TelegramPresentationData import TelegramCore -import Postbox import PeerInfoUI import TextFormat import PhoneNumberFormat @@ -41,9 +40,9 @@ func infoItems( context: AccountContext, presentationData: PresentationData, interaction: PeerInfoInteraction, - reactionSourceMessageId: MessageId?, + reactionSourceMessageId: EngineMessage.Id?, canDeleteReaction: Bool, - callMessages: [Message], + callMessages: [EngineMessage], chatLocation: ChatLocation, isOpenedFromChat: Bool, isMyProfile: Bool diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index 43b382ee37..356ab64269 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -209,7 +209,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro let peerId: PeerId let isOpenedFromChat: Bool let videoCallsEnabled: Bool - let callMessages: [Message] + let callMessages: [EngineMessage] let chatLocation: ChatLocation let chatLocationContextHolder: Atomic let switchToStoryFolder: Int64? @@ -356,7 +356,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro isOpenedFromChat: Bool, reactionSourceMessageId: MessageId?, sourceMessageId: MessageId?, - callMessages: [Message], + callMessages: [EngineMessage], isSettings: Bool, isMyProfile: Bool, hintGroupInCommon: PeerId?, @@ -1120,11 +1120,11 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro var foundGalleryMessage: Message? if let searchContentNode = strongSelf.searchDisplayController?.contentNode as? ChatHistorySearchContainerNode { if let galleryMessage = searchContentNode.messageForGallery(message.id) { - strongSelf.context.engine.messages.ensureMessagesAreLocallyAvailable(messages: [EngineMessage(galleryMessage)]) - foundGalleryMessage = galleryMessage + strongSelf.context.engine.messages.ensureMessagesAreLocallyAvailable(messages: [galleryMessage]) + foundGalleryMessage = galleryMessage._asMessage() } } - if foundGalleryMessage == nil, let galleryMessage = strongSelf.paneContainerNode.findLoadedMessage(id: message.id) { + if foundGalleryMessage == nil, let galleryMessage = strongSelf.paneContainerNode.findLoadedMessage(id: message.id)?._asMessage() { foundGalleryMessage = galleryMessage } @@ -6360,7 +6360,7 @@ public final class PeerInfoScreenImpl: ViewController, PeerInfoScreen, KeyShortc private let isOpenedFromChat: Bool private let reactionSourceMessageId: MessageId? private let sourceMessageId: MessageId? - private let callMessages: [Message] + private let callMessages: [EngineMessage] let isSettings: Bool let isMyProfile: Bool private let hintGroupInCommon: PeerId? @@ -6448,7 +6448,7 @@ public final class PeerInfoScreenImpl: ViewController, PeerInfoScreen, KeyShortc isOpenedFromChat: Bool, reactionSourceMessageId: MessageId?, sourceMessageId: MessageId? = nil, - callMessages: [Message], + callMessages: [EngineMessage], isSettings: Bool = false, isMyProfile: Bool = false, hintGroupInCommon: PeerId? = nil, diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreenOpenChat.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreenOpenChat.swift index dcb6207397..aca8dd3fa1 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreenOpenChat.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreenOpenChat.swift @@ -81,7 +81,7 @@ extension PeerInfoScreenNode { } func openDeleteReaction(messageId: EngineMessage.Id) { - guard let authorPeer = self.data?.peer?._asPeer(), let navigationController = self.controller?.navigationController as? NavigationController else { + guard let authorPeer = self.data?.peer, let navigationController = self.controller?.navigationController as? NavigationController else { return } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreenOpenMessage.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreenOpenMessage.swift index ebaea8f357..5e1350aaed 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreenOpenMessage.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreenOpenMessage.swift @@ -3,7 +3,6 @@ import UIKit import Display import AccountContext import SwiftSignalKit -import Postbox import TelegramCore import LegacyMediaPickerUI import ChatHistorySearchContainerNode @@ -11,27 +10,27 @@ import MediaResources import TelegramUIPreferences extension PeerInfoScreenNode { - func openMessage(id: MessageId) -> Bool { + func openMessage(id: EngineMessage.Id) -> Bool { guard let controller = self.controller, let navigationController = controller.navigationController as? NavigationController else { return false } - var foundGalleryMessage: Message? + var foundGalleryMessage: EngineMessage? if let searchContentNode = self.searchDisplayController?.contentNode as? ChatHistorySearchContainerNode { if let galleryMessage = searchContentNode.messageForGallery(id) { - self.context.engine.messages.ensureMessagesAreLocallyAvailable(messages: [EngineMessage(galleryMessage)]) + self.context.engine.messages.ensureMessagesAreLocallyAvailable(messages: [galleryMessage]) foundGalleryMessage = galleryMessage } } if foundGalleryMessage == nil, let galleryMessage = self.paneContainerNode.findLoadedMessage(id: id) { foundGalleryMessage = galleryMessage } - + guard let galleryMessage = foundGalleryMessage else { return false } self.view.endEditing(true) - - return self.context.sharedContext.openChatMessage(OpenChatMessageParams(context: self.context, chatLocation: self.chatLocation, chatFilterTag: nil, chatLocationContextHolder: self.chatLocationContextHolder, message: galleryMessage, standalone: false, reverseMessageGalleryOrder: true, navigationController: navigationController, dismissInput: { [weak self] in + + return self.context.sharedContext.openChatMessage(OpenChatMessageParams(context: self.context, chatLocation: self.chatLocation, chatFilterTag: nil, chatLocationContextHolder: self.chatLocationContextHolder, message: galleryMessage._asMessage(), standalone: false, reverseMessageGalleryOrder: true, navigationController: navigationController, dismissInput: { [weak self] in self?.view.endEditing(true) }, present: { [weak self] c, a, _ in self?.controller?.present(c, in: .window(.root), with: a, blockInteraction: true) @@ -39,7 +38,7 @@ extension PeerInfoScreenNode { guard let strongSelf = self else { return nil } - return strongSelf.paneContainerNode.transitionNodeForGallery(messageId: messageId, media: media) + return strongSelf.paneContainerNode.transitionNodeForGallery(messageId: messageId, media: EngineMedia(media)) }, addToTransitionSurface: { [weak self] view in guard let strongSelf = self else { return @@ -105,16 +104,17 @@ extension PeerInfoScreenNode { } var mediaReference: AnyMediaReference? - for media in message.media { - if let image = media as? TelegramMediaImage { + for media in message.engineMedia { + if case let .image(image) = media { mediaReference = AnyMediaReference.standalone(media: image) - } else if let file = media as? TelegramMediaFile { + } else if case let .file(file) = media { mediaReference = AnyMediaReference.standalone(media: file) } } - + if let mediaReference = mediaReference, let peer = message.peers[message.id.peerId] { - legacyMediaEditor(context: strongSelf.context, peer: peer, threadTitle: message.associatedThreadInfo?.title, media: mediaReference, mode: .draw, initialCaption: NSAttributedString(), snapshots: snapshots, transitionCompletion: { + legacyMediaEditor(context: strongSelf.context, peer: EnginePeer(peer), threadTitle: message.associatedThreadInfo?.title, media: mediaReference, mode: .draw, initialCaption: NSAttributedString(), snapshots: snapshots, transitionCompletion: { + transitionCompletion() }, getCaptionPanelView: { return nil diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreenOpenURL.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreenOpenURL.swift index 99088bd1e9..270236ed71 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreenOpenURL.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreenOpenURL.swift @@ -3,7 +3,6 @@ import UIKit import Display import AccountContext import SwiftSignalKit -import Postbox import TelegramCore import OpenInExternalAppUI import PresentationDataUtils @@ -134,19 +133,16 @@ extension PeerInfoScreenNode { } disposable.set((resolveSignal |> take(1) - |> mapToSignal { peer -> Signal in - return .single(peer?._asPeer()) - } |> deliverOnMainQueue).start(next: { [weak self] peer in if let strongSelf = self { if let peer = peer { var navigation = navigation if case .default = navigation { - if let peer = peer as? TelegramUser, peer.botInfo != nil { + if case let .user(user) = peer, user.botInfo != nil { navigation = .chat(textInputState: nil, subject: nil, peekData: nil) } } - strongSelf.openResolved(.peer(peer, navigation)) + strongSelf.openResolved(.peer(peer._asPeer(), navigation)) } else { strongSelf.controller?.present(textAlertController(context: strongSelf.context, updatedPresentationData: strongSelf.controller?.updatedPresentationData, title: nil, text: strongSelf.presentationData.strings.Resolve_ErrorNotFound, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root)) } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoSettingsItems.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoSettingsItems.swift index 32aa2f6619..c5f58f4bb5 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoSettingsItems.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoSettingsItems.swift @@ -4,7 +4,6 @@ import Display import AccountContext import TelegramPresentationData import TelegramCore -import Postbox import PhoneNumberFormat import ItemListUI import SwiftSignalKit @@ -128,7 +127,7 @@ func settingsItems(data: PeerInfoScreenData?, context: AccountContext, presentat return context.engine.stickers.resolveInlineStickers(fileIds: fileIds) } )) - let member: PeerInfoMember = .account(peer: RenderedPeer(peer: peer)) + let member: PeerInfoMember = .account(peer: EngineRenderedPeer(peer: peer)) items[.accounts]!.append(PeerInfoScreenMemberItem(id: member.id, context: mappedContext, enclosingPeer: nil, member: member, badge: badgeCount > 0 ? "\(compactNumericCountString(Int(badgeCount), decimalSeparator: presentationData.dateTimeFormat.decimalSeparator))" : nil, isAccount: true, action: { action in switch action { case .open: diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PresentAddMembers.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PresentAddMembers.swift index 2ff46cd6a4..98af424b97 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PresentAddMembers.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PresentAddMembers.swift @@ -4,7 +4,6 @@ import Display import AccountContext import TelegramPresentationData import SwiftSignalKit -import Postbox import TelegramCore import InviteLinksUI import SendInviteLinkScreen @@ -12,7 +11,7 @@ import UndoUI import PresentationDataUtils public func presentAddMembersImpl(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal)?, parentController: ViewController, groupPeer: EnginePeer, selectAddMemberDisposable: MetaDisposable, addMemberDisposable: MetaDisposable) { - let members: Promise<[PeerId]> = Promise() + let members: Promise<[EnginePeer.Id]> = Promise() if groupPeer.id.namespace == Namespaces.Peer.CloudChannel { /*var membersDisposable: Disposable? let (disposable, _) = context.peerChannelMemberCategoriesContextsManager.recent(postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerView.peerId, updated: { listState in @@ -29,7 +28,7 @@ public func presentAddMembersImpl(context: AccountContext, updatedPresentationDa |> take(1) |> deliverOnMainQueue).startStandalone(next: { [weak parentController] recentIds in var createInviteLinkImpl: (() -> Void)? - var confirmationImpl: ((PeerId) -> Signal)? + var confirmationImpl: ((EnginePeer.Id) -> Signal)? let _ = confirmationImpl var options: [ContactListAdditionalOption] = [] let presentationData = updatedPresentationData?.initial ?? context.sharedContext.currentPresentationData.with { $0 } @@ -88,8 +87,8 @@ public func presentAddMembersImpl(context: AccountContext, updatedPresentationDa } } - let addMembers: ([ContactListPeerId]) -> Signal<[(PeerId, AddChannelMemberError)], NoError> = { members -> Signal<[(PeerId, AddChannelMemberError)], NoError> in - let memberIds = members.compactMap { contact -> PeerId? in + let addMembers: ([ContactListPeerId]) -> Signal<[(EnginePeer.Id, AddChannelMemberError)], NoError> = { members -> Signal<[(EnginePeer.Id, AddChannelMemberError)], NoError> in + let memberIds = members.compactMap { contact -> EnginePeer.Id? in switch contact { case let .peer(peerId): return peerId @@ -100,23 +99,23 @@ public func presentAddMembersImpl(context: AccountContext, updatedPresentationDa return context.account.postbox.multiplePeersView(memberIds) |> take(1) |> deliverOnMainQueue - |> mapToSignal { view -> Signal<[(PeerId, AddChannelMemberError)], NoError> in + |> mapToSignal { view -> Signal<[(EnginePeer.Id, AddChannelMemberError)], NoError> in if groupPeer.id.namespace == Namespaces.Peer.CloudChannel { if memberIds.count == 1 { return context.peerChannelMemberCategoriesContextsManager.addMember(engine: context.engine, peerId: groupPeer.id, memberId: memberIds[0]) - |> map { _ -> [(PeerId, AddChannelMemberError)] in + |> map { _ -> [(EnginePeer.Id, AddChannelMemberError)] in } - |> then(Signal<[(PeerId, AddChannelMemberError)], AddChannelMemberError>.single([])) - |> `catch` { error -> Signal<[(PeerId, AddChannelMemberError)], NoError> in + |> then(Signal<[(EnginePeer.Id, AddChannelMemberError)], AddChannelMemberError>.single([])) + |> `catch` { error -> Signal<[(EnginePeer.Id, AddChannelMemberError)], NoError> in return .single([(memberIds[0], error)]) } } else { return context.peerChannelMemberCategoriesContextsManager.addMembersAllowPartial(engine: context.engine, peerId: groupPeer.id, memberIds: memberIds) } } else { - var signals: [Signal<(PeerId, AddChannelMemberError)?, NoError>] = [] + var signals: [Signal<(EnginePeer.Id, AddChannelMemberError)?, NoError>] = [] for memberId in memberIds { - let signal: Signal<(PeerId, AddChannelMemberError)?, NoError> = context.engine.peers.addGroupMember(peerId: groupPeer.id, memberId: memberId) + let signal: Signal<(EnginePeer.Id, AddChannelMemberError)?, NoError> = context.engine.peers.addGroupMember(peerId: groupPeer.id, memberId: memberId) |> mapError { error -> AddChannelMemberError in switch error { case .generic: @@ -132,16 +131,16 @@ public func presentAddMembersImpl(context: AccountContext, updatedPresentationDa } } |> ignoreValues - |> map { _ -> (PeerId, AddChannelMemberError)? in + |> map { _ -> (EnginePeer.Id, AddChannelMemberError)? in } - |> then(Signal<(PeerId, AddChannelMemberError)?, AddChannelMemberError>.single(nil)) - |> `catch` { error -> Signal<(PeerId, AddChannelMemberError)?, NoError> in + |> then(Signal<(EnginePeer.Id, AddChannelMemberError)?, AddChannelMemberError>.single(nil)) + |> `catch` { error -> Signal<(EnginePeer.Id, AddChannelMemberError)?, NoError> in return .single((memberId, error)) } signals.append(signal) } return combineLatest(signals) - |> map { values -> [(PeerId, AddChannelMemberError)] in + |> map { values -> [(EnginePeer.Id, AddChannelMemberError)] in return values.compactMap { $0 } } } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift index bab566ae72..1e7f1d5365 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift @@ -4,7 +4,6 @@ import Display import ComponentFlow import TelegramCore import SwiftSignalKit -import Postbox import TelegramPresentationData import PresentationDataUtils import AccountContext @@ -68,7 +67,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr } private let context: AccountContext - private let peerId: PeerId + private let peerId: EnginePeer.Id private let profileGiftsCollections: ProfileGiftsCollectionsContext private let profileGifts: ProfileGiftsContext private let canManage: Bool @@ -132,7 +131,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr private let collectionsMaxCount: Int - public init(context: AccountContext, peerId: PeerId, chatControllerInteraction: ChatControllerInteraction, profileGiftsCollections: ProfileGiftsCollectionsContext, profileGifts: ProfileGiftsContext, canManage: Bool, canGift: Bool, initialGiftCollectionId: Int64?) { + public init(context: AccountContext, peerId: EnginePeer.Id, chatControllerInteraction: ChatControllerInteraction, profileGiftsCollections: ProfileGiftsCollectionsContext, profileGifts: ProfileGiftsContext, canManage: Bool, canGift: Bool, initialGiftCollectionId: Int64?) { self.context = context self.peerId = peerId self.chatControllerInteraction = chatControllerInteraction @@ -347,7 +346,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr } } - public func ensureMessageIsVisible(id: MessageId) { + public func ensureMessageIsVisible(id: EngineMessage.Id) { } public func scrollToTop() -> Bool { @@ -1456,7 +1455,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr self.updateScrolling(transition: ComponentTransition(transition)) } - public func findLoadedMessage(id: MessageId) -> Message? { + public func findLoadedMessage(id: EngineMessage.Id) -> EngineMessage? { return nil } @@ -1472,7 +1471,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr public func cancelPreviewGestures() { } - public func transitionNodeForGallery(messageId: MessageId, media: Media) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { + public func transitionNodeForGallery(messageId: EngineMessage.Id, media: EngineMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { return nil } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift index b5ada88e29..997fd23427 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift @@ -2881,7 +2881,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr } } - public func ensureMessageIsVisible(id: MessageId) { + public func ensureMessageIsVisible(id: EngineMessage.Id) { } private func requestHistoryAroundVisiblePosition(synchronous: Bool, reloadAtTop: Bool, animated: Bool = true) { @@ -3299,7 +3299,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr self.itemGrid.brieflyDisableTouchActions() } - public func findLoadedMessage(id: MessageId) -> Message? { + public func findLoadedMessage(id: EngineMessage.Id) -> EngineMessage? { return nil } @@ -3313,7 +3313,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr public func cancelPreviewGestures() { } - public func transitionNodeForGallery(messageId: MessageId, media: Media) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { + public func transitionNodeForGallery(messageId: EngineMessage.Id, media: EngineMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { return nil } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoVisualMediaPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoVisualMediaPaneNode.swift index 3497f3aa66..5c073eee63 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoVisualMediaPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoVisualMediaPaneNode.swift @@ -1777,7 +1777,7 @@ public final class PeerInfoVisualMediaPaneNode: ASDisplayNode, PeerInfoPaneNode, let _ = updateVisualMediaStoredState(engine: self.context.engine, peerId: self.peerId, messageTag: self.stateTag, state: VisualMediaStoredState(zoomLevel: level.rawValue)).start() } - public func ensureMessageIsVisible(id: MessageId) { + public func ensureMessageIsVisible(id: EngineMessage.Id) { } private func requestHistoryAroundVisiblePosition(synchronous: Bool, reloadAtTop: Bool) { @@ -1880,7 +1880,7 @@ public final class PeerInfoVisualMediaPaneNode: ASDisplayNode, PeerInfoPaneNode, self.itemGrid.brieflyDisableTouchActions() } - public func findLoadedMessage(id: MessageId) -> Message? { + public func findLoadedMessage(id: EngineMessage.Id) -> EngineMessage? { guard let items = self.items else { return nil } @@ -1889,7 +1889,7 @@ public final class PeerInfoVisualMediaPaneNode: ASDisplayNode, PeerInfoPaneNode, continue } if item.message.id == id { - return item.message + return EngineMessage(item.message) } } return nil @@ -1929,7 +1929,7 @@ public final class PeerInfoVisualMediaPaneNode: ASDisplayNode, PeerInfoPaneNode, } } - public func transitionNodeForGallery(messageId: MessageId, media: Media) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { + public func transitionNodeForGallery(messageId: EngineMessage.Id, media: EngineMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { var foundItemLayer: SparseItemGridLayer? self.itemGrid.forEachVisibleItem { item in guard let itemLayer = item.layer as? ItemLayer else { diff --git a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/AutomaticBusinessMessageListItemComponent.swift b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/AutomaticBusinessMessageListItemComponent.swift index 12d3e1bca0..cf6436f827 100644 --- a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/AutomaticBusinessMessageListItemComponent.swift +++ b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/AutomaticBusinessMessageListItemComponent.swift @@ -7,7 +7,6 @@ import TelegramPresentationData import AppBundle import ChatListUI import AccountContext -import Postbox import TelegramCore final class GreetingMessageListItemComponent: Component { @@ -226,7 +225,7 @@ final class GreetingMessageListItemComponent: Component { context: component.context, chatListLocation: .chatList(groupId: .root), filterData: nil, - index: EngineChatList.Item.Index.chatList(ChatListIndex(pinningIndex: nil, messageIndex: component.message.index)), + index: EngineChatList.Item.Index.chatList(EngineChatListIndex(pinningIndex: nil, messageIndex: component.message.index)), content: .peer(ChatListItemContent.PeerData( messages: [component.message], peer: EngineRenderedPeer(peer: component.accountPeer), diff --git a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/AutomaticBusinessMessageSetupScreen.swift b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/AutomaticBusinessMessageSetupScreen.swift index fe66d1577d..c7d3799a5d 100644 --- a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/AutomaticBusinessMessageSetupScreen.swift +++ b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/AutomaticBusinessMessageSetupScreen.swift @@ -4,7 +4,6 @@ import Photos import Display import AsyncDisplayKit import SwiftSignalKit -import Postbox import TelegramCore import TelegramPresentationData import TelegramUIPreferences diff --git a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/QuickReplySetupScreen.swift b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/QuickReplySetupScreen.swift index 355728c104..a2dd3ce948 100644 --- a/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/QuickReplySetupScreen.swift +++ b/submodules/TelegramUI/Components/Settings/AutomaticBusinessMessageSetupScreen/Sources/QuickReplySetupScreen.swift @@ -4,7 +4,6 @@ import Photos import Display import AsyncDisplayKit import SwiftSignalKit -import Postbox import TelegramCore import TelegramPresentationData import TelegramUIPreferences @@ -256,7 +255,7 @@ final class QuickReplySetupScreenComponent: Component { context: listNode.context, chatListLocation: .chatList(groupId: .root), filterData: nil, - index: EngineChatList.Item.Index.chatList(ChatListIndex(pinningIndex: nil, messageIndex: MessageIndex(id: MessageId(peerId: listNode.context.account.peerId, namespace: 0, id: 0), timestamp: 0))), + index: EngineChatList.Item.Index.chatList(EngineChatListIndex(pinningIndex: nil, messageIndex: EngineMessage.Index(id: EngineMessage.Id(peerId: listNode.context.account.peerId, namespace: 0, id: 0), timestamp: 0))), content: .peer(ChatListItemContent.PeerData( messages: [item.topMessage], peer: EngineRenderedPeer(peer: accountPeer), diff --git a/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/BUILD b/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/BUILD index ed399a9fc6..cb4272bce9 100644 --- a/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/BUILD +++ b/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/BUILD @@ -12,7 +12,6 @@ swift_library( deps = [ "//submodules/AsyncDisplayKit", "//submodules/Display", - "//submodules/Postbox", "//submodules/TelegramCore", "//submodules/SSignalKit/SwiftSignalKit", "//submodules/TelegramPresentationData", diff --git a/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/Sources/ChatbotSetupScreen.swift b/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/Sources/ChatbotSetupScreen.swift index c387c29fa6..b31513a97f 100644 --- a/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/Sources/ChatbotSetupScreen.swift +++ b/submodules/TelegramUI/Components/Settings/ChatbotSetupScreen/Sources/ChatbotSetupScreen.swift @@ -4,7 +4,6 @@ import Photos import Display import AsyncDisplayKit import SwiftSignalKit -import Postbox import TelegramCore import TelegramPresentationData import TelegramUIPreferences diff --git a/submodules/TelegramUI/Components/Settings/QuickReactionSetupController/Sources/QuickReactionSetupController.swift b/submodules/TelegramUI/Components/Settings/QuickReactionSetupController/Sources/QuickReactionSetupController.swift index 38cbafd692..2cb32a6233 100644 --- a/submodules/TelegramUI/Components/Settings/QuickReactionSetupController/Sources/QuickReactionSetupController.swift +++ b/submodules/TelegramUI/Components/Settings/QuickReactionSetupController/Sources/QuickReactionSetupController.swift @@ -3,7 +3,6 @@ import UIKit import Display import AsyncDisplayKit import SwiftSignalKit -import Postbox import TelegramCore import TelegramPresentationData import TelegramUIPreferences @@ -58,7 +57,7 @@ private enum QuickReactionSetupControllerEntry: ItemListNodeEntry { } case demoHeader(String) - case demoMessage(wallpaper: TelegramWallpaper, fontSize: PresentationFontSize, bubbleCorners: PresentationChatBubbleCorners, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, availableReactions: AvailableReactions?, reaction: MessageReaction.Reaction?, accountPeer: Peer?) + case demoMessage(wallpaper: TelegramWallpaper, fontSize: PresentationFontSize, bubbleCorners: PresentationChatBubbleCorners, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, availableReactions: AvailableReactions?, reaction: MessageReaction.Reaction?, accountPeer: EnginePeer?) case demoDescription(String) case quickReaction(String, MessageReaction.Reaction, AvailableReactions) case quickReactionDescription(String) @@ -160,7 +159,7 @@ private enum QuickReactionSetupControllerEntry: ItemListNodeEntry { nameDisplayOrder: nameDisplayOrder, availableReactions: availableReactions, reaction: reaction, - accountPeer: accountPeer, + accountPeer: accountPeer?._asPeer(), toggleReaction: { arguments.toggleReaction() } @@ -187,7 +186,7 @@ private func quickReactionSetupControllerEntries( reactionSettings: ReactionSettings, state: QuickReactionSetupControllerState, isPremium: Bool, - accountPeer: Peer? + accountPeer: EnginePeer? ) -> [QuickReactionSetupControllerEntry] { var entries: [QuickReactionSetupControllerEntry] = [] @@ -275,7 +274,7 @@ public func quickReactionSetupController( reactionSettings: settings, state: state, isPremium: isPremium, - accountPeer: accountPeer?._asPeer() + accountPeer: accountPeer ) let controllerState = ItemListControllerState( @@ -310,7 +309,7 @@ public func quickReactionSetupController( ) |> take(1) |> deliverOnMainQueue).start(next: { settings, availableReactions in - var currentSelectedFileId: MediaId? + var currentSelectedFileId: EngineMedia.Id? switch settings.quickReaction { case .builtin: if let availableReactions = availableReactions { @@ -320,7 +319,7 @@ public func quickReactionSetupController( } } case let .custom(fileId): - currentSelectedFileId = MediaId(namespace: Namespaces.Media.CloudFile, id: fileId) + currentSelectedFileId = EngineMedia.Id(namespace: Namespaces.Media.CloudFile, id: fileId) case .stars: if let availableReactions = availableReactions { if let reaction = availableReactions.reactions.first(where: { $0.value == settings.quickReaction }) { @@ -330,7 +329,7 @@ public func quickReactionSetupController( } } - var selectedItems = Set() + var selectedItems = Set() if let currentSelectedFileId = currentSelectedFileId { selectedItems.insert(currentSelectedFileId) } diff --git a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/ShareWithPeersScreenState.swift b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/ShareWithPeersScreenState.swift index 816ed17c06..26748749b2 100644 --- a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/ShareWithPeersScreenState.swift +++ b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/ShareWithPeersScreenState.swift @@ -4,7 +4,6 @@ import TelegramCore import AccountContext import TelegramUIPreferences import TemporaryCachedPeerDataManager -import Postbox public extension ShareWithPeersScreen { final class State { @@ -650,9 +649,9 @@ public extension ShareWithPeersScreen { } } - let queryTokens = stringIndexTokens(searchQuery ?? "", transliteration: .combined) - func peerMatchesTokens(peer: EnginePeer, tokens: [ValueBoxKey]) -> Bool { - if matchStringIndexTokens(peer.indexName._asIndexName().indexTokens, with: queryTokens) { + let queryTokens = context.engine.peers.tokenizeSearchString(string: searchQuery ?? "", transliteration: .combined) + func peerMatchesTokens(peer: EnginePeer, tokens: [EngineDataBuffer]) -> Bool { + if context.engine.peers.matchSearchTokens(peer.indexName._asIndexName().indexTokens, with: queryTokens) { return true } return false diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift index 36cce86732..bcebfb8be8 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift @@ -28,7 +28,6 @@ import TelegramPresentationData import LegacyInstantVideoController import TelegramPresentationData import ChatPresentationInterfaceState -import Postbox import OverlayStatusController import PresentationDataUtils import TextFieldComponent @@ -786,7 +785,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { call.sendMessage(fromId: sendAsPeer?.peer.id, isAdmin: isAdmin, text: text.string, entities: entities, paidStars: sendPaidMessageStars?.value) - component.storyItemSharedState.replyDrafts.removeValue(forKey: StoryId(peerId: peerId, id: focusedItem.storyItem.id)) + component.storyItemSharedState.replyDrafts.removeValue(forKey: EngineStoryId(peerId: peerId, id: focusedItem.storyItem.id)) inputPanelView.clearSendMessageInput(updateState: true) self.currentLiveStreamMessageStars = nil @@ -813,7 +812,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { guard let peerId = focusedItem.peerId else { return } - let focusedStoryId = StoryId(peerId: peerId, id: focusedItem.storyItem.id) + let focusedStoryId = EngineStoryId(peerId: peerId, id: focusedItem.storyItem.id) guard let inputPanelView = view.inputPanel.view as? MessageInputPanelComponent.View else { return } @@ -830,7 +829,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { let waveformBuffer = audio.waveform.makeBitstream() - var messageAttributes: [MessageAttribute] = [] + var messageAttributes: [EngineMessage.Attribute] = [] if let sendPaidMessageStars = component.slice.additionalPeerData.sendPaidMessageStars { messageAttributes.append(PaidStarsMessageAttribute(stars: sendPaidMessageStars, postponeSending: false)) } @@ -865,7 +864,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { } } }) - component.storyItemSharedState.replyDrafts.removeValue(forKey: StoryId(peerId: peerId, id: focusedItem.storyItem.id)) + component.storyItemSharedState.replyDrafts.removeValue(forKey: EngineStoryId(peerId: peerId, id: focusedItem.storyItem.id)) inputPanelView.clearSendMessageInput(updateState: true) self.currentInputMode = .text @@ -894,7 +893,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { guard let peerId = focusedItem.peerId else { return } - let focusedStoryId = StoryId(peerId: peerId, id: focusedItem.storyItem.id) + let focusedStoryId = EngineStoryId(peerId: peerId, id: focusedItem.storyItem.id) let peer = component.slice.effectivePeer let controller = component.controller() as? StoryContainerScreen @@ -954,7 +953,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { guard let peerId = focusedItem.peerId else { return } - let focusedStoryId = StoryId(peerId: peerId, id: focusedItem.storyItem.id) + let focusedStoryId = EngineStoryId(peerId: peerId, id: focusedItem.storyItem.id) let peer = component.slice.effectivePeer let controller = component.controller() as? StoryContainerScreen @@ -1067,7 +1066,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { fileAttributes.append(.Sticker(displayText: "", packReference: nil, maskData: nil)) fileAttributes.append(.ImageSize(size: PixelDimensions(size))) - let 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: "image/webp", size: Int64(data.count), 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: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "image/webp", size: Int64(data.count), attributes: fileAttributes, alternativeRepresentations: []) let message = EnqueueMessage.message(text: "", attributes: [], inlineStickers: [:], mediaReference: .standalone(media: media), threadId: nil, replyToMessageId: nil, replyToStoryId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: []) self.presentPaidMessageAlertIfNeeded(view: view, completion: { [weak self] in @@ -1095,7 +1094,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { guard let peerId = focusedItem.peerId else { return } - let focusedStoryId = StoryId(peerId: peerId, id: focusedItem.storyItem.id) + let focusedStoryId = EngineStoryId(peerId: peerId, id: focusedItem.storyItem.id) let _ = (component.context.engine.data.get( TelegramEngine.EngineData.Item.Peer.Peer(id: peerId) ) @@ -1325,7 +1324,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { } let shareController = component.context.sharedContext.makeShareController(context: component.context, params: ShareControllerParams( - subject: .media(AnyMediaReference.standalone(media: TelegramMediaStory(storyId: StoryId(peerId: peerId, id: focusedItem.storyItem.id), isMention: false)), nil), + subject: .media(AnyMediaReference.standalone(media: TelegramMediaStory(storyId: EngineStoryId(peerId: peerId, id: focusedItem.storyItem.id), isMention: false)), nil), preferredAction: preferredAction ?? .default, externalShare: false, immediateExternalShare: false, @@ -1648,7 +1647,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { guard let peerId = focusedItem.peerId else { return } - component.storyItemSharedState.replyDrafts.removeValue(forKey: StoryId(peerId: peerId, id: focusedItem.storyItem.id)) + component.storyItemSharedState.replyDrafts.removeValue(forKey: EngineStoryId(peerId: peerId, id: focusedItem.storyItem.id)) } enum AttachMenuSubject { @@ -1666,7 +1665,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { guard let peerId = focusedItem.peerId else { return } - let focusedStoryId = StoryId(peerId: peerId, id: focusedItem.storyItem.id) + let focusedStoryId = EngineStoryId(peerId: peerId, id: focusedItem.storyItem.id) guard let inputPanelView = view.inputPanel.view as? MessageInputPanelComponent.View else { return } @@ -1939,7 +1938,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { guard let view, let component = view.component else { return } - var messageAttributes: [MessageAttribute] = [] + var messageAttributes: [EngineMessage.Attribute] = [] if let sendPaidMessageStars = component.slice.additionalPeerData.sendPaidMessageStars { messageAttributes.append(PaidStarsMessageAttribute(stars: sendPaidMessageStars, postponeSending: false)) } @@ -2243,7 +2242,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { view: StoryItemSetContainerComponent.View, peer: EnginePeer, replyToMessageId: EngineMessage.Id?, - replyToStoryId: StoryId?, + replyToStoryId: EngineStoryId?, subject: MediaPickerScreenImpl.Subject = .assets(nil, .default), saveEditedPhotos: Bool, bannedSendPhotos: (Int32, Bool)?, @@ -2317,7 +2316,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { present(controller, mediaPickerContext) } - private func presentOldMediaPicker(view: StoryItemSetContainerComponent.View, peer: EnginePeer, replyMessageId: EngineMessage.Id?, replyToStoryId: StoryId?, fileMode: Bool, editingMedia: Bool, push: @escaping (ViewController) -> Void, completion: @escaping ([Any], Bool, Int32) -> Void) { + private func presentOldMediaPicker(view: StoryItemSetContainerComponent.View, peer: EnginePeer, replyMessageId: EngineMessage.Id?, replyToStoryId: EngineStoryId?, fileMode: Bool, editingMedia: Bool, push: @escaping (ViewController) -> Void, completion: @escaping ([Any], Bool, Int32) -> Void) { guard let component = view.component else { return } @@ -2450,7 +2449,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { }) } - private func presentFileGallery(view: StoryItemSetContainerComponent.View, peer: EnginePeer, replyMessageId: EngineMessage.Id?, replyToStoryId: StoryId?, editingMessage: Bool = false) { + private func presentFileGallery(view: StoryItemSetContainerComponent.View, peer: EnginePeer, replyMessageId: EngineMessage.Id?, replyToStoryId: EngineStoryId?, editingMessage: Bool = false) { self.presentOldMediaPicker(view: view, peer: peer, replyMessageId: replyMessageId, replyToStoryId: replyToStoryId, fileMode: true, editingMedia: editingMessage, push: { [weak view] c in view?.component?.controller()?.push(c) }, completion: { [weak self, weak view] signals, silentPosting, scheduleTime in @@ -2465,7 +2464,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { }) } - private func presentICloudFileGallery(view: StoryItemSetContainerComponent.View, peer: EnginePeer, replyMessageId: EngineMessage.Id?, replyToStoryId: StoryId?) { + private func presentICloudFileGallery(view: StoryItemSetContainerComponent.View, peer: EnginePeer, replyMessageId: EngineMessage.Id?, replyToStoryId: EngineStoryId?) { guard let component = view.component else { return } @@ -2581,7 +2580,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { // guard let peerId = focusedItem.peerId else { // return // } -// let focusedStoryId = StoryId(peerId: peerId, id: focusedItem.storyItem.id) +// let focusedStoryId = EngineStoryId(peerId: peerId, id: focusedItem.storyItem.id) // guard let inputPanelView = view.inputPanel.view as? MessageInputPanelComponent.View else { // return // } @@ -2641,7 +2640,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { // component.controller()?.push(controller) } - private func enqueueChatContextResult(view: StoryItemSetContainerComponent.View, peer: EnginePeer, replyMessageId: EngineMessage.Id?, storyId: StoryId?, results: ChatContextResultCollection, result: ChatContextResult, hideVia: Bool = false, closeMediaInput: Bool = false, silentPosting: Bool = false, scheduleTime: Int32? = nil, resetTextInputState: Bool = true) { + private func enqueueChatContextResult(view: StoryItemSetContainerComponent.View, peer: EnginePeer, replyMessageId: EngineMessage.Id?, storyId: EngineStoryId?, results: ChatContextResultCollection, result: ChatContextResult, hideVia: Bool = false, closeMediaInput: Bool = false, silentPosting: Bool = false, scheduleTime: Int32? = nil, resetTextInputState: Bool = true) { if !canSendMessagesToPeer(peer) { return } @@ -2694,7 +2693,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { } }, enqueueMediaMessages: { [weak self, weak view] signals in if let self, let view, !signals.isEmpty { - self.enqueueMediaMessages(view: view, peer: peer, replyToMessageId: nil, replyToStoryId: StoryId(peerId: peer.id, id: storyId), signals: signals, silentPosting: silentPosting, scheduleTime: scheduleTime) + self.enqueueMediaMessages(view: view, peer: peer, replyToMessageId: nil, replyToStoryId: EngineStoryId(peerId: peer.id, id: storyId), signals: signals, silentPosting: silentPosting, scheduleTime: scheduleTime) } }) }), activateOnDisplay: activateOnDisplay) @@ -2758,7 +2757,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { }) as? TGCaptionPanelView } - private func openCamera(view: StoryItemSetContainerComponent.View, peer: EnginePeer, replyToMessageId: EngineMessage.Id?, replyToStoryId: StoryId?, cameraView: TGAttachmentCameraView? = nil) { + private func openCamera(view: StoryItemSetContainerComponent.View, peer: EnginePeer, replyToMessageId: EngineMessage.Id?, replyToStoryId: EngineStoryId?, cameraView: TGAttachmentCameraView? = nil) { guard let component = view.component else { return } @@ -2816,7 +2815,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { let storeCapturedMedia = peer.id.namespace != Namespaces.Peer.SecretChat - presentedLegacyCamera(context: component.context, peer: peer._asPeer(), chatLocation: .peer(id: peer.id), cameraView: cameraView, menuController: nil, parentController: parentController, attachmentController: self.attachmentController, editingMedia: false, saveCapturedPhotos: storeCapturedMedia, mediaGrouping: true, initialCaption: inputText, hasSchedule: peer.id.namespace != Namespaces.Peer.SecretChat, enablePhoto: enablePhoto, enableVideo: enableVideo, sendMessagesWithSignals: { [weak self, weak view] signals, silentPosting, scheduleTime, parameters in + presentedLegacyCamera(context: component.context, peer: peer, chatLocation: .peer(id: peer.id), cameraView: cameraView, menuController: nil, parentController: parentController, attachmentController: self.attachmentController, editingMedia: false, saveCapturedPhotos: storeCapturedMedia, mediaGrouping: true, initialCaption: inputText, hasSchedule: peer.id.namespace != Namespaces.Peer.SecretChat, enablePhoto: enablePhoto, enableVideo: enableVideo, sendMessagesWithSignals: { [weak self, weak view] signals, silentPosting, scheduleTime, parameters in guard let self, let view else { return } @@ -2927,9 +2926,9 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { } private func transformEnqueueMessages(view: StoryItemSetContainerComponent.View, messages: [EnqueueMessage], silentPosting: Bool, scheduleTime: Int32? = nil) -> [EnqueueMessage] { - var focusedStoryId: StoryId? + var focusedStoryId: EngineStoryId? if let component = view.component, let peerId = component.slice.item.peerId { - focusedStoryId = StoryId(peerId: peerId, id: component.slice.item.storyItem.id) + focusedStoryId = EngineStoryId(peerId: peerId, id: component.slice.item.storyItem.id) } return messages.map { message in @@ -2963,7 +2962,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { attributes.append(OutgoingScheduleInfoMessageAttribute(scheduleTime: scheduleTime, repeatPeriod: nil)) } } - var messageAttributes: [MessageAttribute] = [] + var messageAttributes: [EngineMessage.Attribute] = [] if let component = view.component, let sendPaidMessageStars = component.slice.additionalPeerData.sendPaidMessageStars { messageAttributes.append(PaidStarsMessageAttribute(stars: sendPaidMessageStars, postponeSending: false)) } @@ -2992,7 +2991,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { } } - private func enqueueMediaMessages(view: StoryItemSetContainerComponent.View, peer: EnginePeer, replyToMessageId: EngineMessage.Id?, replyToStoryId: StoryId?, signals: [Any]?, silentPosting: Bool, scheduleTime: Int32? = nil, parameters: ChatSendMessageActionSheetController.SendParameters? = nil, getAnimatedTransitionSource: ((String) -> UIView?)? = nil, completion: @escaping () -> Void = {}) { + private func enqueueMediaMessages(view: StoryItemSetContainerComponent.View, peer: EnginePeer, replyToMessageId: EngineMessage.Id?, replyToStoryId: EngineStoryId?, signals: [Any]?, silentPosting: Bool, scheduleTime: Int32? = nil, parameters: ChatSendMessageActionSheetController.SendParameters? = nil, getAnimatedTransitionSource: ((String) -> UIView?)? = nil, completion: @escaping () -> Void = {}) { guard let component = view.component else { return } @@ -3183,7 +3182,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { }) } - func openPeerMention(view: StoryItemSetContainerComponent.View, name: String, sourceMessageId: MessageId? = nil) { + func openPeerMention(view: StoryItemSetContainerComponent.View, name: String, sourceMessageId: EngineMessage.Id? = nil) { guard let component = view.component, let parentController = component.controller() else { return } @@ -3233,16 +3232,14 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { } return .single(result) } - |> mapToSignal { peer -> Signal in - return .single(peer?._asPeer()) - } - |> deliverOnMainQueue).start(next: { [weak view] peer in + |> deliverOnMainQueue).start(next: { [weak view] enginePeer in guard let view, let component = view.component else { return } - if let peer = peer { + if let enginePeer = enginePeer { + let peer = enginePeer._asPeer() var navigation: ChatControllerInteractionNavigateToPeer - if let peer = peer as? TelegramUser, peer.botInfo == nil { + if case let .user(user) = enginePeer, user.botInfo == nil { navigation = .info(nil) } else { navigation = .chat(textInputState: nil, subject: nil, peekData: nil) @@ -3262,7 +3259,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { let peerId = component.slice.effectivePeer.id - var resolveSignal: Signal + var resolveSignal: Signal if let peerName = peerName { resolveSignal = component.context.engine.peers.resolvePeerByName(name: peerName, referrer: nil) |> mapToSignal { result -> Signal in @@ -3271,23 +3268,15 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { } return .single(result) } - |> mapToSignal { peer -> Signal in - if let peer = peer { - return .single(peer._asPeer()) - } else { - return .single(nil) - } - } } else { resolveSignal = component.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)) - |> mapToSignal { peer -> Signal in + |> mapToSignal { peer -> Signal in if let peer { return .single(peer) } else { return .never() } } - |> map { Optional($0._asPeer()) } } var cancelImpl: (() -> Void)? let presentationData = component.context.sharedContext.currentPresentationData.with { $0 } @@ -3338,7 +3327,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { let searchController = component.context.sharedContext.makeStorySearchController(context: component.context, scope: .query(nil, hashtag), listContext: nil) navigationController.pushViewController(searchController) } else { - let searchController = component.context.sharedContext.makeHashtagSearchController(context: component.context, peer: peer.flatMap(EnginePeer.init), query: hashtag, stories: true, forceDark: true) + let searchController = component.context.sharedContext.makeHashtagSearchController(context: component.context, peer: peer, query: hashtag, stories: true, forceDark: true) navigationController.pushViewController(searchController) } } @@ -3786,9 +3775,9 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) { useGesturePosition = true let action = { [weak self, weak view, weak controller] in let _ = ((context.engine.messages.getMessagesLoadIfNecessary([messageId], strategy: .cloud(skipLocal: true)) - |> mapToSignal { result -> Signal in + |> mapToSignal { result -> Signal in if case let .result(messages) = result { - return .single(messages.first) + return .single(messages.first.flatMap(EngineMessage.init)) } else { return .complete() } diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerEditGif.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerEditGif.swift index 741427088e..09cc1de5f5 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerEditGif.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerEditGif.swift @@ -17,7 +17,7 @@ extension ChatControllerImpl { let hasSchedule = self.presentationInterfaceState.subject != .scheduledMessages && peer.id.namespace != Namespaces.Peer.SecretChat && self.presentationInterfaceState.sendPaidMessageStars == nil legacyMediaEditor( context: self.context, - peer: peer, + peer: EnginePeer(peer), threadTitle: nil, media: file.abstract, mode: addCaption ? .caption : .default, diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift index d99dbe3ecd..f0efbdfb2d 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift @@ -1691,7 +1691,7 @@ extension ChatControllerImpl { if canSendMessagesHere { let _ = strongSelf.presentVoiceMessageDiscardAlert(action: { - if let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId) { + if let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId)?._asMessage() { strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState({ $0.withUpdatedReplyMessageSubject(ChatInterfaceState.ReplyMessageSubject( messageId: message.id, @@ -1756,7 +1756,7 @@ extension ChatControllerImpl { return } let _ = strongSelf.presentVoiceMessageDiscardAlert(action: { - if let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId) { + if let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId)?._asMessage() { strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { state in var entities: [MessageTextEntity] = [] for attribute in message.attributes { @@ -3485,7 +3485,7 @@ extension ChatControllerImpl { strongSelf.controllerInteraction?.callPeer(peerId, isVideo) } }, toggleMessageStickerStarred: { [weak self] messageId in - if let strongSelf = self, let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId) { + if let strongSelf = self, let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId)?._asMessage() { var stickerFile: TelegramMediaFile? for media in message.media { if let file = media as? TelegramMediaFile, file.isSticker { @@ -3647,7 +3647,7 @@ extension ChatControllerImpl { self.selectPollOptionFeedback?.success() }), forKey: id) }, requestStopPollInMessage: { [weak self] id in - guard let strongSelf = self, let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(id) else { + guard let strongSelf = self, let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(id)?._asMessage() else { return } @@ -5285,7 +5285,7 @@ extension ChatControllerImpl { } } - if let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(mappedId) { + if let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(mappedId)?._asMessage() { if toSubject.setupReply { Queue.mainQueue().after(0.1) { strongSelf.interfaceInteraction?.setupReplyMessage(mappedId, toSubject.subject, { _, f in f() }) diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerNavigateToMessage.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerNavigateToMessage.swift index 815a39f0e5..969ff0a103 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerNavigateToMessage.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerNavigateToMessage.swift @@ -1,6 +1,5 @@ import Foundation import UIKit -import Postbox import TelegramCore import SwiftSignalKit import Display @@ -14,8 +13,8 @@ import UndoUI extension ChatControllerImpl { func navigateToMessage( - fromId: MessageId, - id: MessageId, + fromId: EngineMessage.Id, + id: EngineMessage.Id, params: NavigateToMessageParams ) { var id = id @@ -67,7 +66,7 @@ extension ChatControllerImpl { } func navigateToMessage( - from fromId: MessageId?, + from fromId: EngineMessage.Id?, to messageLocation: NavigateToMessageLocation, scrollPosition: ListViewScrollPosition = .center(.bottom), rememberInStack: Bool = true, @@ -84,9 +83,9 @@ extension ChatControllerImpl { completion?() return } - var fromIndex: MessageIndex? + var fromIndex: EngineMessage.Index? - var fromMessage: Message? + var fromMessage: EngineMessage? if let fromId = fromId, let message = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(fromId) { fromIndex = message.index fromMessage = message @@ -114,8 +113,8 @@ extension ChatControllerImpl { if isPinnedMessages || forceNew, let messageId = messageLocation.messageId { let peerSignal: Signal - if forceNew, let fromMessage, let peer = fromMessage.peers[fromMessage.id.peerId] { - peerSignal = .single(EnginePeer(peer)) + if forceNew, let fromMessage, let peer = fromMessage.enginePeers[fromMessage.id.peerId] { + peerSignal = .single(peer) } else { peerSignal = self.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: messageId.peerId)) } @@ -125,11 +124,11 @@ extension ChatControllerImpl { |> `catch` { _ in return .single(.result([])) } - |> mapToSignal { result -> Signal<[Message], NoError> in + |> mapToSignal { result -> Signal<[EngineMessage], NoError> in guard case let .result(result) = result else { return .complete() } - return .single(result) + return .single(result.map(EngineMessage.init)) } ) |> deliverOnMainQueue).startStandalone(next: { [weak self] peer, messages in @@ -143,7 +142,7 @@ extension ChatControllerImpl { self.dismiss() let navigateToLocation: NavigateToChatControllerParams.Location - if let message = messages.first, let threadId = message.threadId, let channel = message.peers[message.id.peerId] as? TelegramChannel, channel.isForumOrMonoForum { + if let message = messages.first, let threadId = message.threadId, case let .channel(channel) = message.enginePeers[message.id.peerId], channel.isForumOrMonoForum { navigateToLocation = .replyThread(ChatReplyThreadMessage(peerId: peer.id, threadId: threadId, channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: false,maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false)) } else { navigateToLocation = .peer(peer) @@ -198,7 +197,7 @@ extension ChatControllerImpl { case let .index(index): searchLocation = .index(index) case .upperBound: - searchLocation = .index(MessageIndex.upperBound(peerId: chatLocation.peerId)) + searchLocation = .index(EngineMessage.Index.upperBound(peerId: chatLocation.peerId)) } var historyView: Signal @@ -206,9 +205,9 @@ extension ChatControllerImpl { historyView = preloadedChatHistoryViewForLocation(ChatHistoryLocationInput(content: .InitialSearch(subject: MessageHistoryInitialSearchSubject(location: searchLocation), count: 50, highlight: true, setupReply: false), id: 0), context: self.context, chatLocation: preloadChatLocation, subject: subject, chatLocationContextHolder: Atomic(value: nil), fixedCombinedReadStates: nil, tag: nil, additionalData: []) - var signal: Signal<(MessageIndex?, Bool), NoError> + var signal: Signal<(EngineMessage.Index?, Bool), NoError> signal = historyView - |> mapToSignal { historyView -> Signal<(MessageIndex?, Bool), NoError> in + |> mapToSignal { historyView -> Signal<(EngineMessage.Index?, Bool), NoError> in switch historyView { case .Loading: return .single((nil, true)) @@ -320,7 +319,7 @@ extension ChatControllerImpl { self.contentData?.historyNavigationStack.add(fromIndex) } - let scrollFromIndex: MessageIndex? + let scrollFromIndex: EngineMessage.Index? if let fromIndex = fromIndex { scrollFromIndex = fromIndex } else if let message = self.chatDisplayNode.historyNode.lastVisbleMesssage() { @@ -361,7 +360,7 @@ extension ChatControllerImpl { } if case let .id(_, params) = messageLocation, let timecode = params.timestamp { - let _ = self.controllerInteraction?.openMessage(message, OpenMessageParams(mode: .timecode(timecode))) + let _ = self.controllerInteraction?.openMessage(message._asMessage(), OpenMessageParams(mode: .timecode(timecode))) } } else if case let .index(index) = messageLocation, index.id.id == 0, index.timestamp > 0, case .scheduledMessages = self.presentationInterfaceState.subject { self.chatDisplayNode.historyNode.scrollToMessage(from: scrollFromIndex, to: index, animated: animated, scrollPosition: scrollPosition) @@ -393,7 +392,7 @@ extension ChatControllerImpl { searchLocation = .index(index) case .upperBound: if let peerId = self.chatLocation.peerId { - searchLocation = .index(MessageIndex.upperBound(peerId: peerId)) + searchLocation = .index(EngineMessage.Index.upperBound(peerId: peerId)) } else { searchLocation = .index(.absoluteUpperBound()) } @@ -401,9 +400,9 @@ extension ChatControllerImpl { var historyView: Signal historyView = preloadedChatHistoryViewForLocation(ChatHistoryLocationInput(content: .InitialSearch(subject: MessageHistoryInitialSearchSubject(location: searchLocation), count: 50, highlight: true, setupReply: setupReply), id: 0), context: self.context, chatLocation: self.chatLocation, subject: self.subject, chatLocationContextHolder: self.chatLocationContextHolder, fixedCombinedReadStates: nil, tag: nil, additionalData: []) - var signal: Signal<(MessageIndex?, Bool), NoError> + var signal: Signal<(EngineMessage.Index?, Bool), NoError> signal = historyView - |> mapToSignal { historyView -> Signal<(MessageIndex?, Bool), NoError> in + |> mapToSignal { historyView -> Signal<(EngineMessage.Index?, Bool), NoError> in switch historyView { case .Loading: return .single((nil, true)) @@ -521,9 +520,9 @@ extension ChatControllerImpl { } let historyView = preloadedChatHistoryViewForLocation(ChatHistoryLocationInput(content: .InitialSearch(subject: MessageHistoryInitialSearchSubject(location: searchLocation, quote: quote.flatMap { quote in MessageHistoryInitialSearchSubject.Quote(string: quote.string, offset: quote.offset) }, subject: subject), count: 50, highlight: true, setupReply: setupReply), id: 0), context: self.context, chatLocation: self.chatLocation, subject: self.subject, chatLocationContextHolder: self.chatLocationContextHolder, fixedCombinedReadStates: nil, tag: nil, additionalData: []) - var signal: Signal + var signal: Signal signal = historyView - |> mapToSignal { historyView -> Signal in + |> mapToSignal { historyView -> Signal in switch historyView { case .Loading: return .complete() diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerNavigationButtonAction.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerNavigationButtonAction.swift index 4777dc06af..2ad7598c76 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerNavigationButtonAction.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerNavigationButtonAction.swift @@ -1,6 +1,5 @@ import Foundation import UIKit -import Postbox import SwiftSignalKit import Display import AsyncDisplayKit @@ -476,7 +475,7 @@ extension ChatControllerImpl { if #available(iOS 13.0, *) { Task { @MainActor [weak self] in guard let peer = await context.engine.data.get( - TelegramEngine.EngineData.Item.Peer.Peer(id: PeerId(replyThreadMessage.threadId)) + TelegramEngine.EngineData.Item.Peer.Peer(id: EnginePeer.Id(replyThreadMessage.threadId)) ).get() else { return } @@ -623,7 +622,7 @@ extension ChatControllerImpl { } else { items.append(ActionSheetButtonItem(title: presentationData.strings.Cache_Clear("\(dataSizeString(totalSize, formatting: DataSizeStringFormatting(presentationData: presentationData)))").string, action: { let clearCategories = sizeIndex.keys.filter({ sizeIndex[$0]!.0 }) - var clearMediaIds = Set() + var clearMediaIds = Set() var media = stats.media if var categories = media[peerId] { @@ -639,11 +638,11 @@ extension ChatControllerImpl { media[peerId] = categories } - var clearResourceIds = Set() + var clearResourceIds = Set() for id in clearMediaIds { if let ids = stats.mediaResourceIds[id] { for resourceId in ids { - clearResourceIds.insert(resourceId) + clearResourceIds.insert(EngineMediaResource.Id(resourceId)) } } } diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenMessageContextMenu.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenMessageContextMenu.swift index 08750090f1..4b66aecd5c 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenMessageContextMenu.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenMessageContextMenu.swift @@ -1,7 +1,6 @@ import Foundation import UIKit import SwiftSignalKit -import Postbox import TelegramCore import AsyncDisplayKit import Display @@ -21,7 +20,7 @@ import PresentationDataUtils import ChatPresentationInterfaceState extension ChatControllerImpl { - func openMessageContextMenu(message: Message, selectAll: Bool, node: ASDisplayNode, frame: CGRect, anyRecognizer: UIGestureRecognizer?, location: CGPoint?) -> Void { + func openMessageContextMenu(message: EngineMessage, selectAll: Bool, node: ASDisplayNode, frame: CGRect, anyRecognizer: UIGestureRecognizer?, location: CGPoint?) -> Void { if self.presentationInterfaceState.interfaceState.selectionState != nil { return } @@ -53,7 +52,7 @@ extension ChatControllerImpl { self.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: self.context.account.peerId)), contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState: self.presentationInterfaceState, context: self.context, messages: updatedMessages, controllerInteraction: self.controllerInteraction, selectAll: selectAll, interfaceInteraction: self.interfaceInteraction, messageNode: node as? ChatMessageItemView), peerMessageAllowedReactions(context: self.context, message: topMessage, ignoreDefault: canBypassReactionRestrictions), - peerMessageSelectedReactions(context: self.context, message: topMessage), + peerMessageSelectedReactions(context: self.context, message: EngineMessage(topMessage)), topMessageReactions(context: self.context, message: topMessage, subPeerId: self.chatLocation.threadId.flatMap(EnginePeer.Id.init), ignoreDefault: canBypassReactionRestrictions), ApplicationSpecificNotice.getChatTextSelectionTips(accountManager: self.context.sharedContext.accountManager) ).startStandalone(next: { [weak self] peer, actions, allowedReactionsAndStars, selectedReactions, topReactions, chatTextSelectionTips in @@ -129,7 +128,7 @@ extension ChatControllerImpl { actions.context = self.context actions.animationCache = self.controllerInteraction?.presentationContext.animationCache - if canAddMessageReactions(message: topMessage), let allowedReactions = allowedReactions, !topReactions.isEmpty { + if canAddMessageReactions(message: EngineMessage(topMessage)), let allowedReactions = allowedReactions, !topReactions.isEmpty { actions.reactionItems = topReactions.map { ReactionContextItem.reaction(item: $0, icon: .none) } actions.selectedReactionItems = selectedReactions.reactions if message.areReactionsTags(accountPeerId: self.context.account.peerId) { @@ -390,7 +389,7 @@ extension ChatControllerImpl { guard let self else { return } - self.openMessageSendStarsScreen(message: message) + self.openMessageSendStarsScreen(message: EngineMessage(message)) }) } return diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenMessageFactCheck.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenMessageFactCheck.swift index ca5ac6c4eb..ce3600bcee 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenMessageFactCheck.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenMessageFactCheck.swift @@ -4,7 +4,7 @@ import FactCheckAlertController extension ChatControllerImpl { func openEditMessageFactCheck(messageId: EngineMessage.Id) { - guard let message = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId) else { + guard let message = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId)?._asMessage() else { return } var currentText: String = "" diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenPeer.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenPeer.swift index 2a69b0af4a..8e52852d57 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenPeer.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenPeer.swift @@ -1,6 +1,5 @@ import Foundation import UIKit -import Postbox import SwiftSignalKit import Display import AsyncDisplayKit @@ -124,7 +123,7 @@ import FaceScanScreen import ForumCreateTopicScreen extension ChatControllerImpl { - func openPeer(peer: EnginePeer?, navigation: ChatControllerInteractionNavigateToPeer, fromMessage: MessageReference?, fromReactionMessageId: MessageId? = nil, expandAvatar: Bool = false, peerTypes: ReplyMarkupButtonAction.PeerTypes? = nil, skipAgeVerification: Bool = false) { + func openPeer(peer: EnginePeer?, navigation: ChatControllerInteractionNavigateToPeer, fromMessage: MessageReference?, fromReactionMessageId: EngineMessage.Id? = nil, expandAvatar: Bool = false, peerTypes: ReplyMarkupButtonAction.PeerTypes? = nil, skipAgeVerification: Bool = false) { let _ = self.presentVoiceMessageDiscardAlert(action: { if case let .peer(currentPeerId) = self.chatLocation, peer?.id == currentPeerId { switch navigation { @@ -166,7 +165,7 @@ extension ChatControllerImpl { } else { if let peer = peer { do { - var chatPeerId: PeerId? + var chatPeerId: EnginePeer.Id? if let peer = self.presentationInterfaceState.renderedPeer?.chatMainPeer as? TelegramGroup { chatPeerId = peer.id } else if let peer = self.presentationInterfaceState.renderedPeer?.chatMainPeer as? TelegramChannel, case .group = peer.info, case .member = peer.participationStatus { @@ -175,19 +174,12 @@ extension ChatControllerImpl { switch navigation { case .info, .default: - let peerSignal: Signal + let peerSignal: Signal if let messageId = fromMessage?.id { peerSignal = loadedPeerFromMessage(account: self.context.account, peerId: peer.id, messageId: messageId) + |> map { peer in peer.flatMap(EnginePeer.init) } } else { peerSignal = self.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peer.id)) - |> mapToSignal { peer -> Signal in - if let peer { - return .single(peer) - } else { - return .never() - } - } - |> map { Optional($0._asPeer()) } } self.navigationActionDisposable.set((peerSignal |> take(1) |> deliverOnMainQueue).startStrict(next: { [weak self] peer in if let strongSelf = self, let peer = peer { @@ -215,7 +207,7 @@ extension ChatControllerImpl { if let validLayout = strongSelf.validLayout, validLayout.deviceMetrics.type == .tablet { expandAvatar = false } - if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, peer: EnginePeer(peer), mode: mode, avatarInitiallyExpanded: expandAvatar, fromChat: false, requestsContext: nil) { + if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, peer: peer, mode: mode, avatarInitiallyExpanded: expandAvatar, fromChat: false, requestsContext: nil) { strongSelf.effectiveNavigationController?.pushViewController(infoController) } } diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenPollContextMenu.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenPollContextMenu.swift index 357ca8942c..7ce1b07481 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenPollContextMenu.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenPollContextMenu.swift @@ -253,7 +253,7 @@ extension ChatControllerImpl { ) ) - let messageContentSource = ChatMessageContextExtractedContentSource(chatController: self, chatNode: self.chatDisplayNode, engine: self.context.engine, message: message, selectAll: false, snapshot: true) + let messageContentSource = ChatMessageContextExtractedContentSource(chatController: self, chatNode: self.chatDisplayNode, engine: self.context.engine, message: EngineMessage(message), selectAll: false, snapshot: true) sources.append( ContextController.Source( diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenPollOptionMedia.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenPollOptionMedia.swift index 7989c608ac..d413ef7a9b 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenPollOptionMedia.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenPollOptionMedia.swift @@ -1,7 +1,6 @@ import Foundation import UIKit import SwiftSignalKit -import Postbox import TelegramCore import AsyncDisplayKit import Display @@ -17,23 +16,23 @@ import StickerPeekUI import StickerPackPreviewUI extension ChatControllerImpl { - func openPollMedia(message: Message, subject: ChatControllerInteraction.PollMediaSubject) -> Void { + func openPollMedia(message: EngineMessage, subject: ChatControllerInteraction.PollMediaSubject) -> Void { let mediaSubject: GalleryMediaSubject - var media: Media? + let media: EngineMedia? switch subject { case let .option(option): - media = option.media + media = option.media.flatMap(EngineMedia.init) mediaSubject = .pollOption(option.opaqueIdentifier) case let .solution(solution): - media = solution.media + media = solution.media.flatMap(EngineMedia.init) mediaSubject = .pollSolution } - + guard let media else { return } - - if let file = media as? TelegramMediaFile, file.isSticker || file.isCustomEmoji { + + if case let .file(file) = media, file.isSticker || file.isCustomEmoji { let _ = (self.context.engine.stickers.isStickerSaved(id: file.fileId) |> deliverOnMainQueue).start(next: { [weak self] isStarred in guard let self else { @@ -112,7 +111,7 @@ extension ChatControllerImpl { chatLocation: self.chatLocation, chatFilterTag: nil, chatLocationContextHolder: nil, - message: message, + message: message._asMessage(), mediaSubject: mediaSubject, standalone: true, reverseMessageGalleryOrder: false, @@ -195,7 +194,7 @@ extension ChatControllerImpl { }, chatAvatarHiddenMedia: { _, _ in }, - gallerySource: .standaloneMessage(message, mediaSubject) + gallerySource: .standaloneMessage(message._asMessage(), mediaSubject) )) } } diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenTodoContextMenu.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenTodoContextMenu.swift index 068c7322dc..1046ef1307 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenTodoContextMenu.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenTodoContextMenu.swift @@ -250,7 +250,7 @@ extension ChatControllerImpl { ) ) - let messageContentSource = ChatMessageContextExtractedContentSource(chatController: self, chatNode: self.chatDisplayNode, engine: self.context.engine, message: message, selectAll: false, snapshot: true) + let messageContentSource = ChatMessageContextExtractedContentSource(chatController: self, chatNode: self.chatDisplayNode, engine: self.context.engine, message: EngineMessage(message), selectAll: false, snapshot: true) sources.append( ContextController.Source( diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenViewOnceMediaMessage.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenViewOnceMediaMessage.swift index ec6308a9f7..2edb644a58 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenViewOnceMediaMessage.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenViewOnceMediaMessage.swift @@ -1,6 +1,5 @@ import Foundation import UIKit -import Postbox import SwiftSignalKit import Display import AsyncDisplayKit @@ -122,7 +121,7 @@ import ChatMediaInputStickerGridItem import AdsInfoScreen extension ChatControllerImpl { - func openViewOnceMediaMessage(_ message: Message) { + func openViewOnceMediaMessage(_ message: EngineMessage) { if self.screenCaptureManager?.isRecordingActive == true { let controller = textAlertController(context: self.context, updatedPresentationData: self.updatedPresentationData, title: nil, text: self.presentationData.strings.Chat_PlayOnceMesasge_DisableScreenCapture, actions: [TextAlertAction(type: .defaultAction, title: self.presentationData.strings.Common_OK, action: { })]) @@ -174,7 +173,7 @@ extension ChatControllerImpl { contextController?.present(c, in: .current) } - let _ = self.context.sharedContext.openChatMessage(OpenChatMessageParams(context: self.context, chatLocation: nil, chatFilterTag: nil, chatLocationContextHolder: nil, message: message, standalone: false, reverseMessageGalleryOrder: false, navigationController: nil, dismissInput: { }, present: { _, _, _ in }, transitionNode: { _, _, _ in return nil }, addToTransitionSurface: { _ in }, openUrl: { _ in }, openPeer: { _, _ in }, callPeer: { _, _ in }, openConferenceCall: { _ in + let _ = self.context.sharedContext.openChatMessage(OpenChatMessageParams(context: self.context, chatLocation: nil, chatFilterTag: nil, chatLocationContextHolder: nil, message: message._asMessage(), standalone: false, reverseMessageGalleryOrder: false, navigationController: nil, dismissInput: { }, present: { _, _, _ in }, transitionNode: { _, _, _ in return nil }, addToTransitionSurface: { _ in }, openUrl: { _ in }, openPeer: { _, _ in }, callPeer: { _, _ in }, openConferenceCall: { _ in }, enqueueMessage: { _ in }, sendSticker: nil, sendEmoji: nil, setupTemporaryHiddenMedia: { _, _, _ in }, chatAvatarHiddenMedia: { _, _ in }, playlistLocation: .singleMessage(message.id))) } } diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerPaste.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerPaste.swift index 72f91cd13c..6e8d0ca603 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerPaste.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerPaste.swift @@ -157,7 +157,7 @@ extension ChatControllerImpl { Queue.mainQueue().after(3.0) { if let message = self.chatDisplayNode.historyNode.lastVisbleMesssage(), let file = message.media.first(where: { $0 is TelegramMediaFile }) as? TelegramMediaFile, file.isSticker { - self.context.engine.stickers.addRecentlyUsedSticker(fileReference: .message(message: MessageReference(message), media: file)) + self.context.engine.stickers.addRecentlyUsedSticker(fileReference: .message(message: MessageReference(message._asMessage()), media: file)) } } }) diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerPlayMessageEffect.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerPlayMessageEffect.swift index fc8fd00154..2c740bda67 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerPlayMessageEffect.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerPlayMessageEffect.swift @@ -8,7 +8,7 @@ import AccountContext import ChatMessageItemView extension ChatControllerImpl { - func playMessageEffect(message: Message) { + func playMessageEffect(message: EngineMessage) { var messageItemNode: ChatMessageItemView? self.chatDisplayNode.historyNode.forEachVisibleMessageItemNode { itemNode in if let item = itemNode.item, item.message.id == message.id { diff --git a/submodules/TelegramUI/Sources/Chat/PeerMessageSelectedReactions.swift b/submodules/TelegramUI/Sources/Chat/PeerMessageSelectedReactions.swift index 7a30ad19f8..94a81cfaf9 100644 --- a/submodules/TelegramUI/Sources/Chat/PeerMessageSelectedReactions.swift +++ b/submodules/TelegramUI/Sources/Chat/PeerMessageSelectedReactions.swift @@ -1,17 +1,16 @@ import Foundation import UIKit import SwiftSignalKit -import Postbox import TelegramCore import AccountContext -func peerMessageSelectedReactions(context: AccountContext, message: Message) -> Signal<(reactions: Set, files: Set), NoError> { +func peerMessageSelectedReactions(context: AccountContext, message: EngineMessage) -> Signal<(reactions: Set, files: Set), NoError> { return context.engine.stickers.availableReactions() |> take(1) - |> map { availableReactions -> (reactions: Set, files: Set) in - var result = Set() + |> map { availableReactions -> (reactions: Set, files: Set) in + var result = Set() var reactions = Set() - + if let effectiveReactions = message.effectiveReactions(isTags: message.areReactionsTags(accountPeerId: context.account.peerId)) { for reaction in effectiveReactions { if !reaction.isSelected { @@ -27,11 +26,11 @@ func peerMessageSelectedReactions(context: AccountContext, message: Message) -> result.insert(availableReaction.selectAnimation.fileId) } case let .custom(fileId): - result.insert(MediaId(namespace: Namespaces.Media.CloudFile, id: fileId)) + result.insert(EngineMedia.Id(namespace: Namespaces.Media.CloudFile, id: fileId)) } } } - + return (reactions, result) } } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index fb0c1a7311..953692fad1 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -846,7 +846,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } let controllerInteraction = ChatControllerInteraction(openMessage: { [weak self] message, params in - guard let self, self.isNodeLoaded, let message = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(message.id) else { + guard let self, self.isNodeLoaded, let message = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(message.id)?._asMessage() else { return false } @@ -904,7 +904,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } if (file.isVoice || file.isInstantVideo) && message.minAutoremoveOrClearTimeout == viewOnceTimeout { - self.openViewOnceMediaMessage(message) + self.openViewOnceMediaMessage(EngineMessage(message)) return false } } else if file.isVideo { @@ -1588,7 +1588,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } if let mediaReference = mediaReference, let peer = message.peers[message.id.peerId] { - legacyMediaEditor(context: self.context, peer: peer, threadTitle: self.contentData?.state.threadInfo?.title, media: mediaReference, mode: .draw, initialCaption: NSAttributedString(), snapshots: snapshots, transitionCompletion: { + legacyMediaEditor(context: self.context, peer: EnginePeer(peer), threadTitle: self.contentData?.state.threadInfo?.title, media: mediaReference, mode: .draw, initialCaption: NSAttributedString(), snapshots: snapshots, transitionCompletion: { transitionCompletion() }, getCaptionPanelView: { [weak self] in return self?.getCaptionPanelView(isFile: false) @@ -1659,13 +1659,13 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G guard let self, self.isNodeLoaded else { return } - self.openMessageContextMenu(message: message, selectAll: selectAll, node: node, frame: frame, anyRecognizer: anyRecognizer, location: location) + self.openMessageContextMenu(message: EngineMessage(message), selectAll: selectAll, node: node, frame: frame, anyRecognizer: anyRecognizer, location: location) }, openMessageReactionContextMenu: { [weak self] message, sourceView, gesture, value in guard let self else { return } - self.openMessageReactionContextMenu(message: message, sourceView: sourceView, gesture: gesture, value: value) + self.openMessageReactionContextMenu(message: EngineMessage(message), sourceView: sourceView, gesture: gesture, value: value) }, updateMessageReaction: { [weak self] initialMessage, reaction, force, sourceView in guard let strongSelf = self else { return @@ -1738,7 +1738,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G let tag = ReactionsMessageAttribute.messageTag(reaction: chosenReaction) if strongSelf.presentationInterfaceState.historyFilter?.customTag == tag { if let sourceView { - strongSelf.openMessageReactionContextMenu(message: message, sourceView: sourceView, gesture: nil, value: chosenReaction) + strongSelf.openMessageReactionContextMenu(message: EngineMessage(message), sourceView: sourceView, gesture: nil, value: chosenReaction) } } else { strongSelf.chatDisplayNode.historyNode.frozenMessageForScrollingReset = message.id @@ -1970,7 +1970,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return } - if !canAddMessageReactions(message: message) { + if !canAddMessageReactions(message: EngineMessage(message)) { itemNode.openMessageContextMenu() return } @@ -2082,7 +2082,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } else { strongSelf.chatDisplayNode.messageTransitionNode.dismissMessageReactionContexts(itemNode: itemNode) - if let removedReaction = removedReaction, let targetView = itemNode.targetReactionView(value: removedReaction), shouldDisplayInlineDateReactions(message: message, isPremium: strongSelf.presentationInterfaceState.isPremium, forceInline: false) { + if let removedReaction = removedReaction, let targetView = itemNode.targetReactionView(value: removedReaction), shouldDisplayInlineDateReactions(message: EngineMessage(message), isPremium: strongSelf.presentationInterfaceState.isPremium, forceInline: false) { var hideRemovedReaction: Bool = false if let reactions = mergedMessageReactions(attributes: message.attributes, isTags: message.areReactionsTags(accountPeerId: context.account.peerId)) { for reaction in reactions.reactions { @@ -3098,7 +3098,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G case .default: strongSelf.openUrl(defaultUrl, concealed: false, skipUrlAuth: true) case let .request(domain, bot, _, flags, _, _): - let controller = chatMessageActionUrlAuthController(context: strongSelf.context, defaultUrl: defaultUrl, domain: domain, bot: bot, requestWriteAccess: flags.contains(.requestWriteAccess), displayName: peer.displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder), open: { [weak self] authorize, allowWriteAccess in + let controller = chatMessageActionUrlAuthController(context: strongSelf.context, defaultUrl: defaultUrl, domain: domain, bot: EnginePeer(bot), requestWriteAccess: flags.contains(.requestWriteAccess), displayName: peer.displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder), open: { [weak self] authorize, allowWriteAccess in if let strongSelf = self { if authorize { strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { @@ -3349,7 +3349,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G postAsReply = true } - if let messageId = messageId, let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId) { + if let messageId = messageId, let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId)?._asMessage() { if let author = message.author as? TelegramUser, author.botInfo != nil { } else { postAsReply = false @@ -3378,7 +3378,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.sendMessages([.message(text: command, attributes: attributes, inlineStickers: [:], mediaReference: nil, threadId: strongSelf.chatLocation.threadId, replyToMessageId: replyToMessageId, replyToStoryId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: [])]) } }, openInstantPage: { [weak self] message, associatedData in - if let strongSelf = self, strongSelf.isNodeLoaded, let navigationController = strongSelf.effectiveNavigationController, let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(message.id) { + if let strongSelf = self, strongSelf.isNodeLoaded, let navigationController = strongSelf.effectiveNavigationController, let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(message.id)?._asMessage() { let _ = strongSelf.presentVoiceMessageDiscardAlert(action: { strongSelf.chatDisplayNode.dismissInput() if let controller = strongSelf.context.sharedContext.makeInstantPageController(context: strongSelf.context, message: message, sourcePeerType: associatedData?.automaticDownloadPeerType) { @@ -3390,7 +3390,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G }) } }, openWallpaper: { [weak self] message in - if let strongSelf = self, strongSelf.isNodeLoaded, let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(message.id) { + if let strongSelf = self, strongSelf.isNodeLoaded, let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(message.id)?._asMessage() { let _ = strongSelf.presentVoiceMessageDiscardAlert(action: { strongSelf.chatDisplayNode.dismissInput() strongSelf.context.sharedContext.openChatWallpaper(context: strongSelf.context, message: message, present: { [weak self] c, a in @@ -3399,7 +3399,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G }) } }, openTheme: { [weak self] message in - if let strongSelf = self, strongSelf.isNodeLoaded, let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(message.id) { + if let strongSelf = self, strongSelf.isNodeLoaded, let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(message.id)?._asMessage() { let _ = strongSelf.presentVoiceMessageDiscardAlert(action: { strongSelf.chatDisplayNode.dismissInput() openChatTheme(context: strongSelf.context, message: message, pushController: { [weak self] c in @@ -3723,7 +3723,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.chatDisplayNode.messageTransitionNode.dismissMessageReactionContexts() - let controller = makeContextController(presentationData: strongSelf.presentationData, source: .extracted(ChatMessageContextExtractedContentSource(chatController: strongSelf, chatNode: strongSelf.chatDisplayNode, engine: strongSelf.context.engine, message: message._asMessage(), selectAll: true)), items: .single(ContextController.Items(content: .list(actions))), recognizer: nil) + let controller = makeContextController(presentationData: strongSelf.presentationData, source: .extracted(ChatMessageContextExtractedContentSource(chatController: strongSelf, chatNode: strongSelf.chatDisplayNode, engine: strongSelf.context.engine, message: message, selectAll: true)), items: .single(ContextController.Items(content: .list(actions))), recognizer: nil) strongSelf.currentContextController = controller strongSelf.forEachController({ controller in if let controller = controller as? TooltipScreen { @@ -3811,7 +3811,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.chatDisplayNode.messageTransitionNode.dismissMessageReactionContexts() - let controller = makeContextController(presentationData: strongSelf.presentationData, source: .extracted(ChatMessageContextExtractedContentSource(chatController: strongSelf, chatNode: strongSelf.chatDisplayNode, engine: strongSelf.context.engine, message: topMessage, selectAll: true)), items: .single(ContextController.Items(content: .list(actions))), recognizer: nil) + let controller = makeContextController(presentationData: strongSelf.presentationData, source: .extracted(ChatMessageContextExtractedContentSource(chatController: strongSelf, chatNode: strongSelf.chatDisplayNode, engine: strongSelf.context.engine, message: EngineMessage(topMessage), selectAll: true)), items: .single(ContextController.Items(content: .list(actions))), recognizer: nil) strongSelf.currentContextController = controller strongSelf.forEachController({ controller in if let controller = controller as? TooltipScreen { @@ -3858,7 +3858,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return } - if let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(id), controllerInteraction.pollActionState.pollMessageIdsInProgress[id] == nil { + if let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(id)?._asMessage(), controllerInteraction.pollActionState.pollMessageIdsInProgress[id] == nil { controllerInteraction.pollActionState.pollMessageIdsInProgress[id] = opaqueIdentifiers strongSelf.chatDisplayNode.historyNode.requestMessageUpdate(id) let disposables: DisposableDict @@ -3887,7 +3887,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G guard let strongSelf = self, let resultPoll = resultPoll else { return } - guard let _ = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(id) else { + guard let _ = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(id)?._asMessage() else { return } @@ -4111,7 +4111,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let forwardInfo = message.forwardInfo, let sourceMessageId = forwardInfo.sourceMessageId, case let .replyThread(threadMessage) = strongSelf.chatLocation, threadMessage.isChannelPost { messageId = sourceMessageId } - if let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId) { + if let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId)?._asMessage() { let _ = strongSelf.controllerInteraction?.openMessage(message, OpenMessageParams(mode: .timecode(Double(timestamp)))) } else { strongSelf.navigateToMessage(messageLocation: .id(messageId, NavigateToMessageParams(timestamp: Double(timestamp), quote: nil)), animated: true, forceInCurrentChat: true) @@ -4342,7 +4342,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } } } - if let messageId = message?.id, let message = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId) ?? message { + if let messageId = message?.id, let message = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId)?._asMessage() ?? message { var quoteData: EngineMessageReplyQuote? let nsRange = NSRange(location: range.lowerBound, length: range.upperBound - range.lowerBound) @@ -4434,7 +4434,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G guard let self else { return } - self.openPollMedia(message: message, subject: subject) + self.openPollMedia(message: EngineMessage(message), subject: subject) }, displayPollSolution: { [weak self] solution, sourceNode in guard let self else { return @@ -4645,7 +4645,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let mediaReference = mediaReference, let peer = message.peers[message.id.peerId] { let inputText = strongSelf.presentationInterfaceState.interfaceState.effectiveInputState.inputText - legacyMediaEditor(context: strongSelf.context, peer: peer, threadTitle: strongSelf.contentData?.state.threadInfo?.title, media: mediaReference, mode: .draw, initialCaption: inputText, snapshots: [], transitionCompletion: nil, getCaptionPanelView: { [weak self] in + legacyMediaEditor(context: strongSelf.context, peer: EnginePeer(peer), threadTitle: strongSelf.contentData?.state.threadInfo?.title, media: mediaReference, mode: .draw, initialCaption: inputText, snapshots: [], transitionCompletion: nil, getCaptionPanelView: { [weak self] in return self?.getCaptionPanelView(isFile: true) }, sendMessagesWithSignals: { [weak self] signals, _, _, _ in if let strongSelf = self { @@ -4790,7 +4790,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } var message: Message? - if let historyMessage = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId) { + if let historyMessage = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId)?._asMessage() { message = historyMessage } else if let panelMessage = self.chatDisplayNode.adPanelMessage, panelMessage.id == messageId { message = panelMessage @@ -4822,7 +4822,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G let controller = AdsInfoScreen( context: context, mode: isBot ? .bot : .channel, - message: message + message: EngineMessage(message) ) controller.removeAd = { [weak self] opaqueId in self?.removeAd(opaqueId: opaqueId) @@ -5296,7 +5296,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G guard let self else { return } - self.playMessageEffect(message: message) + self.playMessageEffect(message: EngineMessage(message)) }, editMessageFactCheck: { [weak self] messageId in guard let self else { return @@ -5612,7 +5612,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } self.dismissAllTooltips() - if let message = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId), let _ = message.forwardInfo { + if let message = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId)?._asMessage(), let _ = message.forwardInfo { let controller = UndoOverlayController( presentationData: self.presentationData, content: .universalImage(image: generateTintedImage(image: UIImage(bundleImageName: "Chat/Stickers/Lock"), color: .white)!, size: nil, title: nil, text: self.presentationData.strings.Chat_Todo_CompletionLimitedForward, customUndoText: nil, timeout: nil), @@ -5644,7 +5644,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } ) self.present(controller, in: .current) - } else if let message = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId) { + } else if let message = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId)?._asMessage() { var peerName = "" if let author = message.author { peerName = EnginePeer(author).compactDisplayTitle @@ -9521,7 +9521,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G func openResolved(result: ResolvedUrl, sourceMessageId: MessageId?, progress: Promise? = nil, forceExternal: Bool = false, concealed: Bool = false, commit: @escaping () -> Void = {}) { let urlContext: OpenURLContext - let message = sourceMessageId.flatMap { self.chatDisplayNode.historyNode.messageInCurrentHistoryView($0) } + let message = sourceMessageId.flatMap { self.chatDisplayNode.historyNode.messageInCurrentHistoryView($0)?._asMessage() } if let peerId = self.chatLocation.peerId { urlContext = .chat(peerId: peerId, message: message, updatedPresentationData: self.updatedPresentationData) } else { @@ -10191,11 +10191,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G }) } - public func getTransitionInfo(messageId: MessageId, media: Media) -> ((UIView) -> Void, ASDisplayNode, () -> (UIView?, UIView?))? { + public func getTransitionInfo(messageId: EngineMessage.Id, media: EngineMedia) -> ((UIView) -> Void, ASDisplayNode, () -> (UIView?, UIView?))? { var selectedNode: (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? + let rawMedia = media._asMedia() self.chatDisplayNode.historyNode.forEachItemNode { itemNode in if let itemNode = itemNode as? ChatMessageItemView { - if let result = itemNode.transitionNode(id: messageId, media: media, adjustRect: false) { + if let result = itemNode.transitionNode(id: messageId, media: rawMedia, adjustRect: false) { selectedNode = result } } diff --git a/submodules/TelegramUI/Sources/ChatControllerAdminBanUsers.swift b/submodules/TelegramUI/Sources/ChatControllerAdminBanUsers.swift index 958341234f..2d4623d38f 100644 --- a/submodules/TelegramUI/Sources/ChatControllerAdminBanUsers.swift +++ b/submodules/TelegramUI/Sources/ChatControllerAdminBanUsers.swift @@ -1,7 +1,6 @@ import Foundation import TelegramPresentationData import AccountContext -import Postbox import TelegramCore import SwiftSignalKit import Display @@ -21,7 +20,7 @@ fileprivate struct InitialBannedRights { } extension ChatControllerImpl { - fileprivate func applyAdminUserActionsResult(messageIds: Set, reactionPeerId: EnginePeer.Id? = nil, result: AdminUserActionsSheet.ChatResult, initialUserBannedRights: [EnginePeer.Id: InitialBannedRights]) { + fileprivate func applyAdminUserActionsResult(messageIds: Set, reactionPeerId: EnginePeer.Id? = nil, result: AdminUserActionsSheet.ChatResult, initialUserBannedRights: [EnginePeer.Id: InitialBannedRights]) { guard let messagesPeerId = self.chatLocation.peerId else { return } @@ -148,7 +147,7 @@ extension ChatControllerImpl { self.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState { $0.withoutSelectionState() } }) } - func presentMultiBanMessageOptions(accountPeerId: PeerId, authors: [Peer], messageIds: Set, options: ChatAvailableMessageActionOptions) { + func presentMultiBanMessageOptions(accountPeerId: EnginePeer.Id, authors: [EnginePeer], messageIds: Set, options: ChatAvailableMessageActionOptions) { guard let peerId = self.chatLocation.peerId else { return } @@ -163,7 +162,7 @@ extension ChatControllerImpl { var signal = combineLatest(authors.map { author in self.context.engine.peers.fetchChannelParticipant(peerId: peerId, participantId: author.id) - |> map { result -> (Peer, ChannelParticipant?) in + |> map { result -> (EnginePeer, ChannelParticipant?) in return (author, result) } }) @@ -227,10 +226,9 @@ extension ChatControllerImpl { ), rank: nil, subscriptionUntilDate: nil) } - let peer = author renderedParticipants.append(RenderedChannelParticipant( participant: participant, - peer: EnginePeer(peer) + peer: author )) switch participant { case .creator: @@ -262,7 +260,7 @@ extension ChatControllerImpl { })) } - public func presentReactionDeletionOptions(author: Peer, messageId: MessageId) { + public func presentReactionDeletionOptions(author: EnginePeer, messageId: EngineMessage.Id) { guard self.chatLocation.peerId?.namespace == Namespaces.Peer.CloudChannel, author.id != self.context.account.peerId else { return } @@ -286,7 +284,7 @@ extension ChatControllerImpl { }) } - func presentBanMessageOptions(accountPeerId: PeerId, author: Peer, messageIds: Set, options: ChatAvailableMessageActionOptions, reaction: Bool = false) { + func presentBanMessageOptions(accountPeerId: EnginePeer.Id, author: EnginePeer, messageIds: Set, options: ChatAvailableMessageActionOptions, reaction: Bool = false) { guard let peerId = self.chatLocation.peerId else { return } @@ -408,7 +406,7 @@ extension ChatControllerImpl { })) } - func beginDeleteMessagesWithUndo(messageIds: Set, type: InteractiveMessagesDeletionType) { + func beginDeleteMessagesWithUndo(messageIds: Set, type: InteractiveMessagesDeletionType) { var deleteImmediately = false if case .forEveryone = type { deleteImmediately = true @@ -441,7 +439,7 @@ extension ChatControllerImpl { }), in: .current) } - func presentDeleteMessageOptions(messageIds: Set, options: ChatAvailableMessageActionOptions, contextController: ContextControllerProtocol?, completion: @escaping (ContextMenuActionResult) -> Void) { + func presentDeleteMessageOptions(messageIds: Set, options: ChatAvailableMessageActionOptions, contextController: ContextControllerProtocol?, completion: @escaping (ContextMenuActionResult) -> Void) { let _ = (self.context.engine.data.get( EngineDataMap(messageIds.map(TelegramEngine.EngineData.Item.Messages.Message.init(id:))) ) @@ -597,7 +595,7 @@ extension ChatControllerImpl { if let strongSelf = self { var giveaway: TelegramMediaGiveaway? for messageId in messageIds { - if let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId) { + if let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId)?._asMessage() { if let media = message.media.first(where: { $0 is TelegramMediaGiveaway }) as? TelegramMediaGiveaway { giveaway = media break diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index 68f52b510e..2ff4273233 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -385,7 +385,7 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate { } } else { loadingPlaceholderNode = ChatLoadingPlaceholderNode(context: self.context, theme: self.chatPresentationInterfaceState.theme, chatWallpaper: self.chatPresentationInterfaceState.chatWallpaper, bubbleCorners: self.chatPresentationInterfaceState.bubbleCorners, backgroundNode: self.backgroundNode) - loadingPlaceholderNode.updatePresentationInterfaceState(renderedPeer: self.chatPresentationInterfaceState.renderedPeer, chatLocation: self.chatLocation) + loadingPlaceholderNode.updatePresentationInterfaceState(renderedPeer: self.chatPresentationInterfaceState.renderedPeer.flatMap(EngineRenderedPeer.init), chatLocation: self.chatLocation) self.backgroundNode.supernode?.insertSubnode(loadingPlaceholderNode, aboveSubnode: self.backgroundNode) self.loadingPlaceholderNode = loadingPlaceholderNode @@ -3630,7 +3630,7 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate { self.historyNode.verticalScrollIndicatorColor = UIColor(white: 0.5, alpha: 0.8) if self.pendingSwitchToChatLocation == nil { - self.loadingPlaceholderNode?.updatePresentationInterfaceState(renderedPeer: chatPresentationInterfaceState.renderedPeer, chatLocation: self.chatLocation) + self.loadingPlaceholderNode?.updatePresentationInterfaceState(renderedPeer: chatPresentationInterfaceState.renderedPeer.flatMap(EngineRenderedPeer.init), chatLocation: self.chatLocation) } var updatedInputFocus = self.chatPresentationInterfaceStateRequiresInputFocus(self.chatPresentationInterfaceState) != self.chatPresentationInterfaceStateRequiresInputFocus(chatPresentationInterfaceState) @@ -4810,7 +4810,7 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate { if let editMessageState = effectivePresentationInterfaceState.editMessageState, let mediaReferenceValue = editMessageState.mediaReference { mediaReference = mediaReferenceValue } else { - if let message = self.historyNode.messageInCurrentHistoryView(editingOriginalMessageId) { + if let message = self.historyNode.messageInCurrentHistoryView(editingOriginalMessageId)?._asMessage() { for media in message.media { if media is TelegramMediaFile || media is TelegramMediaImage { mediaReference = .message(message: MessageReference(message), media: media) diff --git a/submodules/TelegramUI/Sources/ChatControllerOpenAttachmentMenu.swift b/submodules/TelegramUI/Sources/ChatControllerOpenAttachmentMenu.swift index 50b7728237..14c12e7075 100644 --- a/submodules/TelegramUI/Sources/ChatControllerOpenAttachmentMenu.swift +++ b/submodules/TelegramUI/Sources/ChatControllerOpenAttachmentMenu.swift @@ -979,7 +979,7 @@ extension ChatControllerImpl { let controller = legacyAttachmentMenu( context: strongSelf.context, - peer: strongSelf.presentationInterfaceState.renderedPeer?.peer, + peer: strongSelf.presentationInterfaceState.renderedPeer?.peer.flatMap(EnginePeer.init), threadTitle: strongSelf.contentData?.state.threadInfo?.title, chatLocation: strongSelf.chatLocation, editMediaOptions: menuEditMediaOptions, addingMedia: editMediaOptions == nil, @@ -989,7 +989,7 @@ extension ChatControllerImpl { canSendPolls: canSendPolls, updatedPresentationData: strongSelf.updatedPresentationData, parentController: legacyController, - recentlyUsedInlineBots: strongSelf.recentlyUsedInlineBotsValue, + recentlyUsedInlineBots: strongSelf.recentlyUsedInlineBotsValue.map(EnginePeer.init), initialCaption: inputText, openGallery: { self?.presentOldMediaPicker(fileMode: false, editingMedia: true, completion: { signals, silentPosting, scheduleTime in @@ -1043,7 +1043,8 @@ extension ChatControllerImpl { hasSchedule = strongSelf.presentationInterfaceState.subject != .scheduledMessages && peer.id.namespace != Namespaces.Peer.SecretChat && strongSelf.presentationInterfaceState.sendPaidMessageStars == nil } - presentedLegacyCamera(context: strongSelf.context, peer: strongSelf.presentationInterfaceState.renderedPeer?.peer, chatLocation: strongSelf.chatLocation, cameraView: cameraView, menuController: menuController, parentController: strongSelf, editingMedia: editMediaOptions != nil, saveCapturedPhotos: storeCapturedPhotos, mediaGrouping: true, initialCaption: inputText, hasSchedule: hasSchedule, enablePhoto: enablePhoto, enableVideo: enableVideo, sendMessagesWithSignals: { [weak self] signals, _, _, _ in + let cameraPeer: EnginePeer? = strongSelf.presentationInterfaceState.renderedPeer?.peer.map { EnginePeer($0) } + presentedLegacyCamera(context: strongSelf.context, peer: cameraPeer, chatLocation: strongSelf.chatLocation, cameraView: cameraView, menuController: menuController, parentController: strongSelf, editingMedia: editMediaOptions != nil, saveCapturedPhotos: storeCapturedPhotos, mediaGrouping: true, initialCaption: inputText, hasSchedule: hasSchedule, enablePhoto: enablePhoto, enableVideo: enableVideo, sendMessagesWithSignals: { [weak self] signals, _, _, _ in if let strongSelf = self { strongSelf.editMessageMediaWithLegacySignals(signals!) @@ -1954,7 +1955,8 @@ extension ChatControllerImpl { } let inputText = strongSelf.presentationInterfaceState.interfaceState.effectiveInputState.inputText - presentedLegacyCamera(context: strongSelf.context, peer: strongSelf.presentationInterfaceState.renderedPeer?.peer, chatLocation: strongSelf.chatLocation, cameraView: cameraView, menuController: nil, parentController: strongSelf, attachmentController: self?.attachmentController, editingMedia: false, saveCapturedPhotos: storeCapturedMedia, mediaGrouping: true, initialCaption: inputText, hasSchedule: hasSchedule, enablePhoto: enablePhoto, enableVideo: enableVideo, sendPaidMessageStars: strongSelf.presentationInterfaceState.sendPaidMessageStars?.value ?? 0, sendMessagesWithSignals: { [weak self] signals, silentPosting, scheduleTime, parameters in + let cameraPeer: EnginePeer? = strongSelf.presentationInterfaceState.renderedPeer?.peer.map { EnginePeer($0) } + presentedLegacyCamera(context: strongSelf.context, peer: cameraPeer, chatLocation: strongSelf.chatLocation, cameraView: cameraView, menuController: nil, parentController: strongSelf, attachmentController: self?.attachmentController, editingMedia: false, saveCapturedPhotos: storeCapturedMedia, mediaGrouping: true, initialCaption: inputText, hasSchedule: hasSchedule, enablePhoto: enablePhoto, enableVideo: enableVideo, sendPaidMessageStars: strongSelf.presentationInterfaceState.sendPaidMessageStars?.value ?? 0, sendMessagesWithSignals: { [weak self] signals, silentPosting, scheduleTime, parameters in if let strongSelf = self { strongSelf.enqueueMediaMessages(signals: signals, silentPosting: silentPosting, scheduleTime: scheduleTime > 0 ? scheduleTime : nil, parameters: parameters) if !inputText.string.isEmpty { @@ -2201,7 +2203,7 @@ extension ChatControllerImpl { } func openTodoEditing(messageId: EngineMessage.Id, itemId: Int32?, append: Bool) { - guard let message = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId), let peer = self.presentationInterfaceState.renderedPeer?.peer else { + guard let message = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId)?._asMessage(), let peer = self.presentationInterfaceState.renderedPeer?.peer else { return } guard let existingTodo = message.media.first(where: { $0 is TelegramMediaTodo }) as? TelegramMediaTodo else { diff --git a/submodules/TelegramUI/Sources/ChatControllerOpenMessageReactionContextMenu.swift b/submodules/TelegramUI/Sources/ChatControllerOpenMessageReactionContextMenu.swift index 2be170fc78..3f47be584c 100644 --- a/submodules/TelegramUI/Sources/ChatControllerOpenMessageReactionContextMenu.swift +++ b/submodules/TelegramUI/Sources/ChatControllerOpenMessageReactionContextMenu.swift @@ -1,7 +1,6 @@ import Foundation import TelegramPresentationData import AccountContext -import Postbox import TelegramCore import SwiftSignalKit import ContextUI @@ -36,7 +35,7 @@ extension ChatControllerImpl { self.push(controller) } - func openMessageReactionContextMenu(message: Message, sourceView: ContextExtractedContentContainingView, gesture: ContextGesture?, value: MessageReaction.Reaction) { + func openMessageReactionContextMenu(message: EngineMessage, sourceView: ContextExtractedContentContainingView, gesture: ContextGesture?, value: MessageReaction.Reaction) { if message.areReactionsTags(accountPeerId: self.context.account.peerId) { if !self.presentationInterfaceState.isPremium { self.presentTagPremiumPaywall() @@ -146,7 +145,7 @@ extension ChatControllerImpl { guard let self else { return } - self.controllerInteraction?.updateMessageReaction(message, .reaction(value), true, nil) + self.controllerInteraction?.updateMessageReaction(message._asMessage(), .reaction(value), true, nil) }))) self.canReadHistory.set(false) @@ -189,7 +188,7 @@ extension ChatControllerImpl { var dismissController: ((@escaping () -> Void) -> Void)? let canDeleteReactions: Bool - if let channel = message.peers[message.id.peerId] as? TelegramChannel { + if case let .channel(channel) = message.enginePeers[message.id.peerId] { canDeleteReactions = channel.hasPermission(.deleteAllMessages) } else { canDeleteReactions = false @@ -202,7 +201,7 @@ extension ChatControllerImpl { guard let self else { return } - self.presentReactionDeletionOptions(author: peer._asPeer(), messageId: message.id) + self.presentReactionDeletionOptions(author: peer, messageId: message.id) }) } } else { @@ -217,7 +216,7 @@ extension ChatControllerImpl { availableReactions: availableReactions, animationCache: self.controllerInteraction!.presentationContext.animationCache, animationRenderer: self.controllerInteraction!.presentationContext.animationRenderer, - message: EngineMessage(message), + message: message, reaction: value, readStats: nil, back: nil, @@ -227,7 +226,7 @@ extension ChatControllerImpl { return } - self.openPeer(peer: peer, navigation: .default, fromMessage: MessageReference(message), fromReactionMessageId: hasReaction ? message.id : nil) + self.openPeer(peer: peer, navigation: .default, fromMessage: MessageReference(message._asMessage()), fromReactionMessageId: hasReaction ? message.id : nil) }) }, deleteReaction: deleteReaction @@ -393,7 +392,7 @@ extension ChatControllerImpl { } } - func openMessageSendStarsScreen(message: Message) { + func openMessageSendStarsScreen(message: EngineMessage) { guard canSendReactionsToChat(self.presentationInterfaceState) else { return } diff --git a/submodules/TelegramUI/Sources/ChatHistoryEntriesForView.swift b/submodules/TelegramUI/Sources/ChatHistoryEntriesForView.swift index e8f2b42b67..6cac18a9de 100644 --- a/submodules/TelegramUI/Sources/ChatHistoryEntriesForView.swift +++ b/submodules/TelegramUI/Sources/ChatHistoryEntriesForView.swift @@ -241,11 +241,11 @@ func chatHistoryEntriesForView( } if presentationData.largeEmoji, message.media.isEmpty { - if messageIsEligibleForLargeCustomEmoji(message) { + if messageIsEligibleForLargeCustomEmoji(EngineMessage(message)) { contentTypeHint = .animatedEmoji } else if stickersEnabled && message.text.count == 1, let _ = associatedData.animatedEmojiStickers[message.text.basicEmoji.0], (message.textEntitiesAttribute?.entities.isEmpty ?? true) { contentTypeHint = .animatedEmoji - } else if messageIsEligibleForLargeEmoji(message) { + } else if messageIsEligibleForLargeEmoji(EngineMessage(message)) { contentTypeHint = .animatedEmoji } } @@ -489,11 +489,11 @@ func chatHistoryEntriesForView( var contentTypeHint: ChatMessageEntryContentType = .generic if presentationData.largeEmoji, topMessage.media.isEmpty { - if messageIsEligibleForLargeCustomEmoji(topMessage) { + if messageIsEligibleForLargeCustomEmoji(EngineMessage(topMessage)) { contentTypeHint = .animatedEmoji } else if stickersEnabled && topMessage.text.count == 1, let _ = associatedData.animatedEmojiStickers[topMessage.text.basicEmoji.0] { contentTypeHint = .animatedEmoji - } else if messageIsEligibleForLargeEmoji(topMessage) { + } else if messageIsEligibleForLargeEmoji(EngineMessage(topMessage)) { contentTypeHint = .animatedEmoji } } diff --git a/submodules/TelegramUI/Sources/ChatHistoryListNode.swift b/submodules/TelegramUI/Sources/ChatHistoryListNode.swift index 2302845a6f..9673ce7981 100644 --- a/submodules/TelegramUI/Sources/ChatHistoryListNode.swift +++ b/submodules/TelegramUI/Sources/ChatHistoryListNode.swift @@ -3586,22 +3586,22 @@ public final class ChatHistoryListNodeImpl: ListViewImpl, ChatHistoryNode, ChatH self.chatHistoryLocationValue = ChatHistoryLocationInput(content: .Scroll(subject: MessageHistoryScrollToSubject(index: .message(toIndex), quote: quote.flatMap { quote in MessageHistoryScrollToSubject.Quote(string: quote.string, offset: quote.offset) }, subject: subject, setupReply: setupReply), anchorIndex: .message(toIndex), sourceIndex: .message(fromIndex), scrollPosition: scrollPosition, animated: animated, highlight: highlight, setupReply: setupReply), id: self.takeNextHistoryLocationId()) } - public func anchorMessageInCurrentHistoryView() -> Message? { + public func anchorMessageInCurrentHistoryView() -> EngineMessage? { if let historyView = self.historyView { if let visibleRange = self.displayedItemRange.visibleRange { var index = 0 for entry in historyView.filteredEntries.reversed() { if index >= visibleRange.firstIndex && index <= visibleRange.lastIndex { if case let .MessageEntry(message, _, _, _, _, _) = entry { - return message + return EngineMessage(message) } } index += 1 } } - + for case let .MessageEntry(message, _, _, _, _, _) in historyView.filteredEntries { - return message + return EngineMessage(message) } } return nil @@ -3627,24 +3627,24 @@ public final class ChatHistoryListNodeImpl: ListViewImpl, ChatHistoryNode, ChatH } } - public func latestMessageInCurrentHistoryView() -> Message? { + public func latestMessageInCurrentHistoryView() -> EngineMessage? { if let historyView = self.historyView { if historyView.originalView.laterId == nil, let firstEntry = historyView.filteredEntries.last { if case let .MessageEntry(message, _, _, _, _, _) = firstEntry { - return message + return EngineMessage(message) } } } return nil } - - public func firstMessageForEditInCurrentHistoryView() -> Message? { + + public func firstMessageForEditInCurrentHistoryView() -> EngineMessage? { if let historyView = self.historyView { if historyView.originalView.laterId == nil { for entry in historyView.filteredEntries.reversed() { if case let .MessageEntry(message, _, _, _, _, _) = entry { if canEditMessage(context: context, limitsConfiguration: context.currentLimitsConfiguration.with { EngineConfiguration.Limits($0) }, message: message) { - return message + return EngineMessage(message) } } } @@ -3653,45 +3653,45 @@ public final class ChatHistoryListNodeImpl: ListViewImpl, ChatHistoryNode, ChatH return nil } - public func messageInCurrentHistoryView(after messageId: MessageId) -> Message? { + public func messageInCurrentHistoryView(after messageId: EngineMessage.Id) -> EngineMessage? { if let historyView = self.historyView { if let index = historyView.filteredEntries.firstIndex(where: { $0.firstIndex.id == messageId }), index < historyView.filteredEntries.count - 1 { let nextEntry = historyView.filteredEntries[index + 1] if case let .MessageEntry(message, _, _, _, _, _) = nextEntry { - return message + return EngineMessage(message) } else if case let .MessageGroupEntry(_, messages, _) = nextEntry, let firstMessage = messages.first { - return firstMessage.0 + return EngineMessage(firstMessage.0) } } } return nil } - - public func messageInCurrentHistoryView(before messageId: MessageId) -> Message? { + + public func messageInCurrentHistoryView(before messageId: EngineMessage.Id) -> EngineMessage? { if let historyView = self.historyView { if let index = historyView.filteredEntries.firstIndex(where: { $0.firstIndex.id == messageId }), index > 0 { let nextEntry = historyView.filteredEntries[index - 1] if case let .MessageEntry(message, _, _, _, _, _) = nextEntry { - return message + return EngineMessage(message) } else if case let .MessageGroupEntry(_, messages, _) = nextEntry, let firstMessage = messages.first { - return firstMessage.0 + return EngineMessage(firstMessage.0) } } } return nil } - public func messageInCurrentHistoryView(_ id: MessageId) -> Message? { + public func messageInCurrentHistoryView(_ id: EngineMessage.Id) -> EngineMessage? { if let historyView = self.historyView { for entry in historyView.filteredEntries { if case let .MessageEntry(message, _, _, _, _, _) = entry { if message.id == id { - return message + return EngineMessage(message) } } else if case let .MessageGroupEntry(_, messages, _) = entry { for (message, _, _, _, _) in messages { if message.id == id { - return message + return EngineMessage(message) } } } @@ -4637,7 +4637,7 @@ public final class ChatHistoryListNodeImpl: ListViewImpl, ChatHistoryNode, ChatH } } - func lastVisbleMesssage() -> Message? { + func lastVisbleMesssage() -> EngineMessage? { var currentMessage: Message? if let historyView = self.historyView { if let visibleRange = self.displayedItemRange.visibleRange { @@ -4656,7 +4656,7 @@ public final class ChatHistoryListNodeImpl: ListViewImpl, ChatHistoryNode, ChatH } } } - return currentMessage + return currentMessage.flatMap(EngineMessage.init) } func immediateScrollState() -> ChatInterfaceHistoryScrollState? { diff --git a/submodules/TelegramUI/Sources/ChatHistoryNode.swift b/submodules/TelegramUI/Sources/ChatHistoryNode.swift index 6d8721b3b8..83885d27b0 100644 --- a/submodules/TelegramUI/Sources/ChatHistoryNode.swift +++ b/submodules/TelegramUI/Sources/ChatHistoryNode.swift @@ -1,11 +1,11 @@ import Foundation import UIKit import AsyncDisplayKit -import Postbox import SwiftSignalKit import Display import ChatPresentationInterfaceState import AccountContext +import TelegramCore public enum ChatHistoryNodeLoadState: Equatable { public enum EmptyType: Equatable { @@ -15,7 +15,7 @@ public enum ChatHistoryNodeLoadState: Equatable { case topic case botInfo } - + case loading(Bool) case empty(EmptyType) case messages @@ -24,11 +24,11 @@ public enum ChatHistoryNodeLoadState: Equatable { public protocol ChatHistoryNode: AnyObject { var historyState: ValuePromise { get } var preloadPages: Bool { get set } - + var loadState: ChatHistoryNodeLoadState? { get } func setLoadStateUpdated(_ f: @escaping (ChatHistoryNodeLoadState, Bool) -> Void) - - func messageInCurrentHistoryView(_ id: MessageId) -> Message? + + func messageInCurrentHistoryView(_ id: EngineMessage.Id) -> EngineMessage? func updateLayout(transition: ContainedViewLayoutTransition, updateSizeAndInsets: ListViewUpdateSizeAndInsets) func forEachItemNode(_ f: (ASDisplayNode) -> Void) func disconnect() diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift index ee3c2eeaee..2025847615 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift @@ -1524,7 +1524,7 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState var activeTodo: TelegramMediaTodo? for media in message.media { if let poll = media as? TelegramMediaPoll, !poll.isClosed, message.id.namespace == Namespaces.Message.Cloud, poll.pollId.namespace == Namespaces.Media.CloudPoll { - if !isPollEffectivelyClosed(message: message, poll: poll) { + if !isPollEffectivelyClosed(message: EngineMessage(message), poll: poll) { activePoll = poll } } else if let todo = media as? TelegramMediaTodo { @@ -2180,7 +2180,7 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState guard let chatController = interfaceInteraction.chatController() as? ChatController else { return } - chatController.presentReactionDeletionOptions(author: peer._asPeer(), messageId: message.id) + chatController.presentReactionDeletionOptions(author: peer, messageId: message.id) }) } } else { @@ -2710,7 +2710,7 @@ func chatAvailableMessageActionsImpl(engine: TelegramEngine, accountPeerId: Peer commonTags = nil } - return ChatAvailableMessageActions(options: reducedOptions, banAuthor: banPeer, banAuthors: banPeers, disableDelete: disableDelete, isCopyProtected: isCopyProtected, setTag: setTag, editTags: commonTags ?? Set()) + return ChatAvailableMessageActions(options: reducedOptions, banAuthor: banPeer.flatMap(EnginePeer.init), banAuthors: banPeers.map(EnginePeer.init), disableDelete: disableDelete, isCopyProtected: isCopyProtected, setTag: setTag, editTags: commonTags ?? Set()) } else { return ChatAvailableMessageActions(options: [], banAuthor: nil, banAuthors: [], disableDelete: false, isCopyProtected: isCopyProtected, setTag: false, editTags: Set()) } diff --git a/submodules/TelegramUI/Sources/ChatInviteRequestsTitlePanelNode.swift b/submodules/TelegramUI/Sources/ChatInviteRequestsTitlePanelNode.swift index b80d3cdb95..bd86622a5a 100644 --- a/submodules/TelegramUI/Sources/ChatInviteRequestsTitlePanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatInviteRequestsTitlePanelNode.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import Display import AsyncDisplayKit -import Postbox import TelegramCore import TelegramPresentationData import LocalizedPeerData @@ -47,7 +46,7 @@ private final class ChatInfoTitlePanelPeerNearbyInfoNode: ASDisplayNode { self.openPeersNearby() } - func update(width: CGFloat, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, chatPeer: Peer, distance: Int32, transition: ContainedViewLayoutTransition) -> CGFloat { + func update(width: CGFloat, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, chatPeer: EnginePeer, distance: Int32, transition: ContainedViewLayoutTransition) -> CGFloat { let primaryTextColor = serviceMessageColorComponents(theme: theme, wallpaper: wallpaper).primaryText if self.theme !== theme { @@ -60,7 +59,7 @@ private final class ChatInfoTitlePanelPeerNearbyInfoNode: ASDisplayNode { let bottomInset: CGFloat = 6.0 let sideInset: CGFloat = 16.0 - let stringAndRanges = strings.Conversation_PeerNearbyDistance(EnginePeer(chatPeer).compactDisplayTitle, shortStringForDistance(strings: strings, distance: distance)) + let stringAndRanges = strings.Conversation_PeerNearbyDistance(chatPeer.compactDisplayTitle, shortStringForDistance(strings: strings, distance: distance)) let attributedString = NSMutableAttributedString(string: stringAndRanges.string, font: Font.regular(13.0), textColor: primaryTextColor) @@ -139,7 +138,7 @@ final class ChatInviteRequestsTitlePanelNode: ChatTitleAccessoryPanelNode { private var theme: PresentationTheme? - private var peerId: PeerId? + private var peerId: EnginePeer.Id? private var peers: [EnginePeer] = [] private var count: Int32 = 0 @@ -184,7 +183,7 @@ final class ChatInviteRequestsTitlePanelNode: ChatTitleAccessoryPanelNode { } - func update(peerId: PeerId, peers: [EnginePeer], count: Int32) { + func update(peerId: EnginePeer.Id, peers: [EnginePeer], count: Int32) { self.peerId = peerId self.peers = peers self.count = count diff --git a/submodules/TelegramUI/Sources/ChatMessageActionUrlAuthController.swift b/submodules/TelegramUI/Sources/ChatMessageActionUrlAuthController.swift index 4e65670b29..1b29e65e76 100644 --- a/submodules/TelegramUI/Sources/ChatMessageActionUrlAuthController.swift +++ b/submodules/TelegramUI/Sources/ChatMessageActionUrlAuthController.swift @@ -3,7 +3,6 @@ import UIKit import SwiftSignalKit import AsyncDisplayKit import Display -import Postbox import TelegramCore import TelegramPresentationData import TelegramUIPreferences @@ -24,7 +23,7 @@ private final class ChatMessageActionUrlAuthAlertContentNode: AlertContentNode { private let nameDisplayOrder: PresentationPersonNameOrder private let defaultUrl: String private let domain: String - private let bot: Peer + private let bot: EnginePeer private let displayName: String private let titleNode: ASTextNode @@ -62,7 +61,7 @@ private final class ChatMessageActionUrlAuthAlertContentNode: AlertContentNode { } } - init(theme: AlertControllerTheme, ptheme: PresentationTheme, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder, defaultUrl: String, domain: String, bot: Peer, requestWriteAccess: Bool, displayName: String, actions: [TextAlertAction]) { + init(theme: AlertControllerTheme, ptheme: PresentationTheme, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder, defaultUrl: String, domain: String, bot: EnginePeer, requestWriteAccess: Bool, displayName: String, actions: [TextAlertAction]) { self.strings = strings self.nameDisplayOrder = nameDisplayOrder self.defaultUrl = defaultUrl @@ -163,7 +162,7 @@ private final class ChatMessageActionUrlAuthAlertContentNode: AlertContentNode { self.textNode.attributedText = formattedText(strings.Conversation_OpenBotLinkText(self.defaultUrl).string, color: theme.primaryColor, textAlignment: .center) self.authorizeLabelNode.attributedText = formattedText(strings.Conversation_OpenBotLinkLogin(self.domain, self.displayName).string, color: theme.primaryColor) - self.allowWriteLabelNode.attributedText = formattedText(strings.Conversation_OpenBotLinkAllowMessages(EnginePeer(self.bot).displayTitle(strings: self.strings, displayOrder: self.nameDisplayOrder)).string, color: theme.primaryColor) + self.allowWriteLabelNode.attributedText = formattedText(strings.Conversation_OpenBotLinkAllowMessages(self.bot.displayTitle(strings: self.strings, displayOrder: self.nameDisplayOrder)).string, color: theme.primaryColor) self.actionNodesSeparator.backgroundColor = theme.separatorColor for actionNode in self.actionNodes { @@ -301,7 +300,7 @@ private final class ChatMessageActionUrlAuthAlertContentNode: AlertContentNode { } } -func chatMessageActionUrlAuthController(context: AccountContext, defaultUrl: String, domain: String, bot: Peer, requestWriteAccess: Bool, displayName: String, open: @escaping (Bool, Bool) -> Void) -> AlertController { +func chatMessageActionUrlAuthController(context: AccountContext, defaultUrl: String, domain: String, bot: EnginePeer, requestWriteAccess: Bool, displayName: String, open: @escaping (Bool, Bool) -> Void) -> AlertController { let presentationData = context.sharedContext.currentPresentationData.with { $0 } let theme = presentationData.theme let strings = presentationData.strings diff --git a/submodules/TelegramUI/Sources/ChatMessageContextControllerContentSource.swift b/submodules/TelegramUI/Sources/ChatMessageContextControllerContentSource.swift index ddc1729688..78d6cb1f9d 100644 --- a/submodules/TelegramUI/Sources/ChatMessageContextControllerContentSource.swift +++ b/submodules/TelegramUI/Sources/ChatMessageContextControllerContentSource.swift @@ -3,7 +3,6 @@ import UIKit import AsyncDisplayKit import Display import ContextUI -import Postbox import TelegramCore import SwiftSignalKit import ChatMessageItemView @@ -38,7 +37,7 @@ final class ChatMessageContextExtractedContentSource: ContextExtractedContentSou private weak var chatController: ChatControllerImpl? private weak var chatNode: ChatControllerNode? private let engine: TelegramEngine - private let message: Message + private let message: EngineMessage private let selectAll: Bool private let snapshot: Bool @@ -61,7 +60,7 @@ final class ChatMessageContextExtractedContentSource: ContextExtractedContentSou |> distinctUntilChanged } - init(chatController: ChatControllerImpl, chatNode: ChatControllerNode, engine: TelegramEngine, message: Message, selectAll: Bool, centerVertically: Bool = false, keepDefaultContentTouches: Bool = false, snapshot: Bool = false) { + init(chatController: ChatControllerImpl, chatNode: ChatControllerNode, engine: TelegramEngine, message: EngineMessage, selectAll: Bool, centerVertically: Bool = false, keepDefaultContentTouches: Bool = false, snapshot: Bool = false) { self.chatController = chatController self.chatNode = chatNode self.engine = engine @@ -134,7 +133,7 @@ final class ChatViewOnceMessageContextExtractedContentSource: ContextExtractedCo private weak var chatNode: ChatControllerNode? private weak var backgroundNode: WallpaperBackgroundNode? private let engine: TelegramEngine - private let message: Message + private let message: EngineMessage private let present: (ViewController) -> Void private var messageNodeCopy: ChatMessageItemView? @@ -167,7 +166,7 @@ final class ChatViewOnceMessageContextExtractedContentSource: ContextExtractedCo ) } - init(context: AccountContext, presentationData: PresentationData, chatNode: ChatControllerNode, backgroundNode: WallpaperBackgroundNode, engine: TelegramEngine, message: Message, present: @escaping (ViewController) -> Void) { + init(context: AccountContext, presentationData: PresentationData, chatNode: ChatControllerNode, backgroundNode: WallpaperBackgroundNode, engine: TelegramEngine, message: EngineMessage, present: @escaping (ViewController) -> Void) { self.context = context self.presentationData = presentationData self.chatNode = chatNode @@ -220,7 +219,7 @@ final class ChatViewOnceMessageContextExtractedContentSource: ContextExtractedCo if (isIncoming || "".isEmpty) { let messageItem = self.context.sharedContext.makeChatMessagePreviewItem( context: self.context, - messages: [self.message], + messages: [self.message._asMessage()], theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, @@ -424,7 +423,7 @@ final class ChatMessageReactionContextExtractedContentSource: ContextExtractedCo private weak var chatNode: ChatControllerNode? private let engine: TelegramEngine - private let message: Message + private let message: EngineMessage private let contentView: ContextExtractedContentContainingView var shouldBeDismissed: Signal { @@ -443,7 +442,7 @@ final class ChatMessageReactionContextExtractedContentSource: ContextExtractedCo |> distinctUntilChanged } - init(chatNode: ChatControllerNode, engine: TelegramEngine, message: Message, contentView: ContextExtractedContentContainingView) { + init(chatNode: ChatControllerNode, engine: TelegramEngine, message: EngineMessage, contentView: ContextExtractedContentContainingView) { self.chatNode = chatNode self.engine = engine self.message = message diff --git a/submodules/TelegramUI/Sources/ChatMessageThrottledProcessingManager.swift b/submodules/TelegramUI/Sources/ChatMessageThrottledProcessingManager.swift index aa33bf57c3..825dfc9748 100644 --- a/submodules/TelegramUI/Sources/ChatMessageThrottledProcessingManager.swift +++ b/submodules/TelegramUI/Sources/ChatMessageThrottledProcessingManager.swift @@ -1,6 +1,7 @@ import Foundation import UIKit import SwiftSignalKit +import TelegramCore final class ChatMessageThrottledProcessingManager { private let queue = Queue.mainQueue() @@ -8,25 +9,25 @@ final class ChatMessageThrottledProcessingManager { private let delay: Double private let submitInterval: Double? - var process: ((Set) -> Void)? + var process: ((Set) -> Void)? private var timer: SwiftSignalKit.Timer? - private var processedList: [MessageAndThreadId] = [] - private var processed: [MessageAndThreadId: Double] = [:] - private var buffer = Set() + private var processedList: [EngineMessageAndThreadId] = [] + private var processed: [EngineMessageAndThreadId: Double] = [:] + private var buffer = Set() init(delay: Double = 1.0, submitInterval: Double? = nil) { self.delay = delay self.submitInterval = submitInterval } - func setProcess(process: @escaping (Set) -> Void) { + func setProcess(process: @escaping (Set) -> Void) { self.queue.async { self.process = process } } - func add(_ messageIds: [MessageAndThreadId]) { + func add(_ messageIds: [EngineMessageAndThreadId]) { self.queue.async { let timestamp = CFAbsoluteTimeGetCurrent() @@ -79,9 +80,9 @@ final class ChatMessageVisibleThrottledProcessingManager { private let interval: Double - private var currentIds = Set() + private var currentIds = Set() - var process: ((Set) -> Void)? + var process: ((Set) -> Void)? private let timer: SwiftSignalKit.Timer @@ -106,13 +107,13 @@ final class ChatMessageVisibleThrottledProcessingManager { self.timer.invalidate() } - func setProcess(process: @escaping (Set) -> Void) { + func setProcess(process: @escaping (Set) -> Void) { self.queue.async { self.process = process } } - func update(_ ids: Set) { + func update(_ ids: Set) { self.queue.async { if self.currentIds != ids { self.currentIds = ids diff --git a/submodules/TelegramUI/Sources/ChatReportPeerTitlePanelNode.swift b/submodules/TelegramUI/Sources/ChatReportPeerTitlePanelNode.swift index 9dcafa3e61..28c8125fab 100644 --- a/submodules/TelegramUI/Sources/ChatReportPeerTitlePanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatReportPeerTitlePanelNode.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import Display import AsyncDisplayKit -import Postbox import SwiftSignalKit import TelegramCore import TelegramPresentationData @@ -184,24 +183,24 @@ private final class ChatInfoTitlePanelInviteInfoNode: ASDisplayNode { return result } - func update(width: CGFloat, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, chatPeer: Peer, invitedBy: Peer, transition: ContainedViewLayoutTransition) -> CGFloat { + func update(width: CGFloat, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, chatPeer: EnginePeer, invitedBy: EnginePeer, transition: ContainedViewLayoutTransition) -> CGFloat { let primaryTextColor = serviceMessageColorComponents(theme: theme, wallpaper: wallpaper).primaryText - + if self.theme !== theme { self.theme = theme - + self.labelNode.linkHighlightColor = primaryTextColor.withAlphaComponent(0.3) } - + let topInset: CGFloat = 6.0 let bottomInset: CGFloat = 6.0 let sideInset: CGFloat = 16.0 - + let stringAndRanges: PresentationStrings.FormattedString - if let channel = chatPeer as? TelegramChannel, case .broadcast = channel.info { - stringAndRanges = strings.Conversation_NoticeInvitedByInChannel(EnginePeer(invitedBy).compactDisplayTitle) + if case let .channel(channel) = chatPeer, case .broadcast = channel.info { + stringAndRanges = strings.Conversation_NoticeInvitedByInChannel(invitedBy.compactDisplayTitle) } else { - stringAndRanges = strings.Conversation_NoticeInvitedByInGroup(EnginePeer(invitedBy).compactDisplayTitle) + stringAndRanges = strings.Conversation_NoticeInvitedByInGroup(invitedBy.compactDisplayTitle) } let attributedString = NSMutableAttributedString(string: stringAndRanges.string, font: Font.regular(13.0), textColor: primaryTextColor) @@ -283,7 +282,7 @@ private final class ChatInfoTitlePanelPeerNearbyInfoNode: ASDisplayNode { self.openPeersNearby() } - func update(width: CGFloat, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, chatPeer: Peer, distance: Int32, transition: ContainedViewLayoutTransition) -> CGFloat { + func update(width: CGFloat, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, chatPeer: EnginePeer, distance: Int32, transition: ContainedViewLayoutTransition) -> CGFloat { let primaryTextColor = serviceMessageColorComponents(theme: theme, wallpaper: wallpaper).primaryText if self.theme !== theme { @@ -296,7 +295,7 @@ private final class ChatInfoTitlePanelPeerNearbyInfoNode: ASDisplayNode { let bottomInset: CGFloat = 6.0 let sideInset: CGFloat = 16.0 - let stringAndRanges = strings.Conversation_PeerNearbyDistance(EnginePeer(chatPeer).compactDisplayTitle, shortStringForDistance(strings: strings, distance: distance)) + let stringAndRanges = strings.Conversation_PeerNearbyDistance(chatPeer.compactDisplayTitle, shortStringForDistance(strings: strings, distance: distance)) let attributedString = NSMutableAttributedString(string: stringAndRanges.string, font: Font.regular(13.0), textColor: primaryTextColor) @@ -738,12 +737,13 @@ final class ChatReportPeerTitlePanelNode: ChatTitleAccessoryPanelNode { panelInset += 40.0 } - var chatPeer: Peer? + var chatPeer: EnginePeer? if let renderedPeer = interfaceState.renderedPeer { - chatPeer = renderedPeer.peers[renderedPeer.peerId] + chatPeer = renderedPeer.peers[renderedPeer.peerId].flatMap(EnginePeer.init) } var hitTestSlop: CGFloat = 0.0 - if let chatPeer = chatPeer, (updatedButtons.contains(.block) || updatedButtons.contains(.reportSpam) || updatedButtons.contains(.reportUserSpam)), let invitedBy = interfaceState.contactStatus?.invitedBy { + if let chatPeer = chatPeer, (updatedButtons.contains(.block) || updatedButtons.contains(.reportSpam) || updatedButtons.contains(.reportUserSpam)), let invitedByPeer = interfaceState.contactStatus?.invitedBy { + let invitedBy = EnginePeer(invitedByPeer) var inviteInfoTransition = transition let inviteInfoNode: ChatInfoTitlePanelInviteInfoNode if let current = self.inviteInfoNode { diff --git a/submodules/TelegramUI/Sources/CommandChatInputContextPanelNode.swift b/submodules/TelegramUI/Sources/CommandChatInputContextPanelNode.swift index aef09615e3..0a652d4f18 100644 --- a/submodules/TelegramUI/Sources/CommandChatInputContextPanelNode.swift +++ b/submodules/TelegramUI/Sources/CommandChatInputContextPanelNode.swift @@ -1,7 +1,6 @@ import Foundation import UIKit import AsyncDisplayKit -import Postbox import TelegramCore import Display import TelegramPresentationData @@ -211,7 +210,7 @@ private struct CommandChatInputContextPanelEntry: Comparable, Identifiable { context: context, chatListLocation: .chatList(groupId: .root), filterData: nil, - index: EngineChatList.Item.Index.chatList(ChatListIndex(pinningIndex: nil, messageIndex: MessageIndex(id: MessageId(peerId: context.account.peerId, namespace: 0, id: 0), timestamp: 0))), + index: EngineChatList.Item.Index.chatList(EngineChatListIndex(pinningIndex: nil, messageIndex: EngineMessage.Index(id: EngineMessage.Id(peerId: context.account.peerId, namespace: 0, id: 0), timestamp: 0))), content: .peer(ChatListItemContent.PeerData( messages: [shortcut.topMessage], peer: renderedPeer, @@ -368,7 +367,7 @@ final class CommandChatInputContextPanelNode: ChatInputContextPanelNode { switch command { case let .command(command): if sendImmediately { - interfaceInteraction.sendBotCommand(command.peer, "/" + command.command.text) + interfaceInteraction.sendBotCommand(command.peer._asPeer(), "/" + command.command.text) } else { interfaceInteraction.updateTextInputStateAndMode { textInputState, inputMode in var commandQueryRange: NSRange? diff --git a/submodules/TelegramUI/Sources/CommandChatInputPanelItem.swift b/submodules/TelegramUI/Sources/CommandChatInputPanelItem.swift index cc50e28b30..e345014502 100644 --- a/submodules/TelegramUI/Sources/CommandChatInputPanelItem.swift +++ b/submodules/TelegramUI/Sources/CommandChatInputPanelItem.swift @@ -140,7 +140,7 @@ final class CommandChatInputPanelItemNode: ListViewItemNode { let leftInset: CGFloat = 55.0 + params.leftInset let rightInset: CGFloat = 10.0 + params.rightInset - let peerName = EnginePeer(item.command.peer).displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder) + let peerName = item.command.peer.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder) let commandString = NSMutableAttributedString() commandString.append(NSAttributedString(string: "/" + item.command.command.text, font: textFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor)) @@ -165,7 +165,7 @@ final class CommandChatInputPanelItemNode: ListViewItemNode { strongSelf.arrowNode.setImage(iconImage, for: []) - strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(item.command.peer), emptyColor: item.presentationData.theme.list.mediaPlaceholderColor) + strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: item.command.peer, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor) let _ = textApply() diff --git a/submodules/TelegramUI/Sources/CommandMenuChatInputContextPanelNode.swift b/submodules/TelegramUI/Sources/CommandMenuChatInputContextPanelNode.swift index 289d41a949..6c54824092 100644 --- a/submodules/TelegramUI/Sources/CommandMenuChatInputContextPanelNode.swift +++ b/submodules/TelegramUI/Sources/CommandMenuChatInputContextPanelNode.swift @@ -151,7 +151,7 @@ final class CommandMenuChatInputContextPanelNode: ChatInputContextPanelNode { let transition = preparedTransition(from: from ?? [], to: to, context: self.context, fontSize: self.fontSize, commandSelected: { [weak self] command, sendImmediately in if let strongSelf = self, let interfaceInteraction = strongSelf.interfaceInteraction { if sendImmediately { - interfaceInteraction.sendBotCommand(command.peer, "/" + command.command.text) + interfaceInteraction.sendBotCommand(command.peer._asPeer(), "/" + command.command.text) } else { interfaceInteraction.updateShowCommands { _ in return false } interfaceInteraction.updateTextInputStateAndMode { textInputState, inputMode in diff --git a/submodules/TelegramUI/Sources/ComposeController.swift b/submodules/TelegramUI/Sources/ComposeController.swift index cf07ca09e6..5cfef2a4fd 100644 --- a/submodules/TelegramUI/Sources/ComposeController.swift +++ b/submodules/TelegramUI/Sources/ComposeController.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import Display import AsyncDisplayKit -import Postbox import SwiftSignalKit import TelegramCore import TelegramPresentationData @@ -22,8 +21,6 @@ public class ComposeControllerImpl: ViewController, ComposeController { return self.displayNode as! ComposeControllerNode } - private let index: PeerNameIndex = .lastNameFirst - private var _ready = Promise() override public var ready: Promise { return self._ready @@ -312,7 +309,7 @@ public class ComposeControllerImpl: ViewController, ComposeController { } } - private func openPeer(peerId: PeerId) { + private func openPeer(peerId: EnginePeer.Id) { (self.navigationController as? NavigationController)?.replaceTopController(ChatControllerImpl(context: self.context, chatLocation: .peer(id: peerId)), animated: true) } diff --git a/submodules/TelegramUI/Sources/ContactMultiselectionController.swift b/submodules/TelegramUI/Sources/ContactMultiselectionController.swift index c7965a6879..b0d6291295 100644 --- a/submodules/TelegramUI/Sources/ContactMultiselectionController.swift +++ b/submodules/TelegramUI/Sources/ContactMultiselectionController.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import Display import AsyncDisplayKit -import Postbox import SwiftSignalKit import TelegramCore import TelegramPresentationData @@ -18,7 +17,7 @@ import PremiumUI import UndoUI import ContextUI -private func peerTokenTitle(accountPeerId: PeerId, peer: EnginePeer, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder) -> String { +private func peerTokenTitle(accountPeerId: EnginePeer.Id, peer: EnginePeer, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder) -> String { if peer.id == accountPeerId { return strings.DialogList_SavedMessages } else if peer.id.isReplies { @@ -43,8 +42,6 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection var dismissed: (() -> Void)? - private let index: PeerNameIndex = .lastNameFirst - private var _ready = Promise() private var _limitsReady = Promise() private var _peersReady = Promise() diff --git a/submodules/TelegramUI/Sources/ContactMultiselectionControllerNode.swift b/submodules/TelegramUI/Sources/ContactMultiselectionControllerNode.swift index 5ff26d31e7..881bfd5b67 100644 --- a/submodules/TelegramUI/Sources/ContactMultiselectionControllerNode.swift +++ b/submodules/TelegramUI/Sources/ContactMultiselectionControllerNode.swift @@ -1,7 +1,6 @@ import Display import UIKit import AsyncDisplayKit -import Postbox import TelegramCore import SwiftSignalKit import TelegramPresentationData @@ -20,16 +19,16 @@ import CheckComponent private struct SearchResultEntry: Identifiable { let index: Int - let peer: Peer - + let peer: EnginePeer + var stableId: Int64 { return self.peer.id.toInt64() } - + static func ==(lhs: SearchResultEntry, rhs: SearchResultEntry) -> Bool { - return lhs.index == rhs.index && lhs.peer.isEqual(rhs.peer) + return lhs.index == rhs.index && lhs.peer == rhs.peer } - + static func <(lhs: SearchResultEntry, rhs: SearchResultEntry) -> Bool { return lhs.index < rhs.index } @@ -327,7 +326,7 @@ final class ContactMultiselectionControllerNode: ASDisplayNode { let searchText = ValuePromise() self.tokenListNode.deleteToken = { [weak self] id in - if let id = id as? PeerId { + if let id = id as? EnginePeer.Id { self?.removeSelectedPeer?(ContactListPeerId.peer(id)) } else if let id = id as? Int { self?.removeSelectedCategory?(id) diff --git a/submodules/TelegramUI/Sources/ContactSelectionController.swift b/submodules/TelegramUI/Sources/ContactSelectionController.swift index b9a6e0977a..a475db9a80 100644 --- a/submodules/TelegramUI/Sources/ContactSelectionController.swift +++ b/submodules/TelegramUI/Sources/ContactSelectionController.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import Display import AsyncDisplayKit -import Postbox import SwiftSignalKit import TelegramCore import TelegramPresentationData @@ -39,7 +38,6 @@ class ContactSelectionControllerImpl: ViewController, ContactSelectionController } } - private let index: PeerNameIndex = .lastNameFirst private let titleProducer: (PresentationStrings) -> String private let options: Signal<[ContactListAdditionalOption], NoError> private let displayDeviceContacts: Bool diff --git a/submodules/TelegramUI/Sources/CreateChannelController.swift b/submodules/TelegramUI/Sources/CreateChannelController.swift index eddc7f5297..3345411ed1 100644 --- a/submodules/TelegramUI/Sources/CreateChannelController.swift +++ b/submodules/TelegramUI/Sources/CreateChannelController.swift @@ -3,7 +3,6 @@ import UIKit import Display import SSignalKit import SwiftSignalKit -import Postbox import TelegramCore import TelegramPresentationData import LegacyComponents @@ -72,7 +71,7 @@ private enum CreateChannelEntryTag: ItemListItemTag { } private enum CreateChannelEntry: ItemListNodeEntry { - case channelInfo(PresentationTheme, PresentationStrings, PresentationDateTimeFormat, Peer?, ItemListAvatarAndNameInfoItemState, ItemListAvatarAndNameInfoItemUpdatingAvatar?) + case channelInfo(PresentationTheme, PresentationStrings, PresentationDateTimeFormat, EnginePeer?, ItemListAvatarAndNameInfoItemState, ItemListAvatarAndNameInfoItemUpdatingAvatar?) case setProfilePhoto(PresentationTheme, String) case descriptionSetup(PresentationTheme, String, String) @@ -128,11 +127,7 @@ private enum CreateChannelEntry: ItemListNodeEntry { if lhsDateTimeFormat != rhsDateTimeFormat { return false } - if let lhsPeer = lhsPeer, let rhsPeer = rhsPeer { - if !lhsPeer.isEqual(rhsPeer) { - return false - } - } else if (lhsPeer != nil) != (rhsPeer != nil) { + if lhsPeer != rhsPeer { return false } if lhsEditingState != rhsEditingState { @@ -198,7 +193,7 @@ private enum CreateChannelEntry: ItemListNodeEntry { let arguments = arguments as! CreateChannelArguments switch self { case let .channelInfo(_, _, dateTimeFormat, peer, state, avatar): - return ItemListAvatarAndNameInfoItem(itemContext: .accountContext(arguments.context), presentationData: presentationData, systemStyle: .glass, dateTimeFormat: dateTimeFormat, mode: .editSettings, peer: peer.flatMap(EnginePeer.init), presence: nil, memberCount: nil, state: state, sectionId: ItemListSectionId(self.section), style: .blocks(withTopInset: false, withExtendedBottomInset: false), editingNameUpdated: { editingName in + return ItemListAvatarAndNameInfoItem(itemContext: .accountContext(arguments.context), presentationData: presentationData, systemStyle: .glass, dateTimeFormat: dateTimeFormat, mode: .editSettings, peer: peer, presence: nil, memberCount: nil, state: state, sectionId: ItemListSectionId(self.section), style: .blocks(withTopInset: false, withExtendedBottomInset: false), editingNameUpdated: { editingName in arguments.updateEditingName(editingName) }, editingNameCompleted: { arguments.focusOnDescription() @@ -286,9 +281,9 @@ private func CreateChannelEntries(presentationData: PresentationData, state: Cre let groupInfoState = ItemListAvatarAndNameInfoItemState(editingName: state.editingName, updatingName: nil) - let peer = TelegramGroup(id: PeerId(namespace: .max, id: PeerId.Id._internalFromInt64Value(0)), title: state.editingName.composedTitle, photo: [], participantCount: 0, role: .creator(rank: nil), membership: .Member, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0) - - entries.append(.channelInfo(presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, peer, groupInfoState, state.avatar)) + let peer = TelegramGroup(id: EnginePeer.Id(namespace: .max, id: EnginePeer.Id.Id._internalFromInt64Value(0)), title: state.editingName.composedTitle, photo: [], participantCount: 0, role: .creator(rank: nil), membership: .Member, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0) + + entries.append(.channelInfo(presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, EnginePeer(peer), groupInfoState, state.avatar)) entries.append(.descriptionSetup(presentationData.theme, presentationData.strings.Channel_Edit_AboutItem, state.editingDescriptionText)) entries.append(.descriptionInfo(presentationData.theme, presentationData.strings.Channel_About_Help)) @@ -350,7 +345,7 @@ public enum CreateChannelMode { case requestPeer(ReplyMarkupButtonRequestPeerType.Channel) } -public func createChannelController(context: AccountContext, mode: CreateChannelMode = .generic, willComplete: @escaping (String, @escaping () -> Void) -> Void = { _, complete in complete() }, completion: ((PeerId, @escaping () -> Void) -> Void)? = nil) -> ViewController { +public func createChannelController(context: AccountContext, mode: CreateChannelMode = .generic, willComplete: @escaping (String, @escaping () -> Void) -> Void = { _, complete in complete() }, completion: ((EnginePeer.Id, @escaping () -> Void) -> Void)? = nil) -> ViewController { let initialState = CreateChannelState(creating: false, editingName: ItemListAvatarAndNameInfoItemName.title(title: "", type: .channel), editingDescriptionText: "", avatar: nil) let statePromise = ValuePromise(initialState, ignoreRepeated: true) let stateValue = Atomic(value: initialState) @@ -431,7 +426,7 @@ public func createChannelController(context: AccountContext, mode: CreateChannel endEditingImpl?() - var createSignal: Signal = context.engine.peers.createChannel(title: title, description: description.isEmpty ? nil : description) + var createSignal: Signal = context.engine.peers.createChannel(title: title, description: description.isEmpty ? nil : description) if case .requestPeer = mode { if let publicLink, !publicLink.isEmpty { createSignal = createSignal @@ -633,7 +628,7 @@ public func createChannelController(context: AccountContext, mode: CreateChannel return updated } - checkAddressNameDisposable.set((context.engine.peers.validateAddressNameInteractive(domain: .peer(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(0))), name: text) + checkAddressNameDisposable.set((context.engine.peers.validateAddressNameInteractive(domain: .peer(EnginePeer.Id(namespace: Namespaces.Peer.CloudGroup, id: EnginePeer.Id.Id._internalFromInt64Value(0))), name: text) |> deliverOnMainQueue).start(next: { result in updateState { state in var updated = state diff --git a/submodules/TelegramUI/Sources/FetchResource.swift b/submodules/TelegramUI/Sources/FetchResource.swift deleted file mode 100644 index 0210791a26..0000000000 --- a/submodules/TelegramUI/Sources/FetchResource.swift +++ /dev/null @@ -1,9 +0,0 @@ -import Foundation -import Postbox -import TelegramCore -import SwiftSignalKit - -func fetchResource(account: Account, resource: MediaResource, intervals: Signal<[(Range, MediaBoxFetchPriority)], NoError>) -> Signal? { - return nil -} - diff --git a/submodules/TelegramUI/Sources/GalleryHiddenMediaManager.swift b/submodules/TelegramUI/Sources/GalleryHiddenMediaManager.swift index ae494a4432..43e16e1fc1 100644 --- a/submodules/TelegramUI/Sources/GalleryHiddenMediaManager.swift +++ b/submodules/TelegramUI/Sources/GalleryHiddenMediaManager.swift @@ -1,6 +1,6 @@ import Foundation import UIKit -import Postbox +import TelegramCore import SwiftSignalKit import AsyncDisplayKit import AccountContext @@ -144,7 +144,7 @@ final class GalleryHiddenMediaManagerImpl: GalleryHiddenMediaManager { } } - func findTarget(messageId: MessageId, media: Media) -> ((UIView) -> Void, ASDisplayNode, () -> (UIView?, UIView?))? { + func findTarget(messageId: EngineMessage.Id, media: EngineMedia) -> ((UIView) -> Void, ASDisplayNode, () -> (UIView?, UIView?))? { for i in (0 ..< self.targets.count).reversed() { if let holderTarget = self.targets[i].target { if let result = holderTarget.getTransitionInfo(messageId: messageId, media: media) { diff --git a/submodules/TelegramUI/Sources/MakeTempAccountContext.swift b/submodules/TelegramUI/Sources/MakeTempAccountContext.swift index 71dba3d413..7f594c5863 100644 --- a/submodules/TelegramUI/Sources/MakeTempAccountContext.swift +++ b/submodules/TelegramUI/Sources/MakeTempAccountContext.swift @@ -13,7 +13,7 @@ public func makeTempContext( appGroupPath: String, accountManager: AccountManager, appLockContext: AppLockContext, - encryptionParameters: ValueBoxEncryptionParameters, + encryptionParameters: EngineValueBoxEncryptionParameters, applicationBindings: TelegramApplicationBindings, initialPresentationDataAndSettings: InitialPresentationDataAndSettings, networkArguments: NetworkInitializationArguments, diff --git a/submodules/TelegramUI/Sources/OpenChatMessage.swift b/submodules/TelegramUI/Sources/OpenChatMessage.swift index d2b59d5a02..db5e01219c 100644 --- a/submodules/TelegramUI/Sources/OpenChatMessage.swift +++ b/submodules/TelegramUI/Sources/OpenChatMessage.swift @@ -479,7 +479,7 @@ func openChatMessageImpl(_ params: OpenChatMessageParams) -> Bool { } public func makeInstantPageControllerImpl(context: AccountContext, message: Message, sourcePeerType: MediaAutoDownloadPeerType?) -> ViewController? { - guard let (webpage, anchor) = instantPageAndAnchor(message: message) else { + guard let (webpage, anchor) = instantPageAndAnchor(message: EngineMessage(message)) else { return nil } let sourceLocation = InstantPageSourceLocation(userLocation: .peer(message.id.peerId), peerType: sourcePeerType ?? .channel) diff --git a/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift b/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift index 213aa143fe..1f0fd76396 100644 --- a/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift +++ b/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift @@ -471,7 +471,7 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, ASGestu } openMessageImpl = { [weak self] id in - if let strongSelf = self, strongSelf.isNodeLoaded, let message = strongSelf.historyNode.messageInCurrentHistoryView(id) { + if let strongSelf = self, strongSelf.isNodeLoaded, let message = strongSelf.historyNode.messageInCurrentHistoryView(id)?._asMessage() { var playlistLocation: PeerMessagesPlaylistLocation? if let location = strongSelf.playlistLocation as? PeerMessagesPlaylistLocation { if case let .custom(messages, canReorder, _, loadMore, hidePanel) = location { diff --git a/submodules/TelegramUI/Sources/PeerMediaCollectionInterfaceState.swift b/submodules/TelegramUI/Sources/PeerMediaCollectionInterfaceState.swift index 5ef8ed2ef9..6b54a65b86 100644 --- a/submodules/TelegramUI/Sources/PeerMediaCollectionInterfaceState.swift +++ b/submodules/TelegramUI/Sources/PeerMediaCollectionInterfaceState.swift @@ -1,5 +1,5 @@ import Foundation -import Postbox +import TelegramCore import TelegramPresentationData import ChatInterfaceState @@ -11,12 +11,12 @@ enum PeerMediaCollectionMode: Int32 { } struct PeerMediaCollectionInterfaceState: Equatable { - let peer: Peer? + let peer: EnginePeer? let selectionState: ChatInterfaceSelectionState? let mode: PeerMediaCollectionMode let theme: PresentationTheme let strings: PresentationStrings - + init(theme: PresentationTheme, strings: PresentationStrings) { self.theme = theme self.strings = strings @@ -24,21 +24,17 @@ struct PeerMediaCollectionInterfaceState: Equatable { self.selectionState = nil self.mode = .photoOrVideo } - - init(peer: Peer?, selectionState: ChatInterfaceSelectionState?, mode: PeerMediaCollectionMode, theme: PresentationTheme, strings: PresentationStrings) { + + init(peer: EnginePeer?, selectionState: ChatInterfaceSelectionState?, mode: PeerMediaCollectionMode, theme: PresentationTheme, strings: PresentationStrings) { self.peer = peer self.selectionState = selectionState self.mode = mode self.theme = theme self.strings = strings } - + static func ==(lhs: PeerMediaCollectionInterfaceState, rhs: PeerMediaCollectionInterfaceState) -> Bool { - if let peer = lhs.peer { - if rhs.peer == nil || !peer.isEqual(rhs.peer!) { - return false - } - } else if let _ = rhs.peer { + if lhs.peer != rhs.peer { return false } @@ -61,8 +57,8 @@ struct PeerMediaCollectionInterfaceState: Equatable { return true } - func withUpdatedSelectedMessages(_ messageIds: [MessageId]) -> PeerMediaCollectionInterfaceState { - var selectedIds = Set() + func withUpdatedSelectedMessages(_ messageIds: [EngineMessage.Id]) -> PeerMediaCollectionInterfaceState { + var selectedIds = Set() if let selectionState = self.selectionState { selectedIds.formUnion(selectionState.selectedIds) } @@ -72,8 +68,8 @@ struct PeerMediaCollectionInterfaceState: Equatable { return PeerMediaCollectionInterfaceState(peer: self.peer, selectionState: ChatInterfaceSelectionState(selectedIds: selectedIds), mode: self.mode, theme: self.theme, strings: self.strings) } - func withToggledSelectedMessages(_ messageIds: [MessageId], value: Bool) -> PeerMediaCollectionInterfaceState { - var selectedIds = Set() + func withToggledSelectedMessages(_ messageIds: [EngineMessage.Id], value: Bool) -> PeerMediaCollectionInterfaceState { + var selectedIds = Set() if let selectionState = self.selectionState { selectedIds.formUnion(selectionState.selectedIds) } @@ -95,7 +91,7 @@ struct PeerMediaCollectionInterfaceState: Equatable { return PeerMediaCollectionInterfaceState(peer: self.peer, selectionState: nil, mode: self.mode, theme: self.theme, strings: self.strings) } - func withUpdatedPeer(_ peer: Peer?) -> PeerMediaCollectionInterfaceState { + func withUpdatedPeer(_ peer: EnginePeer?) -> PeerMediaCollectionInterfaceState { return PeerMediaCollectionInterfaceState(peer: peer, selectionState: self.selectionState, mode: self.mode, theme: self.theme, strings: self.strings) } diff --git a/submodules/TelegramUI/Sources/SaveMediaToFiles.swift b/submodules/TelegramUI/Sources/SaveMediaToFiles.swift index f644602b4c..ef91d38ffd 100644 --- a/submodules/TelegramUI/Sources/SaveMediaToFiles.swift +++ b/submodules/TelegramUI/Sources/SaveMediaToFiles.swift @@ -61,9 +61,7 @@ func saveMediaToFiles(context: AccountContext, fileReference: FileMediaReference case let .data(data): if data.isComplete { var symlinkPath = data.path + ".mp3" - if fileSize(symlinkPath) != nil { - try? FileManager.default.removeItem(atPath: symlinkPath) - } + try? FileManager.default.removeItem(atPath: symlinkPath) let _ = try? FileManager.default.linkItem(atPath: data.path, toPath: symlinkPath) let audioUrl = URL(fileURLWithPath: symlinkPath) diff --git a/submodules/TelegramUI/Sources/SharedAccountContext.swift b/submodules/TelegramUI/Sources/SharedAccountContext.swift index 3896988f1f..aab652e2ae 100644 --- a/submodules/TelegramUI/Sources/SharedAccountContext.swift +++ b/submodules/TelegramUI/Sources/SharedAccountContext.swift @@ -4485,7 +4485,7 @@ private func peerInfoControllerImpl(context: AccountContext, updatedPresentation } else if case .user = peer { var reactionSourceMessageId: MessageId? var sourceMessageId: MessageId? - var callMessages: [Message] = [] + var callMessages: [EngineMessage] = [] var hintGroupInCommon: PeerId? var forumTopicThread: ChatReplyThreadMessage? var sharedMediaFromForumTopic: (EnginePeer.Id, Int64)? diff --git a/submodules/TelegramUI/Sources/TelegramRootController.swift b/submodules/TelegramUI/Sources/TelegramRootController.swift index db5f613c5c..c5ea211173 100644 --- a/submodules/TelegramUI/Sources/TelegramRootController.swift +++ b/submodules/TelegramUI/Sources/TelegramRootController.swift @@ -2,7 +2,6 @@ import Foundation import UIKit import Display import AsyncDisplayKit -import Postbox import TelegramCore import SwiftSignalKit import TelegramPresentationData @@ -695,9 +694,9 @@ public final class TelegramRootController: NavigationController, TelegramRootCon if let mediaResult = result.media { switch mediaResult { case let .image(image, dimensions): - 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 imageData = compressImageToJPEG(image, quality: 0.7, tempFilePath: tempFile.path) { media = .image(dimensions: dimensions, data: imageData, stickers: result.stickers) @@ -705,8 +704,8 @@ public final class TelegramRootController: NavigationController, TelegramRootCon case let .video(content, firstFrameImage, values, duration, dimensions): let adjustments: VideoMediaResourceAdjustments if let valuesData = try? JSONEncoder().encode(values) { - let data = MemoryBuffer(data: valuesData) - let digest = MemoryBuffer(data: data.md5Digest()) + let data = EngineMemoryBuffer(data: valuesData) + let digest = EngineMemoryBuffer(data: data.md5Digest()) adjustments = VideoMediaResourceAdjustments(data: data, digest: digest, isStory: true) let resource: TelegramMediaResource @@ -718,13 +717,13 @@ public final class TelegramRootController: NavigationController, TelegramRootCon case let .asset(localIdentifier): resource = VideoLibraryMediaResource(localIdentifier: localIdentifier, conversion: .compress(adjustments)) } - let tempFile = TempBox.shared.tempFile(fileName: "file") + let tempFile = EngineTempBox.shared.tempFile(fileName: "file") defer { - TempBox.shared.dispose(tempFile) + EngineTempBox.shared.dispose(tempFile) } let imageData = firstFrameImage.flatMap { compressImageToJPEG($0, quality: 0.6, tempFilePath: tempFile.path) } - let firstFrameFile = imageData.flatMap { data -> TempBoxFile? in - let file = TempBox.shared.tempFile(fileName: "image.jpg") + let firstFrameFile = imageData.flatMap { data -> EngineTempBoxFile? in + let file = EngineTempBox.shared.tempFile(fileName: "image.jpg") if let _ = try? data.write(to: URL(fileURLWithPath: file.path)) { return file } else { diff --git a/submodules/TelegramUIPreferences/Sources/InAppNotificationSettings.swift b/submodules/TelegramUIPreferences/Sources/InAppNotificationSettings.swift index 88dcefed30..c555fced8f 100644 --- a/submodules/TelegramUIPreferences/Sources/InAppNotificationSettings.swift +++ b/submodules/TelegramUIPreferences/Sources/InAppNotificationSettings.swift @@ -1,12 +1,11 @@ import Foundation -import Postbox import SwiftSignalKit import TelegramCore public enum TotalUnreadCountDisplayStyle: Int32 { case filtered = 0 - public var category: ChatListTotalUnreadStateCategory { + public var category: EngineChatListTotalUnreadStateCategory { switch self { case .filtered: return .filtered @@ -18,7 +17,7 @@ public enum TotalUnreadCountDisplayCategory: Int32 { case chats = 0 case messages = 1 - public var statsType: ChatListTotalUnreadStateStats { + public var statsType: EngineChatListTotalUnreadStateStats { switch self { case .chats: return .chats @@ -34,7 +33,7 @@ public struct InAppNotificationSettings: Codable, Equatable { public var displayPreviews: Bool public var totalUnreadCountDisplayStyle: TotalUnreadCountDisplayStyle public var totalUnreadCountDisplayCategory: TotalUnreadCountDisplayCategory - public var totalUnreadCountIncludeTags: PeerSummaryCounterTags + public var totalUnreadCountIncludeTags: EnginePeerSummaryCounterTags public var displayNameOnLockscreen: Bool public var displayNotificationsFromAllAccounts: Bool public var customSound: String? @@ -43,7 +42,7 @@ public struct InAppNotificationSettings: Codable, Equatable { return InAppNotificationSettings(playSounds: true, vibrate: false, displayPreviews: true, totalUnreadCountDisplayStyle: .filtered, totalUnreadCountDisplayCategory: .messages, totalUnreadCountIncludeTags: .all, displayNameOnLockscreen: true, displayNotificationsFromAllAccounts: true, customSound: nil) } - public init(playSounds: Bool, vibrate: Bool, displayPreviews: Bool, totalUnreadCountDisplayStyle: TotalUnreadCountDisplayStyle, totalUnreadCountDisplayCategory: TotalUnreadCountDisplayCategory, totalUnreadCountIncludeTags: PeerSummaryCounterTags, displayNameOnLockscreen: Bool, displayNotificationsFromAllAccounts: Bool, customSound: String?) { + public init(playSounds: Bool, vibrate: Bool, displayPreviews: Bool, totalUnreadCountDisplayStyle: TotalUnreadCountDisplayStyle, totalUnreadCountDisplayCategory: TotalUnreadCountDisplayCategory, totalUnreadCountIncludeTags: EnginePeerSummaryCounterTags, displayNameOnLockscreen: Bool, displayNotificationsFromAllAccounts: Bool, customSound: String?) { self.playSounds = playSounds self.vibrate = vibrate self.displayPreviews = displayPreviews @@ -64,9 +63,9 @@ public struct InAppNotificationSettings: Codable, Equatable { self.totalUnreadCountDisplayStyle = TotalUnreadCountDisplayStyle(rawValue: try container.decode(Int32.self, forKey: "cds")) ?? .filtered self.totalUnreadCountDisplayCategory = TotalUnreadCountDisplayCategory(rawValue: try container.decodeIfPresent(Int32.self, forKey: "totalUnreadCountDisplayCategory") ?? 1) ?? .messages if let value = try container.decodeIfPresent(Int32.self, forKey: "totalUnreadCountIncludeTags_2") { - self.totalUnreadCountIncludeTags = PeerSummaryCounterTags(rawValue: value) + self.totalUnreadCountIncludeTags = EnginePeerSummaryCounterTags(rawValue: value) } else if let value = try container.decodeIfPresent(Int32.self, forKey: "totalUnreadCountIncludeTags") { - var resultTags: PeerSummaryCounterTags = [] + var resultTags: EnginePeerSummaryCounterTags = [] for legacyTag in LegacyPeerSummaryCounterTags(rawValue: value) { if legacyTag == .regularChatsAndPrivateGroups { resultTags.insert(.contact) @@ -113,7 +112,7 @@ public func updateInAppNotificationSettingsInteractively(accountManager: Account } else { currentSettings = InAppNotificationSettings.defaultSettings } - return PreferencesEntry(f(currentSettings)) + return EnginePreferencesEntry(f(currentSettings)) }) } } diff --git a/submodules/TelegramUIPreferences/Sources/PostboxKeys.swift b/submodules/TelegramUIPreferences/Sources/PostboxKeys.swift index d6f3aa3b6f..55d1c95193 100644 --- a/submodules/TelegramUIPreferences/Sources/PostboxKeys.swift +++ b/submodules/TelegramUIPreferences/Sources/PostboxKeys.swift @@ -1,6 +1,5 @@ import Foundation import TelegramCore -import Postbox private enum ApplicationSpecificPreferencesKeyValues: Int32 { case voipDerivedState = 16 @@ -13,15 +12,15 @@ private enum ApplicationSpecificPreferencesKeyValues: Int32 { } public struct ApplicationSpecificPreferencesKeys { - public static let voipDerivedState = applicationSpecificPreferencesKey(ApplicationSpecificPreferencesKeyValues.voipDerivedState.rawValue) - public static let chatArchiveSettings = applicationSpecificPreferencesKey(ApplicationSpecificPreferencesKeyValues.chatArchiveSettings.rawValue) - public static let chatListFilterSettings = applicationSpecificPreferencesKey(ApplicationSpecificPreferencesKeyValues.chatListFilterSettings.rawValue) - public static let widgetSettings = applicationSpecificPreferencesKey(ApplicationSpecificPreferencesKeyValues.widgetSettings.rawValue) - public static let mediaAutoSaveSettings = applicationSpecificPreferencesKey(ApplicationSpecificPreferencesKeyValues.mediaAutoSaveSettings.rawValue) - public static let ageVerificationState = applicationSpecificPreferencesKey(ApplicationSpecificPreferencesKeyValues.ageVerificationState.rawValue) + public static let voipDerivedState: EngineDataBuffer = applicationSpecificPreferencesKey(ApplicationSpecificPreferencesKeyValues.voipDerivedState.rawValue) + public static let chatArchiveSettings: EngineDataBuffer = applicationSpecificPreferencesKey(ApplicationSpecificPreferencesKeyValues.chatArchiveSettings.rawValue) + public static let chatListFilterSettings: EngineDataBuffer = applicationSpecificPreferencesKey(ApplicationSpecificPreferencesKeyValues.chatListFilterSettings.rawValue) + public static let widgetSettings: EngineDataBuffer = applicationSpecificPreferencesKey(ApplicationSpecificPreferencesKeyValues.widgetSettings.rawValue) + public static let mediaAutoSaveSettings: EngineDataBuffer = applicationSpecificPreferencesKey(ApplicationSpecificPreferencesKeyValues.mediaAutoSaveSettings.rawValue) + public static let ageVerificationState: EngineDataBuffer = applicationSpecificPreferencesKey(ApplicationSpecificPreferencesKeyValues.ageVerificationState.rawValue) - public static func textProcessingEditingState(peerId: PeerId) -> ValueBoxKey { - let key = ValueBoxKey(length: 4 + 8) + public static func textProcessingEditingState(peerId: EnginePeer.Id) -> EngineDataBuffer { + let key = EngineDataBuffer(length: 4 + 8) key.setInt32(0, value: ApplicationSpecificPreferencesKeyValues.textProcessingEditingState.rawValue) key.setInt64(4, value: peerId.toInt64()) return key @@ -55,29 +54,29 @@ private enum ApplicationSpecificSharedDataKeyValues: Int32 { } public struct ApplicationSpecificSharedDataKeys { - public static let inAppNotificationSettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.inAppNotificationSettings.rawValue) - public static let presentationPasscodeSettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.presentationPasscodeSettings.rawValue) - public static let automaticMediaDownloadSettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.automaticMediaDownloadSettings.rawValue) - public static let generatedMediaStoreSettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.generatedMediaStoreSettings.rawValue) - public static let voiceCallSettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.voiceCallSettings.rawValue) - public static let presentationThemeSettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.presentationThemeSettings.rawValue) - public static let instantPagePresentationSettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.instantPagePresentationSettings.rawValue) - public static let callListSettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.callListSettings.rawValue) - public static let experimentalSettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.experimentalSettings.rawValue) - public static let musicPlaybackSettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.musicPlaybackSettings.rawValue) - public static let mediaInputSettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.mediaInputSettings.rawValue) - public static let experimentalUISettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.experimentalUISettings.rawValue) - public static let stickerSettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.stickerSettings.rawValue) - public static let watchPresetSettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.watchPresetSettings.rawValue) - public static let webSearchSettings = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.webSearchSettings.rawValue) - public static let contactSynchronizationSettings = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.contactSynchronizationSettings.rawValue) - public static let webBrowserSettings = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.webBrowserSettings.rawValue) - public static let intentsSettings = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.intentsSettings.rawValue) - public static let translationSettings = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.translationSettings.rawValue) - public static let drawingSettings = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.drawingSettings.rawValue) - public static let mediaDisplaySettings = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.mediaDisplaySettings.rawValue) - public static let updateSettings = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.updateSettings.rawValue) - public static let chatSettings = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.chatSettings.rawValue) + public static let inAppNotificationSettings: EngineDataBuffer = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.inAppNotificationSettings.rawValue) + public static let presentationPasscodeSettings: EngineDataBuffer = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.presentationPasscodeSettings.rawValue) + public static let automaticMediaDownloadSettings: EngineDataBuffer = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.automaticMediaDownloadSettings.rawValue) + public static let generatedMediaStoreSettings: EngineDataBuffer = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.generatedMediaStoreSettings.rawValue) + public static let voiceCallSettings: EngineDataBuffer = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.voiceCallSettings.rawValue) + public static let presentationThemeSettings: EngineDataBuffer = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.presentationThemeSettings.rawValue) + public static let instantPagePresentationSettings: EngineDataBuffer = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.instantPagePresentationSettings.rawValue) + public static let callListSettings: EngineDataBuffer = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.callListSettings.rawValue) + public static let experimentalSettings: EngineDataBuffer = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.experimentalSettings.rawValue) + public static let musicPlaybackSettings: EngineDataBuffer = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.musicPlaybackSettings.rawValue) + public static let mediaInputSettings: EngineDataBuffer = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.mediaInputSettings.rawValue) + public static let experimentalUISettings: EngineDataBuffer = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.experimentalUISettings.rawValue) + public static let stickerSettings: EngineDataBuffer = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.stickerSettings.rawValue) + public static let watchPresetSettings: EngineDataBuffer = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.watchPresetSettings.rawValue) + public static let webSearchSettings: EngineDataBuffer = applicationSpecificSharedDataKey(ApplicationSpecificSharedDataKeyValues.webSearchSettings.rawValue) + public static let contactSynchronizationSettings: EngineDataBuffer = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.contactSynchronizationSettings.rawValue) + public static let webBrowserSettings: EngineDataBuffer = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.webBrowserSettings.rawValue) + public static let intentsSettings: EngineDataBuffer = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.intentsSettings.rawValue) + public static let translationSettings: EngineDataBuffer = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.translationSettings.rawValue) + public static let drawingSettings: EngineDataBuffer = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.drawingSettings.rawValue) + public static let mediaDisplaySettings: EngineDataBuffer = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.mediaDisplaySettings.rawValue) + public static let updateSettings: EngineDataBuffer = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.updateSettings.rawValue) + public static let chatSettings: EngineDataBuffer = applicationSpecificPreferencesKey(ApplicationSpecificSharedDataKeyValues.chatSettings.rawValue) } private enum ApplicationSpecificItemCacheCollectionIdValues: Int8 { diff --git a/submodules/TelegramUIPreferences/Sources/RenderedTotalUnreadCount.swift b/submodules/TelegramUIPreferences/Sources/RenderedTotalUnreadCount.swift index 09243edeac..233adf2e18 100644 --- a/submodules/TelegramUIPreferences/Sources/RenderedTotalUnreadCount.swift +++ b/submodules/TelegramUIPreferences/Sources/RenderedTotalUnreadCount.swift @@ -7,12 +7,7 @@ public enum RenderedTotalUnreadCountType { case filtered } -public func renderedTotalUnreadCount(inAppNotificationSettings: InAppNotificationSettings, transaction: Transaction) -> (Int32, RenderedTotalUnreadCountType) { - let totalUnreadState = transaction.getTotalUnreadState(groupId: .root) - return renderedTotalUnreadCount(inAppSettings: inAppNotificationSettings, totalUnreadState: totalUnreadState) -} - -public func renderedTotalUnreadCount(inAppSettings: InAppNotificationSettings, totalUnreadState: ChatListTotalUnreadState) -> (Int32, RenderedTotalUnreadCountType) { +public func renderedTotalUnreadCount(inAppSettings: InAppNotificationSettings, totalUnreadState: EngineChatListTotalUnreadState) -> (Int32, RenderedTotalUnreadCountType) { let type: RenderedTotalUnreadCountType switch inAppSettings.totalUnreadCountDisplayStyle { case .filtered: diff --git a/submodules/TelegramVoip/Sources/WrappedMediaStreamingContext.swift b/submodules/TelegramVoip/Sources/WrappedMediaStreamingContext.swift index 640e984bf5..27b72f8605 100644 --- a/submodules/TelegramVoip/Sources/WrappedMediaStreamingContext.swift +++ b/submodules/TelegramVoip/Sources/WrappedMediaStreamingContext.swift @@ -3,7 +3,6 @@ import SwiftSignalKit import TgVoipWebrtc import TelegramCore import Network -import Postbox import FFMpegBinding import ManagedFile @@ -275,7 +274,7 @@ public final class ExternalMediaStreamingContext: SharedHLSServerSource { } } - func fileData(id: Int64, range: Range) -> Signal<(TempBoxFile, Range, Int)?, NoError> { + func fileData(id: Int64, range: Range) -> Signal<(EngineTempBoxFile, Range, Int)?, NoError> { return .never() } } @@ -331,7 +330,7 @@ public final class ExternalMediaStreamingContext: SharedHLSServerSource { } } - public func fileData(id: Int64, range: Range) -> Signal<(TempBoxFile, Range, Int)?, NoError> { + public func fileData(id: Int64, range: Range) -> Signal<(EngineTempBoxFile, Range, Int)?, NoError> { return self.impl.signalWith { impl, subscriber in impl.fileData(id: id, range: range).start(next: subscriber.putNext) } @@ -519,7 +518,7 @@ public protocol SharedHLSServerSource: AnyObject { func masterPlaylistData() -> Signal func playlistData(quality: Int) -> Signal func partData(index: Int, quality: Int) -> Signal - func fileData(id: Int64, range: Range) -> Signal<(TempBoxFile, Range, Int)?, NoError> + func fileData(id: Int64, range: Range) -> Signal<(EngineTempBoxFile, Range, Int)?, NoError> func arbitraryFileData(path: String) -> Signal<(data: Data, contentType: String)?, NoError> } @@ -778,11 +777,11 @@ public final class SharedHLSServer { } if let result { - let sourceTempFile = TempBox.shared.tempFile(fileName: "part.mp4") - let tempFile = TempBox.shared.tempFile(fileName: "part.ts") + let sourceTempFile = EngineTempBox.shared.tempFile(fileName: "part.mp4") + let tempFile = EngineTempBox.shared.tempFile(fileName: "part.ts") defer { - TempBox.shared.dispose(sourceTempFile) - TempBox.shared.dispose(tempFile) + EngineTempBox.shared.dispose(sourceTempFile) + EngineTempBox.shared.dispose(tempFile) } guard let _ = try? result.write(to: URL(fileURLWithPath: sourceTempFile.path)) else { @@ -875,7 +874,7 @@ public final class SharedHLSServer { }) } - private static func sendRemainingFileRange(queue: Queue, connection: NWConnection, tempFile: TempBoxFile, managedFile: ManagedFile, remainingRange: Range, fileSize: Int) -> Void { + private static func sendRemainingFileRange(queue: Queue, connection: NWConnection, tempFile: EngineTempBoxFile, managedFile: ManagedFile, remainingRange: Range, fileSize: Int) -> Void { let blockSize = 256 * 1024 let clippedLowerBound = min(remainingRange.lowerBound, fileSize) @@ -883,7 +882,7 @@ public final class SharedHLSServer { clippedUpperBound = min(clippedUpperBound, clippedLowerBound + blockSize) if clippedUpperBound == clippedLowerBound { - TempBox.shared.dispose(tempFile) + EngineTempBox.shared.dispose(tempFile) connection.cancel() } else { let _ = managedFile.seek(position: Int64(clippedLowerBound)) @@ -895,7 +894,7 @@ public final class SharedHLSServer { if let error { Logger.shared.log("SharedHLSServer", "Failed to send response: \(error)") connection.cancel() - TempBox.shared.dispose(tempFile) + EngineTempBox.shared.dispose(tempFile) } else { sendRemainingFileRange(queue: queue, connection: connection, tempFile: tempFile, managedFile: managedFile, remainingRange: nextRange, fileSize: fileSize) } @@ -904,12 +903,12 @@ public final class SharedHLSServer { } } - private func sendResponseFileAndClose(connection: NWConnection, file: TempBoxFile, fileRange: Range, range: Range, totalSize: Int) { + private func sendResponseFileAndClose(connection: NWConnection, file: EngineTempBoxFile, fileRange: Range, range: Range, totalSize: Int) { let queue = self.queue guard let managedFile = ManagedFile(queue: nil, path: file.path, mode: .read), let fileSize = managedFile.getSize() else { self.sendErrorAndClose(connection: connection, error: .internalServerError) - TempBox.shared.dispose(file) + EngineTempBox.shared.dispose(file) return } diff --git a/submodules/TemporaryCachedPeerDataManager/Sources/CachedChannelAdmins.swift b/submodules/TemporaryCachedPeerDataManager/Sources/CachedChannelAdmins.swift index 931d93ab03..a09fb7db18 100644 --- a/submodules/TemporaryCachedPeerDataManager/Sources/CachedChannelAdmins.swift +++ b/submodules/TemporaryCachedPeerDataManager/Sources/CachedChannelAdmins.swift @@ -1,5 +1,4 @@ import Foundation -import Postbox import TelegramCore import SwiftSignalKit @@ -43,16 +42,16 @@ public enum CachedChannelAdminRank: Codable, Equatable { public final class CachedChannelAdminRanks: Codable { private struct DictionaryKey: Codable, Hashable { - var key: PeerId + var key: EnginePeer.Id - init(_ key: PeerId) { + init(_ key: EnginePeer.Id) { self.key = key } init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: StringCodingKey.self) - self.key = PeerId(try container.decode(Int64.self, forKey: "k")) + self.key = EnginePeer.Id(try container.decode(Int64.self, forKey: "k")) } func encode(to encoder: Encoder) throws { @@ -61,18 +60,18 @@ public final class CachedChannelAdminRanks: Codable { try container.encode(self.key.toInt64(), forKey: "k") } } - - public let ranks: [PeerId: CachedChannelAdminRank] - - public init(ranks: [PeerId: CachedChannelAdminRank]) { + + public let ranks: [EnginePeer.Id: CachedChannelAdminRank] + + public init(ranks: [EnginePeer.Id: CachedChannelAdminRank]) { self.ranks = ranks } - + public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: StringCodingKey.self) let dict = try container.decode([DictionaryKey: CachedChannelAdminRank].self, forKey: "ranks") - var mappedDict: [PeerId: CachedChannelAdminRank] = [:] + var mappedDict: [EnginePeer.Id: CachedChannelAdminRank] = [:] for (key, value) in dict { mappedDict[key.key] = value } @@ -89,17 +88,17 @@ public final class CachedChannelAdminRanks: Codable { try container.encode(mappedDict, forKey: "ranks") } - public static func cacheKey(peerId: PeerId) -> ValueBoxKey { - let key = ValueBoxKey(length: 8) + public static func cacheKey(peerId: EnginePeer.Id) -> EngineDataBuffer { + let key = EngineDataBuffer(length: 8) key.setInt64(0, value: peerId.toInt64()) return key } } -public func cachedChannelAdminRanksEntryId(peerId: PeerId) -> ItemCacheEntryId { - return ItemCacheEntryId(collectionId: 100, key: CachedChannelAdminRanks.cacheKey(peerId: peerId)) +public func cachedChannelAdminRanksEntryId(peerId: EnginePeer.Id) -> EngineItemCacheEntryId { + return EngineItemCacheEntryId(collectionId: 100, key: CachedChannelAdminRanks.cacheKey(peerId: peerId)) } -func updateCachedChannelAdminRanks(engine: TelegramEngine, peerId: PeerId, ranks: Dictionary) -> Signal { +func updateCachedChannelAdminRanks(engine: TelegramEngine, peerId: EnginePeer.Id, ranks: Dictionary) -> Signal { return engine.itemCache.put(collectionId: 100, id: CachedChannelAdminRanks.cacheKey(peerId: peerId), item: CachedChannelAdminRanks(ranks: ranks)) } diff --git a/submodules/UrlHandling/Sources/UrlHandling.swift b/submodules/UrlHandling/Sources/UrlHandling.swift index d1102a40b0..9766d60e4b 100644 --- a/submodules/UrlHandling/Sources/UrlHandling.swift +++ b/submodules/UrlHandling/Sources/UrlHandling.swift @@ -1,7 +1,6 @@ import Foundation import UIKit import SwiftSignalKit -import Postbox import TelegramCore import MtProtoKit import TelegramPresentationData @@ -97,7 +96,7 @@ public enum ParsedInternalPeerUrlParameter { public enum ParsedInternalUrl { public enum UrlPeerReference { case name(String) - case id(PeerId) + case id(EnginePeer.Id) } public enum UrlMessageSubject { @@ -107,8 +106,8 @@ public enum ParsedInternalUrl { } case peer(UrlPeerReference, ParsedInternalPeerUrlParameter?) - case peerId(PeerId) - case privateMessage(messageId: MessageId, threadId: Int32?, subject: UrlMessageSubject?) + case peerId(EnginePeer.Id) + case privateMessage(messageId: EngineMessage.Id, threadId: Int32?, subject: UrlMessageSubject?) case stickerPack(name: String, type: StickerPackUrlType) case invoice(String) case join(String) @@ -278,7 +277,7 @@ public func parseInternalUrl(sharedContext: SharedAccountContext, context: Accou } else if peerName == "boost" { for queryItem in queryItems { if queryItem.name == "c", let value = queryItem.value, let channelId = Int64(value), channelId > 0 { - let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) + let peerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudChannel, id: EnginePeer.Id.Id._internalFromInt64Value(channelId)) return .peer(.id(peerId), .boost) } } @@ -446,7 +445,7 @@ public func parseInternalUrl(sharedContext: SharedAccountContext, context: Accou } } } else if pathComponents[0].hasPrefix(phonebookUsernamePathPrefix), let idValue = Int64(String(pathComponents[0][pathComponents[0].index(pathComponents[0].startIndex, offsetBy: phonebookUsernamePathPrefix.count)...])) { - return .peerId(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(idValue))) + return .peerId(EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(idValue))) } else if pathComponents[0].hasPrefix("$") || pathComponents[0].hasPrefix("%24") { var component = pathComponents[0].replacingOccurrences(of: "%24", with: "$") if component.hasPrefix("$") { @@ -649,7 +648,7 @@ public func parseInternalUrl(sharedContext: SharedAccountContext, context: Accou } } } - return .privateMessage(messageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, id: messageId), threadId: threadId, subject: subject) + return .privateMessage(messageId: EngineMessage.Id(peerId: EnginePeer.Id(namespace: Namespaces.Peer.CloudChannel, id: EnginePeer.Id.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, id: messageId), threadId: threadId, subject: subject) } else { return nil } @@ -688,7 +687,7 @@ public func parseInternalUrl(sharedContext: SharedAccountContext, context: Accou } } } - return .privateMessage(messageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, id: messageId), threadId: threadId, subject: subject) + return .privateMessage(messageId: EngineMessage.Id(peerId: EnginePeer.Id(namespace: Namespaces.Peer.CloudChannel, id: EnginePeer.Id.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, id: messageId), threadId: threadId, subject: subject) } else { return nil } @@ -712,7 +711,7 @@ public func parseInternalUrl(sharedContext: SharedAccountContext, context: Accou } } - let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) + let peerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudChannel, id: EnginePeer.Id.Id._internalFromInt64Value(channelId)) if boost { return .peer(.id(peerId), .boost) } else if let threadId = threadId { @@ -960,7 +959,7 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl) } case let .channelMessage(id, timecode): if case let .channel(channel) = peer, channel.isForumOrMonoForum { - let messageId = MessageId(peerId: channel.id, namespace: Namespaces.Message.Cloud, id: id) + let messageId = EngineMessage.Id(peerId: channel.id, namespace: Namespaces.Message.Cloud, id: id) return context.engine.messages.getMessagesLoadIfNecessary([messageId], strategy: .cloud(skipLocal: false)) |> `catch` { _ in return .single(.result([])) @@ -990,10 +989,10 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl) } } } else { - return .single(.result(.channelMessage(peer: peer._asPeer(), messageId: MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: id), timecode: timecode))) + return .single(.result(.channelMessage(peer: peer._asPeer(), messageId: EngineMessage.Id(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: id), timecode: timecode))) } case let .replyThread(id, replyId): - let replyThreadMessageId = MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: id) + let replyThreadMessageId = EngineMessage.Id(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: id) if case let .channel(channel) = peer, channel.isForumOrMonoForum { return context.engine.peers.fetchForumChannelTopic(id: channel.id, threadId: Int64(replyThreadMessageId.id)) @@ -1003,7 +1002,7 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl) return .progress case let .result(info): if let _ = info { - return .result(.replyThreadMessage(replyThreadMessage: ChatReplyThreadMessage(peerId: channel.id, threadId: Int64(replyThreadMessageId.id), channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false), messageId: MessageId(peerId: channel.id, namespace: Namespaces.Message.Cloud, id: replyId))) + return .result(.replyThreadMessage(replyThreadMessage: ChatReplyThreadMessage(peerId: channel.id, threadId: Int64(replyThreadMessageId.id), channelMessageId: nil, isChannelPost: false, isForumPost: true, isMonoforumPost: false, maxMessage: nil, maxReadIncomingMessageId: nil, maxReadOutgoingMessageId: nil, unreadCount: 0, initialFilledHoles: IndexSet(), initialAnchor: .automatic, isNotAvailable: false), messageId: EngineMessage.Id(peerId: channel.id, namespace: Namespaces.Message.Cloud, id: replyId))) } else { return .result(.peer(peer._asPeer(), .chat(textInputState: nil, subject: nil, peekData: nil))) } @@ -1019,7 +1018,7 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl) guard let result = result else { return .result(.channelMessage(peer: peer._asPeer(), messageId: replyThreadMessageId, timecode: nil)) } - return .result(.replyThreadMessage(replyThreadMessage: result, messageId: MessageId(peerId: result.peerId, namespace: Namespaces.Message.Cloud, id: replyId))) + return .result(.replyThreadMessage(replyThreadMessage: result, messageId: EngineMessage.Id(peerId: result.peerId, namespace: Namespaces.Message.Cloud, id: replyId))) }) } case let .voiceChat(invite): @@ -1160,7 +1159,7 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl) } } } else if let threadId = threadId { - let replyThreadMessageId = MessageId(peerId: foundPeer.id, namespace: Namespaces.Message.Cloud, id: threadId) + let replyThreadMessageId = EngineMessage.Id(peerId: foundPeer.id, namespace: Namespaces.Message.Cloud, id: threadId) return .single(.progress) |> then(context.engine.messages.fetchChannelReplyThreadMessage(messageId: replyThreadMessageId, atMessageId: nil) |> map(Optional.init) |> `catch` { _ -> Signal in @@ -1509,7 +1508,7 @@ private struct UrlHandlingConfiguration { } } -public func resolveUrlImpl(context: AccountContext, peerId: PeerId?, url: String, skipUrlAuth: Bool) -> Signal { +public func resolveUrlImpl(context: AccountContext, peerId: EnginePeer.Id?, url: String, skipUrlAuth: Bool) -> Signal { let schemes = ["http://", "https://", ""] return ApplicationSpecificNotice.getSecretChatLinkPreviews(accountManager: context.sharedContext.accountManager) diff --git a/submodules/WebsiteType/BUILD b/submodules/WebsiteType/BUILD index 4b08a4a695..0aa10486c0 100644 --- a/submodules/WebsiteType/BUILD +++ b/submodules/WebsiteType/BUILD @@ -10,7 +10,6 @@ swift_library( "-warnings-as-errors", ], deps = [ - "//submodules/Postbox", "//submodules/TelegramCore", ], visibility = [ diff --git a/submodules/WebsiteType/Sources/WebsiteType.swift b/submodules/WebsiteType/Sources/WebsiteType.swift index 69407581d2..4bccf86fd5 100644 --- a/submodules/WebsiteType/Sources/WebsiteType.swift +++ b/submodules/WebsiteType/Sources/WebsiteType.swift @@ -1,5 +1,4 @@ import Foundation -import Postbox import TelegramCore public enum WebsiteType { @@ -40,15 +39,15 @@ public func instantPageType(of webpage: TelegramMediaWebpageLoadedContent) -> In public func defaultWebpageImageSizeIsSmall(webpage: TelegramMediaWebpageLoadedContent) -> Bool { let type = websiteType(of: webpage.websiteName) - let mainMedia: Media? + let mainMedia: EngineMedia? switch type { case .instagram, .twitter: - mainMedia = webpage.story ?? webpage.image ?? webpage.file + mainMedia = webpage.story.map(EngineMedia.story) ?? webpage.image.map(EngineMedia.image) ?? webpage.file.map(EngineMedia.file) default: - mainMedia = webpage.story ?? webpage.file ?? webpage.image + mainMedia = webpage.story.map(EngineMedia.story) ?? webpage.file.map(EngineMedia.file) ?? webpage.image.map(EngineMedia.image) } - - if let image = mainMedia as? TelegramMediaImage { + + if case let .image(image) = mainMedia { if let type = webpage.type, (["photo", "video", "embed", "gif", "document", "telegram_album"] as [String]).contains(type) { } else if let type = webpage.type, (["article"] as [String]).contains(type) { return true