Postbox -> TelegramEngine wave 16b: ItemListPeerItem.Context engine: collapse

ItemListPeerItem.Context.Custom's init took (postbox: Postbox, network: Network)
purely to forward them to downstream AvatarNode.setPeer and EmojiStatusComponent.
Collapse to engine: TelegramEngine (wave-11 pattern, engine handle preferred per
the standing guidance since the sole external caller is main-app, not
Share-Extension).

Surface changes:
- Context.Custom: two stored fields (postbox, network) -> one (engine); init
  param pair -> single engine:.
- Context: computed postbox/network -> computed engine.
- Six internal forwards route via item.context.engine.account.postbox/.network.

External caller (sole .custom(Custom(...)) construction site codebase-wide):
- PeerInfoSettingsItems.swift:121 -> pass engine: peerAccountContext.engine
  (the accountsAndPeers tuple already carries AccountContext, which exposes
  .engine: TelegramEngine).

All 37 other ItemListPeerItem(...) sites use the .account(context: AccountContext)
convenience overload unchanged.

Module does NOT become Postbox-free: PeerStoryStats? (public surface on
storyStats) and, via the now-unavoidable Postbox import, a handful of other
transitive Postbox types remain reachable. PeerStoryStats is deeply baked into
Postbox view types (PeerView, PeerStoryStatsView, ChatListEntry, MessageHistoryView,
Postbox.getPeerStoryStats) and moving it would require a cross-module wrapper
rewrite out of scope here. EngineMessageHistoryThread.Info (the other
previously-blocking public-surface type) was moved to TelegramCore in the
preceding wave 16a commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
isaac 2026-04-20 21:30:19 +02:00
parent 3bb22d503c
commit a5432e44a8
2 changed files with 17 additions and 30 deletions

View file

@ -326,25 +326,22 @@ public final class ItemListPeerItem: ListViewItem, ItemListItem {
public enum Context {
public final class Custom {
public let accountPeerId: EnginePeer.Id
public let postbox: Postbox
public let network: Network
public let engine: TelegramEngine
public let animationCache: AnimationCache
public let animationRenderer: MultiAnimationRenderer
public let isPremiumDisabled: Bool
public let resolveInlineStickers: ([Int64]) -> Signal<[Int64: TelegramMediaFile], NoError>
public init(
accountPeerId: EnginePeer.Id,
postbox: Postbox,
network: Network,
engine: TelegramEngine,
animationCache: AnimationCache,
animationRenderer: MultiAnimationRenderer,
isPremiumDisabled: Bool,
resolveInlineStickers: @escaping ([Int64]) -> Signal<[Int64: TelegramMediaFile], NoError>
) {
self.accountPeerId = accountPeerId
self.postbox = postbox
self.network = network
self.engine = engine
self.animationCache = animationCache
self.animationRenderer = animationRenderer
self.isPremiumDisabled = isPremiumDisabled
@ -364,21 +361,12 @@ public final class ItemListPeerItem: ListViewItem, ItemListItem {
}
}
public var postbox: Postbox {
public var engine: TelegramEngine {
switch self {
case let .account(context):
return context.account.postbox
return context.engine
case let .custom(custom):
return custom.postbox
}
}
public var network: Network {
switch self {
case let .account(context):
return context.account.network
case let .custom(custom):
return custom.network
return custom.engine
}
}
@ -1495,7 +1483,7 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
}
let verifiedIconComponent = EmojiStatusComponent(
postbox: item.context.postbox,
postbox: item.context.engine.account.postbox,
energyUsageSettings: item.context.energyUsageSettings,
resolveInlineStickers: item.context.resolveInlineStickers,
animationCache: animationCache,
@ -1543,7 +1531,7 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
}
let credibilityIconComponent = EmojiStatusComponent(
postbox: item.context.postbox,
postbox: item.context.engine.account.postbox,
energyUsageSettings: item.context.energyUsageSettings,
resolveInlineStickers: item.context.resolveInlineStickers,
animationCache: animationCache,
@ -1702,7 +1690,7 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
}
let avatarIconComponent = EmojiStatusComponent(
postbox: item.context.postbox,
postbox: item.context.engine.account.postbox,
energyUsageSettings: item.context.energyUsageSettings,
resolveInlineStickers: item.context.resolveInlineStickers,
animationCache: item.context.animationCache,
@ -1730,8 +1718,8 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
if item.peer.id == item.context.accountPeerId, case .threatSelfAsSaved = item.aliasHandling {
strongSelf.avatarNode.setPeer(
accountPeerId: item.context.accountPeerId,
postbox: item.context.postbox,
network: item.context.network,
postbox: item.context.engine.account.postbox,
network: item.context.engine.account.network,
contentSettings: item.context.contentSettings,
theme: item.presentationData.theme,
peer: item.peer,
@ -1742,8 +1730,8 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
} else if item.peer.id.isReplies {
strongSelf.avatarNode.setPeer(
accountPeerId: item.context.accountPeerId,
postbox: item.context.postbox,
network: item.context.network,
postbox: item.context.engine.account.postbox,
network: item.context.engine.account.network,
contentSettings: item.context.contentSettings,
theme: item.presentationData.theme,
peer: item.peer,
@ -1765,8 +1753,8 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
strongSelf.avatarNode.setPeer(
accountPeerId: item.context.accountPeerId,
postbox: item.context.postbox,
network: item.context.network,
postbox: item.context.engine.account.postbox,
network: item.context.engine.account.network,
contentSettings: item.context.contentSettings,
theme: item.presentationData.theme,
peer: item.peer,

View file

@ -120,8 +120,7 @@ func settingsItems(data: PeerInfoScreenData?, context: AccountContext, presentat
for (peerAccountContext, peer, badgeCount) in settings.accountsAndPeers {
let mappedContext = ItemListPeerItem.Context.custom(ItemListPeerItem.Context.Custom(
accountPeerId: peerAccountContext.account.peerId,
postbox: peerAccountContext.account.postbox,
network: peerAccountContext.account.network,
engine: peerAccountContext.engine,
animationCache: context.animationCache,
animationRenderer: context.animationRenderer,
isPremiumDisabled: false,