Files
Telegram-iOS/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreenOpenNote.swift
T
IsaacIsaacClaude Opus 4.7
7b2b74e79b Postbox -> TelegramEngine wave 6: unused import Postbox batch sweep
First build-verified unused-import sweep: speculatively dropped
import Postbox from 782 consumer files (plain ^import Postbox$ lines,
excluding TelegramCore/Postbox/TelegramApi paths), iterated 18 full
project builds with --continueOnError, restored the import on every
file that failed to compile. 183 drops survived; 189 consumer modules
newly Postbox-free.

Bundled: spec + plan + C1 atomic batch drop + C2 CLAUDE.md outcome and
permanent methodology guidance under Wave-selection. The methodology
subsection captures the reusable playbook (--continueOnError is
essential, dependency graphs are deep so expect many iterations,
pattern-based preemptive restores accelerate convergence, and
CLAUDE.md's engine typealias cheat sheet arrows are migration targets
rather than typealiases in TelegramCore).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 23:46:13 +02:00

76 lines
3.1 KiB
Swift

import Foundation
import UIKit
import Display
import AccountContext
import SwiftSignalKit
import TelegramCore
import AsyncDisplayKit
import ContextUI
import Pasteboard
import UndoUI
extension PeerInfoScreenNode {
func openNoteContextMenu(node: ASDisplayNode, gesture: ContextGesture?) {
guard let sourceNode = node as? ContextExtractedContentContainingNode else {
return
}
guard let cachedData = self.data?.cachedData else {
return
}
var noteText: String?
var noteEntities: [MessageTextEntity]?
if let cachedData = cachedData as? CachedUserData {
noteText = cachedData.note?.text
noteEntities = cachedData.note?.entities
}
guard let noteText, !noteText.isEmpty else {
return
}
let copyAction = { [weak self] in
guard let self else {
return
}
storeMessageTextInPasteboard(noteText, entities: noteEntities ?? [])
let toastText = self.presentationData.strings.PeerInfo_ToastNoteCopied
self.controller?.present(UndoOverlayController(presentationData: self.presentationData, content: .copy(text: toastText), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), in: .current)
}
var items: [ContextMenuItem] = []
items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.PeerInfo_NoteActionEdit, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Edit"), color: theme.contextMenu.primaryColor) }, action: { [weak self] c, _ in
c?.dismiss {
guard let self else {
return
}
self.headerNode.navigationButtonContainer.performAction?(.edit, nil, nil)
for (_, section) in self.editingSections {
for (id, itemNode) in section.itemNodes {
if id == AnyHashable("note_edit") {
if let itemNode = itemNode as? PeerInfoScreenNoteListItemNode {
itemNode.focus()
}
break
}
}
}
}
})))
let copyText = self.presentationData.strings.PeerInfo_NoteActionCopy
items.append(.action(ContextMenuActionItem(text: copyText, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Copy"), color: theme.contextMenu.primaryColor) }, action: { c, _ in
c?.dismiss {
copyAction()
}
})))
let actions = ContextController.Items(content: .list(items))
let contextController = makeContextController(presentationData: self.presentationData, source: .extracted(PeerInfoContextExtractedContentSource(sourceNode: sourceNode)), items: .single(actions), gesture: gesture)
self.controller?.present(contextController, in: .window(.root))
}
}