Consolidates 137 wave commits + 31 supporting commits (CLAUDE.md bump, typealias additions, AnyObject→EngineMedia restoration) into one squashed commit. Migrates dozens of consumer-side public APIs, struct fields, protocol methods, and enum payloads from Postbox protocols/structs to TelegramEngine engine wrappers and typealiases. Drops `import Postbox` from many files. Adds new TelegramCore typealiases and one TelegramEngineUnauthorized facade. Notable changes by category: **TelegramCore typealias additions** (rule 2 — narrow utility typealiases): - EngineChatListIndex, EngineTempBoxFile, EngineItemCollectionItemIndex, EngineItemCollectionViewEntryIndex, EngineValueBoxEncryptionParameters, EngineMessageAndThreadId, EnginePeerStoryStats, EngineMessageHistoryAnchorIndex, EngineChatListTotalUnreadStateCategory, EngineChatListTotalUnreadStateStats, EnginePeerSummaryCounterTags, EngineChatListTotalUnreadState, EngineItemCacheEntryId, EngineHashFunctions, EngineCachedMediaResourceRepresentationResult, EngineMediaResourceDataFetchResult, EngineMediaResourceDataFetchError, EngineMediaResourceStatus, EngineCachedPeerData **TelegramCore engine extensions/forwarders**: - EngineMessage.engineMedia, EngineMessage.enginePeers, EngineMessage.adAttribute, EngineMessage.effectivelyIncoming - engineFileSize forwarder - TelegramEngine.Resources.clearCachedMediaResources(mediaResourceIds: Set<EngineMediaResource.Id>) - TelegramEngine.Resources.fetchStatus(id:resourceSize:) - TelegramEngineUnauthorized.UnauthorizedResources facade with storeResourceData **Public API/struct migrations to engine types**: - ChatAvailableMessageActions.banAuthor/banAuthors → EnginePeer?/[EnginePeer] - WebSessionsContextState.peers → [EnginePeer.Id: EnginePeer] - CacheUsageStats.peers → [EnginePeer.Id: EnginePeer] - PeerCommand.peer → EnginePeer - PeerInfoControllerMode.calls(messages:) → [EngineMessage] - CallControllerNodeProtocol.updatePeer → EnginePeer params - ChatHistoryListNode.messageInCurrentHistoryView (and 4 variants) → EngineMessage? - ChatHistorySearchContainerNode.messageForGallery → EngineMessage? - PeerInfoPaneNode.findLoadedMessage / ensureMessageIsVisible / transitionNodeForGallery → engine-typed - GalleryHiddenMediaTarget.getTransitionInfo / GalleryHiddenMediaManager.findTarget → engine-typed - ChatPanelInterfaceInteraction.presentReactionDeletionOptions / presentBan*MessageOptions → EnginePeer - DrawingMessageRenderer.messages → [EngineMessage] - ChatVideoGalleryItemScrubberView.setFetchStatusSignal → EngineMediaResource.FetchStatus - ChannelDiscussionGroupActionSheetItem.peer, VoiceChatPeerEntry.peer, VoiceChatFullscreenParticipantItem.peer, MediaStreamComponent.chatPeer, MediaStreamVideoComponent.callPeer, ChatMessageContactBubbleContentNode.contactPeer, ChatMessageForwardInfoNode.peer, ChatMessageCommentFooterContentNode.replyPeers, ChatReportPeerTitlePanelNode.peer, ChatMessageActionUrlAuthController.bot, PeerMediaCollectionInterfaceState.peer, ChatMessageCallBubbleContentNode.peopleAvatars, ChatLoadingNode.renderedPeer (→ EngineRenderedPeer) — all to engine types **Wave-71-shadow stored-field migrations** (Postbox Peer/Message → Engine wrapper): - LegacyCallControllerNode.peer - CallStatusBarNode.currentPeer **Dead-code / dead-field removals**: - CallController.peer, CallControllerNodeV2.account, ContactMultiselectionController PeerNameIndex fields, preparedChatListNodeViewTransition account: Account param, FetchResource.swift entirely (unused function) **Module-level Postbox import drops**: 30+ files including TelegramRootController, EditStories, GiftViewScreen, AnimatedStickerUtils, FetchPhotoLibraryImageResource, PeerInfoGiftsPaneNode, PeerInfoPaneContainerNode, PresentAddMembers, PeerInfoProfileItems, ChatControllerAdminBanUsers, PresentationData typealiases, DefaultDayPresentationTheme, ChatListViewTransition, GalleryHiddenMediaManager, RecentSessionsController, GifContext, AuthorizationSequenceController, PeerInfoHeaderEditingContentNode, PeerInfoHeaderNode, PeerAllowedReactionListController, CallControllerNodeV2, and 6 PeerInfo pane files. **AnyObject restoration**: rule 8 added (never substitute Postbox protocols with Any/AnyObject) — undid previous AnyObject substitutions in waves 141/143 back to EngineMedia. Doc maintenance: CLAUDE.md updated to reflect new typealiases and forwarders. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
118 lines
6.2 KiB
Swift
118 lines
6.2 KiB
Swift
import Foundation
|
|
import SwiftSignalKit
|
|
import TelegramCore
|
|
|
|
public enum TotalUnreadCountDisplayStyle: Int32 {
|
|
case filtered = 0
|
|
|
|
public var category: EngineChatListTotalUnreadStateCategory {
|
|
switch self {
|
|
case .filtered:
|
|
return .filtered
|
|
}
|
|
}
|
|
}
|
|
|
|
public enum TotalUnreadCountDisplayCategory: Int32 {
|
|
case chats = 0
|
|
case messages = 1
|
|
|
|
public var statsType: EngineChatListTotalUnreadStateStats {
|
|
switch self {
|
|
case .chats:
|
|
return .chats
|
|
case .messages:
|
|
return .messages
|
|
}
|
|
}
|
|
}
|
|
|
|
public struct InAppNotificationSettings: Codable, Equatable {
|
|
public var playSounds: Bool
|
|
public var vibrate: Bool
|
|
public var displayPreviews: Bool
|
|
public var totalUnreadCountDisplayStyle: TotalUnreadCountDisplayStyle
|
|
public var totalUnreadCountDisplayCategory: TotalUnreadCountDisplayCategory
|
|
public var totalUnreadCountIncludeTags: EnginePeerSummaryCounterTags
|
|
public var displayNameOnLockscreen: Bool
|
|
public var displayNotificationsFromAllAccounts: Bool
|
|
public var customSound: String?
|
|
|
|
public static var defaultSettings: InAppNotificationSettings {
|
|
return InAppNotificationSettings(playSounds: true, vibrate: false, displayPreviews: true, totalUnreadCountDisplayStyle: .filtered, totalUnreadCountDisplayCategory: .messages, totalUnreadCountIncludeTags: .all, displayNameOnLockscreen: true, displayNotificationsFromAllAccounts: true, customSound: nil)
|
|
}
|
|
|
|
public init(playSounds: Bool, vibrate: Bool, displayPreviews: Bool, totalUnreadCountDisplayStyle: TotalUnreadCountDisplayStyle, totalUnreadCountDisplayCategory: TotalUnreadCountDisplayCategory, totalUnreadCountIncludeTags: EnginePeerSummaryCounterTags, displayNameOnLockscreen: Bool, displayNotificationsFromAllAccounts: Bool, customSound: String?) {
|
|
self.playSounds = playSounds
|
|
self.vibrate = vibrate
|
|
self.displayPreviews = displayPreviews
|
|
self.totalUnreadCountDisplayStyle = totalUnreadCountDisplayStyle
|
|
self.totalUnreadCountDisplayCategory = totalUnreadCountDisplayCategory
|
|
self.totalUnreadCountIncludeTags = totalUnreadCountIncludeTags
|
|
self.displayNameOnLockscreen = displayNameOnLockscreen
|
|
self.displayNotificationsFromAllAccounts = displayNotificationsFromAllAccounts
|
|
self.customSound = customSound
|
|
}
|
|
|
|
public init(from decoder: Decoder) throws {
|
|
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
|
|
|
self.playSounds = (try container.decode(Int32.self, forKey: "s")) != 0
|
|
self.vibrate = (try container.decode(Int32.self, forKey: "v")) != 0
|
|
self.displayPreviews = (try container.decode(Int32.self, forKey: "p")) != 0
|
|
self.totalUnreadCountDisplayStyle = TotalUnreadCountDisplayStyle(rawValue: try container.decode(Int32.self, forKey: "cds")) ?? .filtered
|
|
self.totalUnreadCountDisplayCategory = TotalUnreadCountDisplayCategory(rawValue: try container.decodeIfPresent(Int32.self, forKey: "totalUnreadCountDisplayCategory") ?? 1) ?? .messages
|
|
if let value = try container.decodeIfPresent(Int32.self, forKey: "totalUnreadCountIncludeTags_2") {
|
|
self.totalUnreadCountIncludeTags = EnginePeerSummaryCounterTags(rawValue: value)
|
|
} else if let value = try container.decodeIfPresent(Int32.self, forKey: "totalUnreadCountIncludeTags") {
|
|
var resultTags: EnginePeerSummaryCounterTags = []
|
|
for legacyTag in LegacyPeerSummaryCounterTags(rawValue: value) {
|
|
if legacyTag == .regularChatsAndPrivateGroups {
|
|
resultTags.insert(.contact)
|
|
resultTags.insert(.nonContact)
|
|
resultTags.insert(.bot)
|
|
resultTags.insert(.group)
|
|
} else if legacyTag == .publicGroups {
|
|
resultTags.insert(.group)
|
|
} else if legacyTag == .channels {
|
|
resultTags.insert(.channel)
|
|
}
|
|
}
|
|
self.totalUnreadCountIncludeTags = resultTags
|
|
} else {
|
|
self.totalUnreadCountIncludeTags = .all
|
|
}
|
|
self.displayNameOnLockscreen = (try container.decodeIfPresent(Int32.self, forKey: "displayNameOnLockscreen") ?? 1) != 0
|
|
self.displayNotificationsFromAllAccounts = (try container.decodeIfPresent(Int32.self, forKey: "displayNotificationsFromAllAccounts") ?? 1) != 0
|
|
|
|
self.customSound = try container.decodeIfPresent(String.self, forKey: "customSound")
|
|
}
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: StringCodingKey.self)
|
|
|
|
try container.encode((self.playSounds ? 1 : 0) as Int32, forKey: "s")
|
|
try container.encode((self.vibrate ? 1 : 0) as Int32, forKey: "v")
|
|
try container.encode((self.displayPreviews ? 1 : 0) as Int32, forKey: "p")
|
|
try container.encode(self.totalUnreadCountDisplayStyle.rawValue, forKey: "cds")
|
|
try container.encode(self.totalUnreadCountDisplayCategory.rawValue, forKey: "totalUnreadCountDisplayCategory")
|
|
try container.encode(self.totalUnreadCountIncludeTags.rawValue, forKey: "totalUnreadCountIncludeTags_2")
|
|
try container.encode((self.displayNameOnLockscreen ? 1 : 0) as Int32, forKey: "displayNameOnLockscreen")
|
|
try container.encode((self.displayNotificationsFromAllAccounts ? 1 : 0) as Int32, forKey: "displayNotificationsFromAllAccounts")
|
|
try container.encodeIfPresent(self.customSound, forKey: "customSound")
|
|
}
|
|
}
|
|
|
|
public func updateInAppNotificationSettingsInteractively(accountManager: AccountManager<TelegramAccountManagerTypes>, _ f: @escaping (InAppNotificationSettings) -> InAppNotificationSettings) -> Signal<Void, NoError> {
|
|
return accountManager.transaction { transaction -> Void in
|
|
transaction.updateSharedData(ApplicationSpecificSharedDataKeys.inAppNotificationSettings, { entry in
|
|
let currentSettings: InAppNotificationSettings
|
|
if let entry = entry?.get(InAppNotificationSettings.self) {
|
|
currentSettings = entry
|
|
} else {
|
|
currentSettings = InAppNotificationSettings.defaultSettings
|
|
}
|
|
return EnginePreferencesEntry(f(currentSettings))
|
|
})
|
|
}
|
|
}
|