From 6fd65e6d26596704e51830f4625e3484293d23d4 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 22 Mar 2026 16:53:55 +0100 Subject: [PATCH] Various improvements --- .../AccountContext/Sources/MediaManager.swift | 11 +++---- .../Sources/ChatListControllerNode.swift | 30 +++++++++++-------- .../Sources/ChatListSearchListPaneNode.swift | 2 +- .../Sources/AttachmentFileController.swift | 4 +-- .../Sources/AttachmentFileSearchItem.swift | 2 +- .../Sources/PeerMessagesMediaPlaylist.swift | 6 ++-- .../Sources/ChatControllerNode.swift | 30 +++++++++++-------- .../OverlayAudioPlayerControllerNode.swift | 6 ++-- 8 files changed, 50 insertions(+), 41 deletions(-) diff --git a/submodules/AccountContext/Sources/MediaManager.swift b/submodules/AccountContext/Sources/MediaManager.swift index 02cd0173d0..19db4f51a4 100644 --- a/submodules/AccountContext/Sources/MediaManager.swift +++ b/submodules/AccountContext/Sources/MediaManager.swift @@ -28,7 +28,7 @@ public enum PeerMessagesPlaylistLocation: Equatable, SharedMediaPlaylistLocation case singleMessage(MessageId) case recentActions(Message) case savedMusic(context: ProfileSavedMusicContext, at: Int32, canReorder: Bool) - case custom(messages: Signal<([Message], Int32, Bool), NoError>, canReorder: Bool, at: MessageId, loadMore: (() -> Void)?) + case custom(messages: Signal<([Message], Int32, Bool), NoError>, canReorder: Bool, at: MessageId, loadMore: (() -> Void)?, hidePanel: Bool) public var playlistId: PeerMessagesMediaPlaylistId { switch self { @@ -84,7 +84,8 @@ public enum PeerMessagesPlaylistLocation: Equatable, SharedMediaPlaylistLocation return } savedMusicContext.loadMore() - } + }, + hidePanel: false ) default: return self @@ -93,7 +94,7 @@ public enum PeerMessagesPlaylistLocation: Equatable, SharedMediaPlaylistLocation public var messageId: MessageId? { switch self { - case let .messages(_, _, messageId), let .singleMessage(messageId), let .custom(_, _, messageId, _): + case let .messages(_, _, messageId), let .singleMessage(messageId), let .custom(_, _, messageId, _, _): return messageId default: return nil @@ -134,8 +135,8 @@ public enum PeerMessagesPlaylistLocation: Equatable, SharedMediaPlaylistLocation } else { return false } - case let .custom(_, _, lhsAt, _): - if case let .custom(_, _, rhsAt, _) = rhs, lhsAt == rhsAt { + case let .custom(_, _, lhsAt, _, _): + if case let .custom(_, _, rhsAt, _, _) = rhs, lhsAt == rhsAt { return true } else { return false diff --git a/submodules/ChatListUI/Sources/ChatListControllerNode.swift b/submodules/ChatListUI/Sources/ChatListControllerNode.swift index a9bdacca0a..91c9505a72 100644 --- a/submodules/ChatListUI/Sources/ChatListControllerNode.swift +++ b/submodules/ChatListUI/Sources/ChatListControllerNode.swift @@ -1466,19 +1466,23 @@ final class ChatListControllerNode: ASDisplayNode, ASGestureRecognizerDelegate { ) } if let mediaPlayback = self.controller?.globalControlPanelsContextState?.mediaPlayback { - panels.append(HeaderPanelContainerComponent.Panel( - key: "media", - orderIndex: 1, - component: AnyComponent(MediaPlaybackHeaderPanelComponent( - context: self.context, - theme: self.presentationData.theme, - strings: self.presentationData.strings, - data: mediaPlayback, - controller: { [weak self] in - return self?.controller - } - ))) - ) + if let playlistLocation = mediaPlayback.playlistLocation as? PeerMessagesPlaylistLocation, case let .custom(_, _, _, _, hidePanel) = playlistLocation, hidePanel { + + } else { + panels.append(HeaderPanelContainerComponent.Panel( + key: "media", + orderIndex: 1, + component: AnyComponent(MediaPlaybackHeaderPanelComponent( + context: self.context, + theme: self.presentationData.theme, + strings: self.presentationData.strings, + data: mediaPlayback, + controller: { [weak self] in + return self?.controller + } + ))) + ) + } } if let liveLocation = self.controller?.globalControlPanelsContextState?.liveLocation { panels.append(HeaderPanelContainerComponent.Panel( diff --git a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift index 4a8d409864..c9b263ff10 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift @@ -3534,7 +3534,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode { return (message.map { $0._asMessage() }, a, b) }, canReorder: false, at: message.id, loadMore: { loadMore() - }) + }, hidePanel: false) } return context.sharedContext.openChatMessage(OpenChatMessageParams(context: context, chatLocation: .peer(id: message.id.peerId), chatFilterTag: nil, chatLocationContextHolder: nil, message: message, standalone: false, reverseMessageGalleryOrder: true, mode: mode, navigationController: navigationController, dismissInput: { diff --git a/submodules/TelegramUI/Components/AttachmentFileController/Sources/AttachmentFileController.swift b/submodules/TelegramUI/Components/AttachmentFileController/Sources/AttachmentFileController.swift index 043f68f6f6..89eab33c33 100644 --- a/submodules/TelegramUI/Components/AttachmentFileController/Sources/AttachmentFileController.swift +++ b/submodules/TelegramUI/Components/AttachmentFileController/Sources/AttachmentFileController.swift @@ -638,7 +638,7 @@ public func makeAttachmentFileControllerImpl( toggleMediaPlayback: { message in didPreviewAudio = true - let playlistLocation: PeerMessagesPlaylistLocation = .custom(messages: .single(([message], 0, false)), canReorder: false, at: message.id, loadMore: nil) + let playlistLocation: PeerMessagesPlaylistLocation = .custom(messages: .single(([message], 0, false)), canReorder: false, at: message.id, loadMore: nil, hidePanel: true) context.sharedContext.mediaManager.setPlaylist((context, PeerMessagesMediaPlaylist(context: context, location: playlistLocation, chatLocationContextHolder: nil)), type: .music, control: .playback(.togglePlayPause)) }, isSelectionActive: { @@ -696,7 +696,7 @@ public func makeAttachmentFileControllerImpl( items.append(.action(ContextMenuActionItem(text: "Play", icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Play"), color: theme.contextMenu.primaryColor) }, action: { c, _ in c?.dismiss(completion: {}) - let playlistLocation: PeerMessagesPlaylistLocation = .custom(messages: .single(([message._asMessage()], 0, false)), canReorder: false, at: message.id, loadMore: nil) + let playlistLocation: PeerMessagesPlaylistLocation = .custom(messages: .single(([message._asMessage()], 0, false)), canReorder: false, at: message.id, loadMore: nil, hidePanel: true) context.sharedContext.mediaManager.setPlaylist((context, PeerMessagesMediaPlaylist(context: context, location: playlistLocation, chatLocationContextHolder: nil)), type: .music, control: .playback(.togglePlayPause)) }))) } diff --git a/submodules/TelegramUI/Components/AttachmentFileController/Sources/AttachmentFileSearchItem.swift b/submodules/TelegramUI/Components/AttachmentFileController/Sources/AttachmentFileSearchItem.swift index c016ebcff6..cd46f98d27 100644 --- a/submodules/TelegramUI/Components/AttachmentFileController/Sources/AttachmentFileSearchItem.swift +++ b/submodules/TelegramUI/Components/AttachmentFileController/Sources/AttachmentFileSearchItem.swift @@ -484,7 +484,7 @@ public final class AttachmentFileSearchContainerNode: SearchDisplayControllerCon self?.listNode.clearHighlightAnimated(true) }, toggleMediaPlayback: { message in - let playlistLocation: PeerMessagesPlaylistLocation = .custom(messages: .single(([message], 0, false)), canReorder: false, at: message.id, loadMore: nil) + let playlistLocation: PeerMessagesPlaylistLocation = .custom(messages: .single(([message], 0, false)), canReorder: false, at: message.id, loadMore: nil, hidePanel: true) context.sharedContext.mediaManager.setPlaylist((context, PeerMessagesMediaPlaylist(context: context, location: playlistLocation, chatLocationContextHolder: nil)), type: .music, control: .playback(.togglePlayPause)) }, expandSection: { [weak self] section in diff --git a/submodules/TelegramUI/Components/MediaManager/PeerMessagesMediaPlaylist/Sources/PeerMessagesMediaPlaylist.swift b/submodules/TelegramUI/Components/MediaManager/PeerMessagesMediaPlaylist/Sources/PeerMessagesMediaPlaylist.swift index 6565bf17c5..3f974eb788 100644 --- a/submodules/TelegramUI/Components/MediaManager/PeerMessagesMediaPlaylist/Sources/PeerMessagesMediaPlaylist.swift +++ b/submodules/TelegramUI/Components/MediaManager/PeerMessagesMediaPlaylist/Sources/PeerMessagesMediaPlaylist.swift @@ -434,7 +434,7 @@ public final class PeerMessagesMediaPlaylist: SharedMediaPlaylist { self.messagesLocation = location switch self.messagesLocation.effectiveLocation(context: context) { - case let .messages(_, _, messageId), let .singleMessage(messageId), let .custom(_, _, messageId, _): + case let .messages(_, _, messageId), let .singleMessage(messageId), let .custom(_, _, messageId, _, _): self.loadItem(anchor: .messageId(messageId), navigation: .later, reversed: self.order == .reversed) case let .recentActions(message): self.loadingItem = false @@ -608,7 +608,7 @@ public final class PeerMessagesMediaPlaylist: SharedMediaPlaylist { strongSelf.updateState() } })) - case let .custom(messages, _, at, _): + case let .custom(messages, _, at, _, _): self.navigationDisposable.set((messages |> take(1) |> deliverOnMainQueue).startStrict(next: { [weak self] messages in @@ -787,7 +787,7 @@ public final class PeerMessagesMediaPlaylist: SharedMediaPlaylist { self.updateState() case .savedMusic: fatalError() - case let .custom(messages, _, _, loadMore): + case let .custom(messages, _, _, loadMore, _): let inputIndex: Signal let looping = self.looping switch self.order { diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index 7c84d1f1fb..60930de77d 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -1377,19 +1377,23 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate { } } if self.chatPresentationInterfaceState.search == nil, let mediaPlayback = self.controller?.globalControlPanelsContextState?.mediaPlayback { - headerPanels.append(HeaderPanelContainerComponent.Panel( - key: "media", - orderIndex: 1, - component: AnyComponent(MediaPlaybackHeaderPanelComponent( - context: self.context, - theme: self.chatPresentationInterfaceState.theme, - strings: self.chatPresentationInterfaceState.strings, - data: mediaPlayback, - controller: { [weak self] in - return self?.controller - } - ))) - ) + if let playlistLocation = mediaPlayback.playlistLocation as? PeerMessagesPlaylistLocation, case let .custom(_, _, _, _, hidePanel) = playlistLocation, hidePanel { + + } else { + headerPanels.append(HeaderPanelContainerComponent.Panel( + key: "media", + orderIndex: 1, + component: AnyComponent(MediaPlaybackHeaderPanelComponent( + context: self.context, + theme: self.chatPresentationInterfaceState.theme, + strings: self.chatPresentationInterfaceState.strings, + data: mediaPlayback, + controller: { [weak self] in + return self?.controller + } + ))) + ) + } } if self.chatPresentationInterfaceState.search == nil, let liveLocation = self.controller?.globalControlPanelsContextState?.liveLocation { headerPanels.append(HeaderPanelContainerComponent.Panel( diff --git a/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift b/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift index 144299e6eb..c2bb7fa9be 100644 --- a/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift +++ b/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift @@ -81,7 +81,7 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, ASGestu self.playlistLocation = playlistLocation self.getParentController = getParentController - if let playlistLocation = playlistLocation as? PeerMessagesPlaylistLocation, case let .custom(messages, canReorder, at, loadMore) = playlistLocation.effectiveLocation(context: context) { + if let playlistLocation = playlistLocation as? PeerMessagesPlaylistLocation, case let .custom(messages, canReorder, at, loadMore, _) = playlistLocation.effectiveLocation(context: context) { self.source = .custom(messages: messages, messageId: at, quote: nil, isSavedMusic: true, canReorder: canReorder, loadMore: loadMore) self.isGlobalSearch = false } else { @@ -372,8 +372,8 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, ASGestu if let strongSelf = self, strongSelf.isNodeLoaded, let message = strongSelf.historyNode.messageInCurrentHistoryView(id) { var playlistLocation: PeerMessagesPlaylistLocation? if let location = strongSelf.playlistLocation as? PeerMessagesPlaylistLocation { - if case let .custom(messages, canReorder, _, loadMore) = location { - playlistLocation = .custom(messages: messages, canReorder: canReorder, at: id, loadMore: loadMore) + if case let .custom(messages, canReorder, _, loadMore, hidePanel) = location { + playlistLocation = .custom(messages: messages, canReorder: canReorder, at: id, loadMore: loadMore, hidePanel: hidePanel) } else if case let .savedMusic(context, _, canReorder) = location { playlistLocation = .savedMusic(context: context, at: id.id, canReorder: canReorder) }