mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-30 03:44:18 +00:00
More music album playback order improvements
This commit is contained in:
parent
bcce69eb68
commit
838c352971
@ -208,7 +208,7 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, UIGestu
|
||||
self.isGlobalSearch = false
|
||||
}
|
||||
|
||||
self.historyNode = ChatHistoryListNode(context: context, updatedPresentationData: (context.sharedContext.currentPresentationData.with({ $0 }), context.sharedContext.presentationData), chatLocation: chatLocation, chatLocationContextHolder: chatLocationContextHolder, tagMask: tagMask, source: source, subject: .message(id: .id(initialMessageId), highlight: true, timecode: nil), controllerInteraction: self.controllerInteraction, selectedMessages: .single(nil), mode: .list(search: false, reversed: self.currentIsReversed, reverseGroups: true, displayHeaders: .none, hintLinks: false, isGlobalSearch: self.isGlobalSearch))
|
||||
self.historyNode = ChatHistoryListNode(context: context, updatedPresentationData: (context.sharedContext.currentPresentationData.with({ $0 }), context.sharedContext.presentationData), chatLocation: chatLocation, chatLocationContextHolder: chatLocationContextHolder, tagMask: tagMask, source: source, subject: .message(id: .id(initialMessageId), highlight: true, timecode: nil), controllerInteraction: self.controllerInteraction, selectedMessages: .single(nil), mode: .list(search: false, reversed: self.currentIsReversed, reverseGroups: !self.currentIsReversed, displayHeaders: .none, hintLinks: false, isGlobalSearch: self.isGlobalSearch))
|
||||
self.historyNode.clipsToBounds = true
|
||||
|
||||
super.init()
|
||||
@ -550,7 +550,7 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, UIGestu
|
||||
}
|
||||
|
||||
let chatLocationContextHolder = Atomic<ChatLocationContextHolder?>(value: nil)
|
||||
let historyNode = ChatHistoryListNode(context: self.context, updatedPresentationData: (self.context.sharedContext.currentPresentationData.with({ $0 }), self.context.sharedContext.presentationData), chatLocation: self.chatLocation, chatLocationContextHolder: chatLocationContextHolder, tagMask: tagMask, subject: .message(id: .id(messageId), highlight: true, timecode: nil), controllerInteraction: self.controllerInteraction, selectedMessages: .single(nil), mode: .list(search: false, reversed: self.currentIsReversed, reverseGroups: true, displayHeaders: .none, hintLinks: false, isGlobalSearch: self.isGlobalSearch))
|
||||
let historyNode = ChatHistoryListNode(context: self.context, updatedPresentationData: (self.context.sharedContext.currentPresentationData.with({ $0 }), self.context.sharedContext.presentationData), chatLocation: self.chatLocation, chatLocationContextHolder: chatLocationContextHolder, tagMask: tagMask, subject: .message(id: .id(messageId), highlight: true, timecode: nil), controllerInteraction: self.controllerInteraction, selectedMessages: .single(nil), mode: .list(search: false, reversed: self.currentIsReversed, reverseGroups: !self.currentIsReversed, displayHeaders: .none, hintLinks: false, isGlobalSearch: self.isGlobalSearch))
|
||||
historyNode.clipsToBounds = true
|
||||
historyNode.preloadPages = true
|
||||
historyNode.stackFromBottom = true
|
||||
|
||||
@ -229,7 +229,7 @@ private func navigatedMessageFromMessages(_ messages: [Message], anchorIndex: Me
|
||||
}
|
||||
}
|
||||
|
||||
private func navigatedMessageFromView(_ view: MessageHistoryView, anchorIndex: MessageIndex, position: NavigatedMessageFromViewPosition) -> (message: Message, around: [Message], exact: Bool)? {
|
||||
private func navigatedMessageFromView(_ view: MessageHistoryView, anchorIndex: MessageIndex, position: NavigatedMessageFromViewPosition, reversed: Bool) -> (message: Message, around: [Message], exact: Bool)? {
|
||||
var index = 0
|
||||
|
||||
for entry in view.entries {
|
||||
@ -240,7 +240,7 @@ private func navigatedMessageFromView(_ view: MessageHistoryView, anchorIndex: M
|
||||
case .exact:
|
||||
return (entry.message, aroundMessagesFromView(view: view, centralIndex: entry.index), true)
|
||||
case .later:
|
||||
if let currentGroupKey {
|
||||
if !reversed, let currentGroupKey {
|
||||
if index - 1 > 0, view.entries[index - 1].message.groupingKey == currentGroupKey {
|
||||
let message = view.entries[index - 1].message
|
||||
return (message, aroundMessagesFromView(view: view, centralIndex: view.entries[index - 1].index), true)
|
||||
@ -259,7 +259,7 @@ private func navigatedMessageFromView(_ view: MessageHistoryView, anchorIndex: M
|
||||
return nil
|
||||
}
|
||||
case .earlier:
|
||||
if let currentGroupKey {
|
||||
if !reversed, let currentGroupKey {
|
||||
if index + 1 < view.entries.count, view.entries[index + 1].message.groupingKey == currentGroupKey {
|
||||
let message = view.entries[index + 1].message
|
||||
return (message, aroundMessagesFromView(view: view, centralIndex: view.entries[index + 1].index), true)
|
||||
@ -286,7 +286,7 @@ private func navigatedMessageFromView(_ view: MessageHistoryView, anchorIndex: M
|
||||
}
|
||||
} else if index != 0 {
|
||||
let message = view.entries[index - 1].message
|
||||
if let nextGroupingKey = message.groupingKey {
|
||||
if !reversed, let nextGroupingKey = message.groupingKey {
|
||||
for i in (0 ..< index).reversed() {
|
||||
if view.entries[i].message.groupingKey != nextGroupingKey {
|
||||
let message = view.entries[i + 1].message
|
||||
@ -410,7 +410,7 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
||||
|
||||
switch self.messagesLocation {
|
||||
case let .messages(_, _, messageId), let .singleMessage(messageId), let .custom(_, messageId, _):
|
||||
self.loadItem(anchor: .messageId(messageId), navigation: .later)
|
||||
self.loadItem(anchor: .messageId(messageId), navigation: .later, reversed: self.order == .reversed)
|
||||
case let .recentActions(message):
|
||||
self.loadingItem = false
|
||||
self.currentItem = (message, [])
|
||||
@ -463,7 +463,7 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
||||
self.currentItem = nil
|
||||
self.updateState()
|
||||
} else {
|
||||
self.loadItem(anchor: .index(currentItem.current.index), navigation: navigation)
|
||||
self.loadItem(anchor: .index(currentItem.current.index), navigation: navigation, reversed: self.order == .reversed)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -524,7 +524,7 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
||||
}
|
||||
}
|
||||
|
||||
private func loadItem(anchor: PeerMessagesMediaPlaylistLoadAnchor, navigation: PeerMessagesMediaPlaylistNavigation) {
|
||||
private func loadItem(anchor: PeerMessagesMediaPlaylistLoadAnchor, navigation: PeerMessagesMediaPlaylistNavigation, reversed: Bool) {
|
||||
self.loadingItem = true
|
||||
self.updateState()
|
||||
|
||||
@ -548,7 +548,7 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
||||
|
||||
return self.context.account.postbox.aroundMessageHistoryViewForLocation(self.context.chatLocationInput(for: chatLocation, contextHolder: self.chatLocationContextHolder ?? Atomic<ChatLocationContextHolder?>(value: nil)), anchor: .index(message.index), ignoreMessagesInTimestampRange: nil, count: 10, fixedCombinedReadStates: nil, topTaggedMessageIdNamespaces: [], tagMask: tagMask, appendMessagesFromTheSameGroup: false, namespaces: namespaces, orderStatistics: [])
|
||||
|> mapToSignal { view -> Signal<(Message, [Message])?, NoError> in
|
||||
if let (message, aroundMessages, _) = navigatedMessageFromView(view.0, anchorIndex: message.index, position: .exact) {
|
||||
if let (message, aroundMessages, _) = navigatedMessageFromView(view.0, anchorIndex: message.index, position: .exact, reversed: reversed) {
|
||||
return .single((message, aroundMessages))
|
||||
} else {
|
||||
return .single((message, []))
|
||||
@ -670,7 +670,7 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
||||
position = .exact
|
||||
}
|
||||
|
||||
if let (message, aroundMessages, exact) = navigatedMessageFromView(view.0, anchorIndex: inputIndex, position: position) {
|
||||
if let (message, aroundMessages, exact) = navigatedMessageFromView(view.0, anchorIndex: inputIndex, position: position, reversed: reversed) {
|
||||
switch navigation {
|
||||
case .random:
|
||||
return .single((message, []))
|
||||
@ -697,7 +697,7 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
||||
case .earlier:
|
||||
position = .later
|
||||
}
|
||||
if let (message, aroundMessages, _) = navigatedMessageFromView(view.0, anchorIndex: MessageIndex.absoluteLowerBound(), position: position) {
|
||||
if let (message, aroundMessages, _) = navigatedMessageFromView(view.0, anchorIndex: MessageIndex.absoluteLowerBound(), position: position, reversed: reversed) {
|
||||
return .single((message, aroundMessages))
|
||||
} else {
|
||||
return .single(nil)
|
||||
@ -832,7 +832,7 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
||||
}
|
||||
|
||||
if messages.count > previousMessagesCount {
|
||||
strongSelf.loadItem(anchor: anchor, navigation: navigation)
|
||||
strongSelf.loadItem(anchor: anchor, navigation: navigation, reversed: strongSelf.order == .reversed)
|
||||
|
||||
strongSelf.loadMoreDisposable.set(nil)
|
||||
strongSelf.loadingMore = false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user