From 41aef1c928e6b4c79980e3b8520a22749a66f469 Mon Sep 17 00:00:00 2001 From: isaac <> Date: Thu, 4 Jun 2026 20:49:24 +0200 Subject: [PATCH] InstantPage: exclude audio/music from the rich-content gallery openInstantPageMedia builds the gallery from allMedias() filtered to .image / .file. An audio track is an EngineMedia.file (a TelegramMediaFile with an .Audio attribute), so it passed the .file case and appeared as a gallery entry. Audio is enrolled in allMedias() only so the audio player can gather sibling tracks for its playlist (handleOpenAudioTap); it is not visual gallery content. Split the .file case to keep videos/gifs/documents but drop music and voice (!file.isMusic && !file.isVoice). No-op for V1 full-page Instant View (its mediasFromItems never enrolled audio); fixes the V2 rich bubble. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../InstantPageUI/Sources/InstantPageMediaOpen.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/submodules/InstantPageUI/Sources/InstantPageMediaOpen.swift b/submodules/InstantPageUI/Sources/InstantPageMediaOpen.swift index b2e0805914..22ec793857 100644 --- a/submodules/InstantPageUI/Sources/InstantPageMediaOpen.swift +++ b/submodules/InstantPageUI/Sources/InstantPageMediaOpen.swift @@ -13,8 +13,9 @@ import LocationUI /// - `.geo(map)` → pushes `LocationViewController` via `push`. /// - `.webpage(webPage)` cover → single-entry `InstantPageGalleryController`. /// - `.file(file)` with `isAnimated` → single-entry gallery in "playing video" mode. -/// - Default → multi-entry gallery built from `allMedias` (filtered to `.image / .file`), -/// centered on the tapped media; "playing video" mode is on. +/// - Default → multi-entry gallery built from `allMedias` (filtered to `.image` and non-audio +/// `.file` — audio/music siblings are excluded), centered on the tapped media; "playing +/// video" mode is on. /// /// Behavior matches V1's `InstantPageControllerNode.openMedia(_:)` bit-for-bit. /// @@ -66,8 +67,13 @@ public func openInstantPageMedia( fromPlayingVideo = true let filteredMedias = allMedias.filter { item in switch item.media { - case .image, .file: + case .image: return true + case let .file(file): + // Audio/music files are enrolled in `allMedias()` only so the audio playlist can + // gather its siblings (see `handleOpenAudioTap`); they are not visual gallery + // content, so keep videos/gifs/documents but exclude music and voice. + return !file.isMusic && !file.isVoice default: return false }