mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Various improvements
This commit is contained in:
parent
59dc46e0f5
commit
524c29cbe3
28 changed files with 1159 additions and 164 deletions
|
|
@ -765,6 +765,8 @@ public final class ChatHistoryListNodeImpl: ListViewImpl, ChatHistoryNode, ChatH
|
|||
|
||||
private let initTimestamp: Double
|
||||
|
||||
var pinToTopStableId: EngineMessage.StableId?
|
||||
|
||||
public init(
|
||||
context: AccountContext,
|
||||
updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>),
|
||||
|
|
@ -2140,6 +2142,29 @@ public final class ChatHistoryListNodeImpl: ListViewImpl, ChatHistoryNode, ChatH
|
|||
if case let .replyThread(message) = chatLocation, message.peerId == context.account.peerId, !rotated {
|
||||
includeEmbeddedSavedChatInfo = true
|
||||
}
|
||||
|
||||
var pinToTopStableId: EngineMessage.StableId?
|
||||
var scrollToPinToTopStableId = false
|
||||
if let strongSelf = self {
|
||||
for i in (0 ..< view.entries.count).reversed() {
|
||||
let message = view.entries[i].message
|
||||
if message.attributes.contains(where: { $0 is TypingDraftMessageAttribute }) {
|
||||
for j in (0 ..< i).reversed() {
|
||||
let otherMessage = view.entries[j].message
|
||||
if !otherMessage.effectivelyIncoming(context.account.peerId) {
|
||||
if strongSelf.pinToTopStableId != otherMessage.stableId {
|
||||
strongSelf.pinToTopStableId = otherMessage.stableId
|
||||
scrollToPinToTopStableId = true
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
pinToTopStableId = strongSelf.pinToTopStableId
|
||||
}
|
||||
|
||||
let previousChatHistoryEntriesForViewState = chatHistoryEntriesForViewState.with({ $0 })
|
||||
let (filteredEntries, updatedChatHistoryEntriesForViewState) = chatHistoryEntriesForView(
|
||||
|
|
@ -2168,7 +2193,8 @@ public final class ChatHistoryListNodeImpl: ListViewImpl, ChatHistoryNode, ChatH
|
|||
cachedData: data.cachedData,
|
||||
adMessage: allAdMessages.fixed,
|
||||
dynamicAdMessages: allAdMessages.opportunistic,
|
||||
isMusicPlaylist: isMusicPlaylist
|
||||
isMusicPlaylist: isMusicPlaylist,
|
||||
pinToTopStableId: pinToTopStableId
|
||||
)
|
||||
let lastHeaderId = filteredEntries.last.flatMap { listMessageDateHeaderId(timestamp: $0.index.timestamp) } ?? 0
|
||||
let processedView = ChatHistoryView(originalView: view, filteredEntries: filteredEntries, associatedData: associatedData, lastHeaderId: lastHeaderId, id: id, locationInput: update.2, ignoreMessagesInTimestampRange: update.3, ignoreMessageIds: update.4)
|
||||
|
|
@ -2392,6 +2418,17 @@ public final class ChatHistoryListNodeImpl: ListViewImpl, ChatHistoryNode, ChatH
|
|||
keyboardButtonsMessage = nil
|
||||
}
|
||||
|
||||
if scrollToPinToTopStableId, let strongSelf = self, let pinToTopStableId = strongSelf.pinToTopStableId {
|
||||
for entry in processedView.filteredEntries.reversed() {
|
||||
if case let .MessageEntry(message, _, _, _, _, _) = entry {
|
||||
if message.stableId == pinToTopStableId {
|
||||
updatedScrollPosition = .index(subject: MessageHistoryScrollToSubject(index: .message(message.index), quote: nil), position: .top(0.0), directionHint: .Up, animated: true, highlight: false, displayLink: false, setupReply: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let rawTransition = preparedChatHistoryViewTransition(from: previous, to: processedView, reason: reason, reverse: reverse, chatLocation: chatLocation, source: source, controllerInteraction: controllerInteraction, scrollPosition: updatedScrollPosition, scrollAnimationCurve: scrollAnimationCurve, initialData: initialData?.initialData, keyboardButtonsMessage: keyboardButtonsMessage, cachedData: initialData?.cachedData, cachedDataMessages: initialData?.cachedDataMessages, readStateData: initialData?.readStateData, flashIndicators: flashIndicators, updatedMessageSelection: previousSelectedMessages != selectedMessages, messageTransitionNode: messageTransitionNode(), allUpdated: !isSavedMusic || forceUpdateAll)
|
||||
var mappedTransition = mappedChatHistoryViewListTransition(context: context, chatLocation: chatLocation, associatedData: associatedData, controllerInteraction: controllerInteraction, mode: mode, lastHeaderId: lastHeaderId, isSavedMusic: isSavedMusic, canReorder: processedView.filteredEntries.count > 1 && canReorder, animateFromPreviousFilter: resetScrolling, transition: rawTransition, systemStyle: systemStyle)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue