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>
95 lines
3.7 KiB
Swift
95 lines
3.7 KiB
Swift
import Foundation
|
|
import TelegramCore
|
|
import SwiftSignalKit
|
|
|
|
public struct WebBrowserException: Codable, Equatable {
|
|
public let domain: String
|
|
public let title: String
|
|
public let icon: TelegramMediaImage?
|
|
|
|
public init(domain: String, title: String, icon: TelegramMediaImage?) {
|
|
self.domain = domain
|
|
self.title = title
|
|
self.icon = icon
|
|
}
|
|
|
|
public init(from decoder: Decoder) throws {
|
|
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
|
|
|
self.domain = try container.decode(String.self, forKey: "domain")
|
|
self.title = try container.decode(String.self, forKey: "title")
|
|
self.icon = try container.decodeIfPresent(TelegramMediaImage.self, forKey: "icon")
|
|
}
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: StringCodingKey.self)
|
|
|
|
try container.encode(self.domain, forKey: "domain")
|
|
try container.encode(self.title, forKey: "title")
|
|
if let icon = self.icon {
|
|
try container.encode(icon, forKey: "icon")
|
|
} else {
|
|
try container.encodeNil(forKey: "icon")
|
|
}
|
|
}
|
|
}
|
|
|
|
public struct WebBrowserSettings: Codable, Equatable {
|
|
public let defaultWebBrowser: String?
|
|
public let exceptions: [WebBrowserException]
|
|
|
|
public static var defaultSettings: WebBrowserSettings {
|
|
return WebBrowserSettings(defaultWebBrowser: nil, exceptions: [])
|
|
}
|
|
|
|
public init(defaultWebBrowser: String?, exceptions: [WebBrowserException]) {
|
|
self.defaultWebBrowser = defaultWebBrowser
|
|
self.exceptions = exceptions
|
|
}
|
|
|
|
public init(from decoder: Decoder) throws {
|
|
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
|
|
|
self.defaultWebBrowser = try? container.decodeIfPresent(String.self, forKey: "defaultWebBrowser")
|
|
self.exceptions = (try? container.decodeIfPresent([WebBrowserException].self, forKey: "exceptions")) ?? []
|
|
}
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: StringCodingKey.self)
|
|
|
|
try container.encodeIfPresent(self.defaultWebBrowser, forKey: "defaultWebBrowser")
|
|
try container.encode(self.exceptions, forKey: "exceptions")
|
|
}
|
|
|
|
public static func ==(lhs: WebBrowserSettings, rhs: WebBrowserSettings) -> Bool {
|
|
if lhs.defaultWebBrowser != rhs.defaultWebBrowser {
|
|
return false
|
|
}
|
|
if lhs.exceptions != rhs.exceptions {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
public func withUpdatedDefaultWebBrowser(_ defaultWebBrowser: String?) -> WebBrowserSettings {
|
|
return WebBrowserSettings(defaultWebBrowser: defaultWebBrowser, exceptions: self.exceptions)
|
|
}
|
|
|
|
public func withUpdatedExceptions(_ exceptions: [WebBrowserException]) -> WebBrowserSettings {
|
|
return WebBrowserSettings(defaultWebBrowser: self.defaultWebBrowser, exceptions: exceptions)
|
|
}
|
|
}
|
|
|
|
public func updateWebBrowserSettingsInteractively(accountManager: AccountManager<TelegramAccountManagerTypes>, _ f: @escaping (WebBrowserSettings) -> WebBrowserSettings) -> Signal<Void, NoError> {
|
|
return accountManager.transaction { transaction -> Void in
|
|
transaction.updateSharedData(ApplicationSpecificSharedDataKeys.webBrowserSettings, { entry in
|
|
let currentSettings: WebBrowserSettings
|
|
if let entry = entry?.get(WebBrowserSettings.self) {
|
|
currentSettings = entry
|
|
} else {
|
|
currentSettings = WebBrowserSettings.defaultSettings
|
|
}
|
|
return EnginePreferencesEntry(f(currentSettings))
|
|
})
|
|
}
|
|
}
|