mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-06-20 18:24:43 +00:00
a731f8bdc0
Render RichText.textDate (API constructor textDate(flags, text, date)) as a locale/timezone-correct, relative-aware, tappable date inside V2 rich-message bubbles, reusing the existing stringForEntityFormattedDate autoformatter. - Model: add RichText.textDate(text:date:format:) with Postbox coding, FlatBuffers schema (RichText.fbs; flatc regenerates), Equatable and plainText; parse flags->DateTimeFormat? at the API boundary (flags==0 => nil, matching the messageEntityFormattedDate convention) with a symmetric apiRichText() round-trip. The new case is handled in every exhaustive RichText switch (SyncCore, ApiUtils, InstantPageTextItem, InstantPageAnchorPath, InstantPagePreviewText, BrowserReadability, BrowserMarkdown). - Render: attributedStringForRichText gains an optional formatDate closure; the V2 layout builds it from the message's strings/dateTimeFormat and threads it to every text-building call site, formatting the timestamp and tagging the run with TelegramTextAttributes.Date. - Tappable: the Date attribute is added to linkSelectionRects hit-testing and mapped in the rich bubble's entityTapContent to the existing .date tap action (opens the date context menu). - Live update: the V2 layout accumulates a page-wide formattedDateUpdatePeriod (>=10s) for relative dates; the rich bubble schedules a refresh timer on it, recreating it only when the period changes. The currentPageLayout cache is bypassed for relative-date pages so the timer-driven relayout actually re-formats the date. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>