From a5825d5a67692f0c5c4631cf9023b418928f9f98 Mon Sep 17 00:00:00 2001 From: isaac <> Date: Thu, 4 Jun 2026 15:54:27 +0200 Subject: [PATCH] Rich text wip --- .../Sources/InstantPageV2SlideshowView.swift | 2 ++ .../SyncCore_RichTextMessageAttribute.swift | 24 --------------- ...yncCore_StandaloneAccountTransaction.swift | 30 ++++++++++++++++++- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/submodules/InstantPageUI/Sources/InstantPageV2SlideshowView.swift b/submodules/InstantPageUI/Sources/InstantPageV2SlideshowView.swift index 9e0dafa35f..25b963c0f4 100644 --- a/submodules/InstantPageUI/Sources/InstantPageV2SlideshowView.swift +++ b/submodules/InstantPageUI/Sources/InstantPageV2SlideshowView.swift @@ -39,6 +39,8 @@ final class InstantPageV2SlideshowView: UIView, InstantPageItemView, UIScrollVie self.backgroundColor = theme.panelSecondaryColor // structural self.clipsToBounds = true // structural + self.scrollView.disablesInteractiveTransitionGestureRecognizer = true + self.scrollView.isPagingEnabled = true self.scrollView.showsHorizontalScrollIndicator = false self.scrollView.showsVerticalScrollIndicator = false diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_RichTextMessageAttribute.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_RichTextMessageAttribute.swift index 6989687dfe..0bcf72afdf 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_RichTextMessageAttribute.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_RichTextMessageAttribute.swift @@ -6,34 +6,10 @@ public class RichTextMessageAttribute: MessageAttribute, Equatable { public let instantPage: InstantPage public var associatedPeerIds: [PeerId] { - /*var result: [PeerId] = [] - for entity in entities { - switch entity.type { - case let .TextMention(peerId): - result.append(peerId) - default: - break - } - } - return result*/ return [] } public var associatedMediaIds: [MediaId] { - /*var result: [MediaId] = [] - for entity in self.entities { - switch entity.type { - case let .CustomEmoji(_, fileId): - result.append(MediaId(namespace: Namespaces.Media.CloudFile, id: fileId)) - default: - break - } - } - if result.isEmpty { - return result - } else { - return Array(Set(result)) - }*/ return [] } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_StandaloneAccountTransaction.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_StandaloneAccountTransaction.swift index cbb1035e4c..ea3445d826 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_StandaloneAccountTransaction.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_StandaloneAccountTransaction.swift @@ -129,8 +129,15 @@ public let telegramPostboxSeedConfiguration: SeedConfiguration = { break } } + var previousRichText: RichTextMessageAttribute? + for attribute in previous { + if let attribute = attribute as? RichTextMessageAttribute { + previousRichText = attribute + break + } + } - if let audioTranscription = audioTranscription { + if let audioTranscription { var found = false for i in 0 ..< updated.count { if let attribute = updated[i] as? AudioTranscriptionMessageAttribute { @@ -155,6 +162,27 @@ public let telegramPostboxSeedConfiguration: SeedConfiguration = { updated.append(previousDerivedData) } } + if let previousRichText, previousRichText.instantPage.isComplete { + for i in 0 ..< updated.count { + if let attribute = updated[i] as? RichTextMessageAttribute { + if !attribute.instantPage.isComplete { + var prefixEquals = true + if attribute.instantPage.blocks.count <= previousRichText.instantPage.blocks.count { + inner: for j in 0 ..< attribute.instantPage.blocks.count { + if attribute.instantPage.blocks[j] != attribute.instantPage.blocks[j] { + prefixEquals = false + break inner + } + } + } + if prefixEquals { + updated[i] = previousRichText + } + } + break + } + } + } }, decodeMessageThreadInfo: { entry in guard let data = entry.get(MessageHistoryThreadData.self) else {