Postbox refactor waves 138–276: 168-commit squash

Consolidates 137 wave commits + 31 supporting commits (CLAUDE.md bump,
typealias additions, AnyObject→EngineMedia restoration) into one squashed
commit. Migrates dozens of consumer-side public APIs, struct fields,
protocol methods, and enum payloads from Postbox protocols/structs to
TelegramEngine engine wrappers and typealiases. Drops `import Postbox`
from many files. Adds new TelegramCore typealiases and one
TelegramEngineUnauthorized facade.

Notable changes by category:

**TelegramCore typealias additions** (rule 2 — narrow utility typealiases):
- EngineChatListIndex, EngineTempBoxFile, EngineItemCollectionItemIndex,
  EngineItemCollectionViewEntryIndex, EngineValueBoxEncryptionParameters,
  EngineMessageAndThreadId, EnginePeerStoryStats, EngineMessageHistoryAnchorIndex,
  EngineChatListTotalUnreadStateCategory, EngineChatListTotalUnreadStateStats,
  EnginePeerSummaryCounterTags, EngineChatListTotalUnreadState,
  EngineItemCacheEntryId, EngineHashFunctions,
  EngineCachedMediaResourceRepresentationResult,
  EngineMediaResourceDataFetchResult, EngineMediaResourceDataFetchError,
  EngineMediaResourceStatus, EngineCachedPeerData

**TelegramCore engine extensions/forwarders**:
- EngineMessage.engineMedia, EngineMessage.enginePeers,
  EngineMessage.adAttribute, EngineMessage.effectivelyIncoming
- engineFileSize forwarder
- TelegramEngine.Resources.clearCachedMediaResources(mediaResourceIds: Set<EngineMediaResource.Id>)
- TelegramEngine.Resources.fetchStatus(id:resourceSize:)
- TelegramEngineUnauthorized.UnauthorizedResources facade with storeResourceData

**Public API/struct migrations to engine types**:
- ChatAvailableMessageActions.banAuthor/banAuthors → EnginePeer?/[EnginePeer]
- WebSessionsContextState.peers → [EnginePeer.Id: EnginePeer]
- CacheUsageStats.peers → [EnginePeer.Id: EnginePeer]
- PeerCommand.peer → EnginePeer
- PeerInfoControllerMode.calls(messages:) → [EngineMessage]
- CallControllerNodeProtocol.updatePeer → EnginePeer params
- ChatHistoryListNode.messageInCurrentHistoryView (and 4 variants) → EngineMessage?
- ChatHistorySearchContainerNode.messageForGallery → EngineMessage?
- PeerInfoPaneNode.findLoadedMessage / ensureMessageIsVisible /
  transitionNodeForGallery → engine-typed
- GalleryHiddenMediaTarget.getTransitionInfo /
  GalleryHiddenMediaManager.findTarget → engine-typed
- ChatPanelInterfaceInteraction.presentReactionDeletionOptions /
  presentBan*MessageOptions → EnginePeer
- DrawingMessageRenderer.messages → [EngineMessage]
- ChatVideoGalleryItemScrubberView.setFetchStatusSignal →
  EngineMediaResource.FetchStatus
- ChannelDiscussionGroupActionSheetItem.peer, VoiceChatPeerEntry.peer,
  VoiceChatFullscreenParticipantItem.peer, MediaStreamComponent.chatPeer,
  MediaStreamVideoComponent.callPeer, ChatMessageContactBubbleContentNode.contactPeer,
  ChatMessageForwardInfoNode.peer, ChatMessageCommentFooterContentNode.replyPeers,
  ChatReportPeerTitlePanelNode.peer, ChatMessageActionUrlAuthController.bot,
  PeerMediaCollectionInterfaceState.peer, ChatMessageCallBubbleContentNode.peopleAvatars,
  ChatLoadingNode.renderedPeer (→ EngineRenderedPeer) — all to engine types

**Wave-71-shadow stored-field migrations** (Postbox Peer/Message → Engine wrapper):
- LegacyCallControllerNode.peer
- CallStatusBarNode.currentPeer

**Dead-code / dead-field removals**:
- CallController.peer, CallControllerNodeV2.account,
  ContactMultiselectionController PeerNameIndex fields,
  preparedChatListNodeViewTransition account: Account param,
  FetchResource.swift entirely (unused function)

**Module-level Postbox import drops**: 30+ files including TelegramRootController,
EditStories, GiftViewScreen, AnimatedStickerUtils, FetchPhotoLibraryImageResource,
PeerInfoGiftsPaneNode, PeerInfoPaneContainerNode, PresentAddMembers,
PeerInfoProfileItems, ChatControllerAdminBanUsers, PresentationData typealiases,
DefaultDayPresentationTheme, ChatListViewTransition, GalleryHiddenMediaManager,
RecentSessionsController, GifContext, AuthorizationSequenceController,
PeerInfoHeaderEditingContentNode, PeerInfoHeaderNode,
PeerAllowedReactionListController, CallControllerNodeV2, and 6 PeerInfo pane files.

**AnyObject restoration**: rule 8 added (never substitute Postbox protocols
with Any/AnyObject) — undid previous AnyObject substitutions in waves 141/143
back to EngineMedia.

Doc maintenance: CLAUDE.md updated to reflect new typealiases and forwarders.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
isaac 2026-05-05 00:44:27 +02:00
parent 631df15f40
commit 69bfc65da7
226 changed files with 1467 additions and 1519 deletions

View file

@ -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? {