31 waves of consumer-side migration from `import Postbox` to TelegramEngine typealiases. Net: 173 import drops + 39 BUILD-dep drops + 1 new typealias (`EngineStoryId = StoryId`, wave 113). Wave shapes used: - Orphan-import sweeps (107, 108, 128): drop `import Postbox` from files whose only Postbox-symbol reference was the import line itself, then resolve build failures. Methodology requires token-level (`grep -oE`) filtering, not line-level, to avoid masking real Postbox usage on lines that also contain `Namespaces.X` references. - Identifier-swap mini-waves (109-127, 129-134, 136-137): rename Postbox-typealiased identifiers to engine equivalents (PeerId -> EnginePeer.Id, MessageId -> EngineMessage.Id, MediaId -> EngineMedia.Id, MessageIndex -> EngineMessage.Index, StoryId -> EngineStoryId, ItemCollectionId -> EngineItemCollectionId, PreferencesEntry -> EnginePreferencesEntry, FetchResourceSourceType/Error -> EngineFetchResourceSourceType/Error, MemoryBuffer -> EngineMemoryBuffer, MessageTags -> EngineMessage.Tags, MessageAttribute -> EngineMessage.Attribute, TempBox -> EngineTempBox). - Asset-string FP-only orphans (124). - Typealias addition + drain (113): added `EngineStoryId` typealias to TelegramCore, then drained 3+11 consumer sites. Hard blockers identified during these waves (must restore `import Postbox` when present): MediaResource[A-Za-z]* (any suffix -- the literal `MediaResource` matches don't catch MediaResourceData/MediaResourceId/etc.), Postbox/MediaBox/MediaResource raw types, PostboxCoding/PostboxEncoder/ PostboxDecoder, TempBoxFile, ValueBoxKey, PostboxView, combinedView, HashFunctions, postboxLog, openPostbox, declareEncodable, PeerView, MessageHistoryView, MessageHistoryThreadData, CachedPeerData, RenderedPeer, SelectivePrivacyPeer, SimpleDictionary, ItemCollectionInfosView, ItemCollectionItem, ItemCollectionItemIndex, ItemCollectionViewEntryIndex, ChatListIndex, ChatListEntrySummaryComponents, CodableEntry, MessageHistoryThread, MessageHistoryAnchorIndex, MessageHistoryEntryLocation, PeerStoryStats, PeerNameIndex, PeerSummaryCounterTags, ChatListTotalUnreadStateCategory/Stats, arePeersEqual. Protocol-shape blockers: bare `Peer`/`Message`/`Media` in function signatures, generic args, enum-case payloads, or dict value types (e.g., `[PeerId: Peer]`, `case messages([Message])`, `Signal<(Peer?, ...), NoError>`). `replace_all PeerId -> EnginePeer.Id` is dangerous: mangles compound names like `failedPeerId`, `ContactListPeerId`, `nextRemoteMediaId`, `replyToMessageId`. Pre-flight grep `\b[a-z][a-zA-Z]*PeerId\b` and only replace_all if 0 matches. Also removes unneeded design/plan docs from a separate (link-highlighting) feature branch: - docs/superpowers/plans/2026-05-02-link-highlighting-modern-path-fixes.md - docs/superpowers/specs/2026-05-02-link-highlighting-modern-path-fixes-design.md Squashed commits: 6d82c2980d..e6de5d53a3 (59 commits, including per-wave content commits and per-wave CLAUDE.md bumps). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
116 lines
4.7 KiB
Swift
116 lines
4.7 KiB
Swift
import Foundation
|
|
import UIKit
|
|
import SwiftSignalKit
|
|
import TelegramCore
|
|
import AsyncDisplayKit
|
|
import Display
|
|
import ContextUI
|
|
import UndoUI
|
|
import AccountContext
|
|
import ChatMessageItemView
|
|
import ChatMessageItemCommon
|
|
import ChatControllerInteraction
|
|
|
|
extension ChatControllerImpl {
|
|
func openTimecodeContextMenu(timecode: String, value: Double, params: ChatControllerInteraction.LongTapParams) -> Void {
|
|
guard let message = params.message, let contentNode = params.contentNode else {
|
|
return
|
|
}
|
|
|
|
guard let messages = self.chatDisplayNode.historyNode.messageGroupInCurrentHistoryView(message.id) else {
|
|
return
|
|
}
|
|
|
|
var updatedMessages = messages
|
|
for i in 0 ..< updatedMessages.count {
|
|
if updatedMessages[i].id == message.id {
|
|
let message = updatedMessages.remove(at: i)
|
|
updatedMessages.insert(message, at: 0)
|
|
break
|
|
}
|
|
}
|
|
|
|
let recognizer: TapLongTapOrDoubleTapGestureRecognizer? = params.gesture
|
|
let gesture: ContextGesture? = nil
|
|
|
|
let source: ContextContentSource = .extracted(ChatMessageLinkContextExtractedContentSource(chatNode: self.chatDisplayNode, contentNode: contentNode))
|
|
|
|
var items: [ContextMenuItem] = []
|
|
|
|
items.append(
|
|
.action(ContextMenuActionItem(text: self.presentationData.strings.Chat_Context_Timecode_Copy, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Copy"), color: theme.contextMenu.primaryColor) }, action: { [weak self] _, f in
|
|
f(.default)
|
|
|
|
guard let self else {
|
|
return
|
|
}
|
|
|
|
if message.id.namespace == Namespaces.Message.Cloud, let channel = message.peers[message.id.peerId] as? TelegramChannel, let addressName = channel.addressName {
|
|
var timestampSuffix = ""
|
|
let startAtTimestamp = parseTimeString(timecode)
|
|
|
|
var startAtTimestampString = ""
|
|
let hours = startAtTimestamp / 3600
|
|
let minutes = startAtTimestamp / 60 % 60
|
|
let seconds = startAtTimestamp % 60
|
|
if hours == 0 && minutes == 0 {
|
|
startAtTimestampString = "\(startAtTimestamp)"
|
|
} else {
|
|
if hours != 0 {
|
|
startAtTimestampString += "\(hours)h"
|
|
}
|
|
if minutes != 0 {
|
|
startAtTimestampString += "\(minutes)m"
|
|
}
|
|
if seconds != 0 {
|
|
startAtTimestampString += "\(seconds)s"
|
|
}
|
|
}
|
|
timestampSuffix = "?t=\(startAtTimestampString)"
|
|
let inputCopyText = "https://t.me/\(addressName)/\(message.id.id)\(timestampSuffix)"
|
|
UIPasteboard.general.string = inputCopyText
|
|
} else {
|
|
UIPasteboard.general.string = timecode
|
|
}
|
|
|
|
self.present(UndoOverlayController(presentationData: self.presentationData, content: .copy(text: presentationData.strings.Conversation_TextCopied), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), in: .current)
|
|
}))
|
|
)
|
|
|
|
self.canReadHistory.set(false)
|
|
|
|
let controller = makeContextController(presentationData: self.presentationData, source: source, items: .single(ContextController.Items(content: .list(items))), recognizer: recognizer, gesture: gesture, disableScreenshots: false)
|
|
controller.dismissed = { [weak self] in
|
|
self?.canReadHistory.set(true)
|
|
}
|
|
|
|
self.window?.presentInGlobalOverlay(controller)
|
|
}
|
|
}
|
|
|
|
private func parseTimeString(_ timeString: String) -> Int {
|
|
let parts = timeString.split(separator: ":").map(String.init)
|
|
|
|
switch parts.count {
|
|
case 1:
|
|
// Single component (e.g. "1", "10") => seconds
|
|
return Int(parts[0]) ?? 0
|
|
|
|
case 2:
|
|
// Two components (e.g. "1:01", "10:30") => minutes:seconds
|
|
let minutes = Int(parts[0]) ?? 0
|
|
let seconds = Int(parts[1]) ?? 0
|
|
return minutes * 60 + seconds
|
|
|
|
case 3:
|
|
// Three components (e.g. "1:01:01", "10:00:00") => hours:minutes:seconds
|
|
let hours = Int(parts[0]) ?? 0
|
|
let minutes = Int(parts[1]) ?? 0
|
|
let seconds = Int(parts[2]) ?? 0
|
|
return hours * 3600 + minutes * 60 + seconds
|
|
|
|
default:
|
|
// Fallback to 0 or handle invalid format
|
|
return 0
|
|
}
|
|
}
|