Various improvements

This commit is contained in:
Ilya Laktyushin 2026-03-22 16:53:55 +01:00
parent 8098f24f4e
commit 6fd65e6d26
8 changed files with 50 additions and 41 deletions

View file

@ -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

View file

@ -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(

View file

@ -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: {

View file

@ -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))
})))
}

View file

@ -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

View file

@ -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<MessageIndex, NoError>
let looping = self.looping
switch self.order {

View file

@ -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(

View file

@ -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)
}