76 Commits

Author SHA1 Message Date
isaac 493f3103b3 Postbox -> TelegramEngine waves 37-43 + wave 44 design/plan (squashed)
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>
2026-04-24 23:19:43 +04:00
Isaac 1a432362a3 Postbox -> TelegramEngine wave 9: StorageUsageScreen preferences-view rewrite
Closes the first of the two future-wave candidates left open by wave 8 by
rewriting both AccountSpecificCacheStorageSettings preferences-view
observation sites in StorageUsageScreen.swift using engine APIs, and
drops import Postbox from that file.

Site 1 — cacheSettingsExceptionCount (former 1047-1087):
  postbox.combinedView(keys: [.preferences(keys: Set([...]))]) +
  PreferencesView                ->
    context.engine.data.subscribe(TelegramEngine.EngineData.Item
                                    .Configuration.ApplicationSpecific-
                                    Preference(key: ...))
                                   + preferencesEntry?.get(...)

Site 2 — peerExceptions (former 3131-3196):
  - Same preferences-observation replacement as Site 1.
  - postbox.transaction { transaction.getPeer / getPeerCachedData as?
    CachedGroupData / CachedChannelData; FoundPeer(peer:subscribers:) }
    -> context.engine.data.get(EngineDataMap(...TelegramEngine.Engine-
       Data.Item.Peer.Peer.init(id:))) + pattern match on EnginePeer
       .user / .secretChat / .legacyGroup / .channel
  - Signal element: [(peer: FoundPeer, value: Int32)] -> [(peer: Engine-
    Peer, value: Int32)]. FoundPeer wrapper and its `subscribers` field
    dropped — computed but never read downstream (consumers only read
    .isEmpty, .count, and .prefix(3).map { EnginePeer($0.peer.peer) }).

Consumer update:
  peerExceptions.prefix(3).map { EnginePeer($0.peer.peer) } ->
      .prefix(3).map { $0.peer }

Typealias fixup (caught by first-pass build failure):
  var mergedMedia: [MessageId: Int64] -> [EngineMessage.Id: Int64]
  (MessageId is raw Postbox; must use the EngineMessage.Id typealias
   when import Postbox is removed.)

Reusable pattern documented in CLAUDE.md: TelegramEngine.EngineData.Item
.Configuration.ApplicationSpecificPreference(key: ValueBoxKey) is the
general-purpose engine replacement for the postbox.combinedView(keys:
[.preferences(keys: Set([key]))]) + PreferencesView idiom. Works from
any module importing TelegramCore (without import Postbox) because
passing PreferencesKeys.<name> keeps ValueBoxKey as an inferred-only
type that never gets named in the consumer.

Net: 1 file changed, +30 / -54.

StorageUsageScreen.swift is now Postbox-free. The wave 8 outcome's other
future candidate (StorageFileListPanelComponent.swift's Icon.media(Media,
...) enum case) remains — trivial future wave will land the whole-module
drop.

Plan: docs/superpowers/plans/2026-04-20-postbox-to-telegramengine-wave-9.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 01:11:50 +02:00
Isaac 635d392484 Postbox -> TelegramEngine wave 8: StorageUsageScreen domain-type migration
Narrow consumer-module migration of raw Message types to EngineMessage in
the StorageUsageScreen component. Two files touched; the module keeps
import Postbox because of two out-of-scope site clusters (preferences-
view observation + a Media-carrying Icon enum case) — both flagged in
CLAUDE.md and the wave doc as future-wave targets.

StorageUsageScreen.swift:
  SelectionState.togglePeer(availableMessages:)
      [EngineMessage.Id: Message]  -> [EngineMessage.Id: EngineMessage]
  AggregatedData.messages
      [MessageId: Message]         -> [EngineMessage.Id: EngineMessage]
  AggregatedData.clearIncludeMessages / .clearExcludeMessages
      [Message]                     -> [EngineMessage]
  AggregatedData.init messages param — same swap
  RenderResult.messages
      [MessageId: Message]         -> [EngineMessage.Id: EngineMessage]
  openMessage(message: Message)    -> openMessage(message: EngineMessage)
                                      (unwrap to raw at OpenChatMessageParams
                                       / chatMediaListPreviewControllerData
                                       call sites via ._asMessage())

StorageFileListPanelComponent.swift:
  Item.message: Message            -> EngineMessage
                                      (internal .id / .timestamp / .media
                                       usage compiles unchanged against the
                                       EngineMessage class).

Wave-7 facade-boundary bridging dropped:
  - renderStorageUsageStatsMessages call site: the .mapValues(EngineMessage.init)
    on existingMessages and .mapValues { $0._asMessage() } on the result vanish;
    AggregatedData.messages and RenderResult.messages are now engine-typed on
    both sides of the facade.
  - clearStorage call sites (2): the .map(EngineMessage.init) wraps around
    includeMessages / excludeMessages vanish; locals become [EngineMessage].
  - Inside AggregatedData.updateSelected... accumulation loop, four
    item.message._asMessage() calls (where item.message was EngineMessage
    and the target was [Message]) drop back to plain item.message.
  - StorageMediaGridPanelComponent.Item(message: EngineMessage(message), ...)
    at the RenderResult-build loop loses the EngineMessage(...) wrap since
    `message` is already EngineMessage.

Out of scope (module keeps import Postbox):
  - StorageUsageScreen.swift:1047-1062 / 3131-3185 — AccountSpecificCache-
    StorageSettings observation via postbox.combinedView + PreferencesView
    and a postbox.transaction block doing transaction.getPeer / getPeerCached-
    Data as? CachedGroupData/CachedChannelData for peer-category classification.
  - StorageFileListPanelComponent.swift:105 — Icon.media(Media, ...) enum case.
    Constructed only as .media(TelegramMediaFile, ...) or .media(TelegramMedia-
    Image, ...); trivial future wave to split into two cases.

Build verified green: 59s incremental, 27 actions, Telegram.ipa produced.

Plan: docs/superpowers/plans/2026-04-20-postbox-to-telegramengine-wave-8.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 00:39:19 +02:00
Isaac b2ba4b5878 Postbox -> TelegramEngine wave 7: last TelegramEngine.* facade leaks
Closes the seven remaining raw-Postbox leaks in TelegramEngine public
facades surfaced by a post-wave-6 scouting pass (all non-permanently-
blocked candidates).

Facades migrated in place (6 rewrites + 1 deletion; all _internal_*
implementations unchanged per the "internal Postbox-facing stays raw"
rule):

  Messages:
    downloadMessage                          Signal<Message?>           -> Signal<EngineMessage?>
    topPeerActiveLiveLocationMessages        Signal<(Peer?, [Message])> -> Signal<(EnginePeer?, [EngineMessage])>
    getSynchronizeAutosaveItemOperations     deleted (dead facade; sole caller uses _internal_ directly)

  Peers:
    updatedRemotePeer                        Signal<Peer>  -> Signal<EnginePeer>
                                             (PeerReference param kept; no EnginePeer.Reference alias today)

  Resources:
    renderStorageUsageStatsMessages          [EngineMessage.Id: Message]  -> [EngineMessage.Id: EngineMessage]
    clearStorage(peerId: ...)                [Message]                     -> [EngineMessage]
    clearStorage(peerIds: ...)               [Message]                     -> [EngineMessage]
    clearStorage(messages:)                  [Message]                     -> [EngineMessage]
                                             (no external callers; migrated for overload-set consistency)

Consumer call-site updates (5 files):
  - ChatListSearchListPaneNode       drop redundant .flatMap(EngineMessage.init) wrap
  - LocationViewControllerNode       drop redundant .map(EngineMessage.init) wrap
  - LiveLocationSummaryManager       drop redundant EnginePeer(...) / EngineMessage(...) ctors
  - StorageUsageScreen               bridge [Message] <-> [EngineMessage] at the 4 facade-call points
                                     (internal [MessageId: Message] / [Message] storage kept;
                                      full-consumer-module migration is out of scope)

Discovery: grep of TelegramEngine/*/TelegramEngine*.swift public signatures
for `: Postbox|: Account|: MediaBox|: MediaResource|: Peer\b|: Message\b|
-> Signal<.*(Peer|Message)` turned up these seven candidates and no others.
After this wave, the full TelegramEngine.* facade surface is engine-typed
modulo the four permanently-blocked TelegramMediaResource-conforming
classes recorded in CLAUDE.md (ICloudFileResource, InstantPageExternal-
MediaResource, VideoLibraryMediaResource, YoutubeEmbedStoryboardMedia-
Resource).

No modules became Postbox-free in this wave. Plan: docs/superpowers/
plans/2026-04-20-postbox-to-telegramengine-wave-7.md.

Full project build verified green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 00:25:28 +02:00
Isaac 796826b0ad Various improvements 2026-03-31 22:42:02 +08:00
Isaac 72fbe5d7a7 Various improvements 2026-03-13 14:54:44 +01:00
Ilya Laktyushin 246b97ce8e Various fixes 2026-03-12 15:53:10 +01:00
Ilya Laktyushin 8def1683b9 Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios 2026-02-21 13:45:36 +04:00
Ilya Laktyushin 96bb624b2d Merge branch 'formatted-date-api' 2026-02-06 14:25:09 +04:00
Ilya Laktyushin 0d12dd29ad Various improvements 2026-01-25 22:17:49 +04:00
Isaac ca6fdc1629 Glass 2026-01-25 00:31:18 +08:00
Isaac 2db08cde89 Glass 2026-01-13 19:21:49 +04:00
Isaac 3486393f99 Glass 2025-12-20 03:02:08 +08:00
Ilya Laktyushin 85092482f3 Various improvements 2025-10-17 17:01:25 +04:00
Ilya Laktyushin 91036bcdc2 Force external for video ads 2025-08-13 18:07:18 +04:00
Isaac c7a2fe5d3e Update to iOS 13 2025-06-11 16:59:53 +08:00
Isaac 0e119dd6f1 [WIP] Monoforums 2025-05-08 20:56:55 +01:00
Isaac 28f246749f [WIP] Monoforums 2025-05-06 17:00:11 +02:00
Isaac aaf52d4282 Conference calls 2025-03-30 02:06:50 +04:00
Ilya Laktyushin 2fa059477c Various fixes 2024-10-25 03:04:39 +04:00
Ilya Laktyushin 6109477015 Various improvements 2024-08-11 00:14:00 +02:00
Ilya Laktyushin d0156faede Various improvements 2024-08-10 18:41:17 +02:00
Ilya Laktyushin 39598deb04 Add reply action in gallery 2024-07-03 21:43:18 +04:00
Isaac 9a075fa39e Refactoring 2024-06-12 23:04:04 +04:00
Isaac 16faaa4575 [WIP] Send message effects 2024-05-03 22:56:50 +04:00
Isaac d4f7440703 Saved message improvements 2024-01-29 21:23:19 +01:00
Isaac 0ad61d8d63 [WIP] Saved messages 2023-12-23 00:47:22 +04:00
Isaac b5029991f2 [WIP] Saved messages 2023-12-12 22:37:02 +04:00
Ilya Laktyushin df505a7b62 Various improvements 2023-10-22 13:52:38 +04:00
Ali 627009f32e [WIP] Quotes 2023-10-11 00:40:43 +04:00
Ilya Laktyushin f13b1da0bb Web app improvements 2023-09-09 17:34:49 +04:00
Ali f4545aaeeb Support updated API 2023-09-05 13:41:05 +04:00
Ali 77a5857a25 Sharing refactoring 2023-08-15 23:57:04 +04:00
Ali 458a153bad Stories 2023-08-10 00:13:20 +03:00
Ali 295ba9541b Localization 2023-07-16 19:32:01 +04:00
Ali f305edfb17 Stories 2023-07-14 20:49:24 +04:00
Ali 34e8c54bb0 Stories 2023-06-20 12:26:09 +03:00
Ali de8c3f055f [WIP] Stories 2023-06-09 01:07:41 +04:00
Ali 95947fdb99 Refactoring [skip ci] 2023-04-20 18:43:29 +04:00
Ilya Laktyushin 16d80ea910 Fix cache clearing progress positioning 2023-03-30 19:35:57 +04:00
Ilya Laktyushin 5149253333 Don't mark messages as read when something is covering the chat screen 2023-03-23 22:52:31 +04:00
Ali d846bbf510 Add clear storage progress 2023-03-07 13:45:21 +04:00
Ali 274aa510b1 UI improvements 2023-03-02 19:05:19 +04:00
Ali 0dfbf5926b Update cache settings 2023-01-27 19:53:32 +01:00
Ali 1a53010f54 Data usage UI improvements 2023-01-19 22:48:13 +04:00
Ali 41060f0da0 Modernized save to gallery 2023-01-13 21:14:45 +04:00
Ali a7fd29fe10 Various improvements 2023-01-10 21:52:58 +04:00
Ali 58f6657c6e API updates, token login support, initial data usage screen implementation 2023-01-07 00:36:12 +04:00
Ali da7b04a592 Storage usage improvements 2023-01-03 17:44:14 +04:00
Ali b41aa0fd05 Small adjustments 2022-12-31 14:52:27 +04:00