mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Squashes 20 commits — the implementation and outcome commits of
waves 37 through 43 plus wave 44's spec and implementation-plan
docs — into a single commit. Per-wave lessons remain recorded in
docs/superpowers/postbox-refactor-log.md. The unrelated "Add swift
svg" commit is preserved separately outside this squash.
Wave 37 — peerTokenTitle: peer Peer → EnginePeer (1 file)
Wave 38 — canSendMessagesToPeer: peer Peer → EnginePeer (12 files)
Wave 39 — AccountContext.makePeerInfoController: peer Peer → EnginePeer (52 files)
Wave 40 — makeChatQrCodeScreen + makeChatRecentActionsController bundle (8 files)
Wave 41 — RenderedChannelParticipant.peer: Peer → EnginePeer (28 files)
Wave 42 — PeerInfoScreenData.peer: Peer? → EnginePeer? (17 files)
Wave 43 — PeerInfoScreen 6 helpers: peer Peer? → EnginePeer? (12 files)
Wave 44 — RenderedChannelParticipant.peers design doc + implementation plan
(impl and outcome land in subsequent commits, not part of squash)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
118 lines
6.4 KiB
Swift
118 lines
6.4 KiB
Swift
import Foundation
|
|
import UIKit
|
|
import Display
|
|
import AccountContext
|
|
import SwiftSignalKit
|
|
import Postbox
|
|
import TelegramCore
|
|
|
|
extension PeerInfoScreenNode {
|
|
func openChatWithMessageSearch() {
|
|
if let navigationController = (self.controller?.navigationController as? NavigationController) {
|
|
if case let .replyThread(currentMessage) = self.chatLocation, let current = navigationController.viewControllers.first(where: { controller in
|
|
if let controller = controller as? ChatController, case let .replyThread(message) = controller.chatLocation, message.peerId == currentMessage.peerId, message.threadId == currentMessage.threadId {
|
|
return true
|
|
}
|
|
return false
|
|
}) as? ChatController {
|
|
var viewControllers = navigationController.viewControllers
|
|
if let index = viewControllers.firstIndex(of: current) {
|
|
viewControllers.removeSubrange(index + 1 ..< viewControllers.count)
|
|
}
|
|
navigationController.setViewControllers(viewControllers, animated: true)
|
|
current.activateSearch(domain: .everything, query: "")
|
|
} else if let peer = self.data?.chatPeer {
|
|
self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: self.context, chatLocation: .peer(EnginePeer(peer)), keepStack: .default, activateMessageSearch: (.everything, "")))
|
|
}
|
|
}
|
|
}
|
|
|
|
func openChatForReporting(title: String, option: Data, message: String?) {
|
|
if let peer = self.data?.peer, let navigationController = (self.controller?.navigationController as? NavigationController) {
|
|
if case let .channel(channel) = peer, channel.isForumOrMonoForum {
|
|
//let _ = self.context.engine.peers.reportPeer(peerId: peer.id, reason: reason, message: "").startStandalone()
|
|
//self.controller?.present(UndoOverlayController(presentationData: self.presentationData, content: .emoji(name: "PoliceCar", text: self.presentationData.strings.Report_Succeed), elevatedLayout: false, action: { _ in return false }), in: .current)
|
|
} else {
|
|
self.context.sharedContext.navigateToChatController(
|
|
NavigateToChatControllerParams(
|
|
navigationController: navigationController,
|
|
context: self.context,
|
|
chatLocation: .peer(peer),
|
|
keepStack: .default,
|
|
reportReason: NavigateToChatControllerParams.ReportReason(title: title, option: option, message: message)
|
|
)
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
func openChatForThemeChange() {
|
|
if let peer = self.data?.peer, let navigationController = (self.controller?.navigationController as? NavigationController) {
|
|
self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: self.context, chatLocation: .peer(peer), keepStack: .default, changeColors: true))
|
|
}
|
|
}
|
|
|
|
func openChatForTranslation() {
|
|
if let peer = self.data?.peer, let navigationController = (self.controller?.navigationController as? NavigationController) {
|
|
self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: self.context, chatLocation: .peer(peer), keepStack: .default, changeColors: false))
|
|
}
|
|
}
|
|
|
|
func openChat(peerId: EnginePeer.Id?) {
|
|
if let peerId {
|
|
let _ = (self.context.engine.data.get(
|
|
TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)
|
|
)
|
|
|> deliverOnMainQueue).startStandalone(next: { [weak self] peer in
|
|
guard let self, let peer else {
|
|
return
|
|
}
|
|
guard let navigationController = self.controller?.navigationController as? NavigationController else {
|
|
return
|
|
}
|
|
|
|
self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: self.context, chatLocation: .peer(peer), keepStack: .always))
|
|
})
|
|
return
|
|
}
|
|
|
|
if let peer = self.data?.peer, let navigationController = self.controller?.navigationController as? NavigationController {
|
|
self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: self.context, chatLocation: .peer(peer), keepStack: .default))
|
|
}
|
|
}
|
|
|
|
func openChatWithClearedHistory(type: InteractiveHistoryClearingType) {
|
|
guard let peer = self.data?.chatPeer, let navigationController = self.controller?.navigationController as? NavigationController else {
|
|
return
|
|
}
|
|
|
|
self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: self.context, chatLocation: .peer(EnginePeer(peer)), keepStack: .default, setupController: { controller in
|
|
controller.beginClearHistory(type: type)
|
|
}))
|
|
}
|
|
|
|
func openChannelMessages() {
|
|
guard case let .channel(channel) = self.data?.peer, let linkedMonoforumId = channel.linkedMonoforumId else {
|
|
return
|
|
}
|
|
let _ = (self.context.engine.data.get(
|
|
TelegramEngine.EngineData.Item.Peer.Peer(id: linkedMonoforumId)
|
|
)
|
|
|> deliverOnMainQueue).startStandalone(next: { [weak self] peer in
|
|
guard let self, let peer else {
|
|
return
|
|
}
|
|
if let controller = self.controller, let navigationController = controller.navigationController as? NavigationController {
|
|
self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: self.context, chatLocation: .peer(peer)))
|
|
}
|
|
})
|
|
}
|
|
|
|
func openRecentActions() {
|
|
guard let peer = self.data?.peer else {
|
|
return
|
|
}
|
|
let controller = self.context.sharedContext.makeChatRecentActionsController(context: self.context, peer: peer, adminPeerId: nil, starsState: self.data?.starsRevenueStatsState)
|
|
self.controller?.push(controller)
|
|
}
|
|
}
|