mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Various improvements
This commit is contained in:
parent
7c0d5519bf
commit
1d7bf5aa12
@ -913,6 +913,7 @@ public protocol ChatController: ViewController {
|
||||
func activateSearch(domain: ChatSearchDomain, query: String)
|
||||
func beginClearHistory(type: InteractiveHistoryClearingType)
|
||||
|
||||
func performScrollToTop() -> Bool
|
||||
func transferScrollingVelocity(_ velocity: CGFloat)
|
||||
func updateIsScrollingLockedAtTop(isScrollingLockedAtTop: Bool)
|
||||
}
|
||||
|
@ -1860,23 +1860,15 @@ public final class AccountViewTracker {
|
||||
return transaction.getMessageHistoryThreadInfo(peerId: peerId, threadId: threadId)?.data.get(MessageHistoryThreadData.self)
|
||||
}
|
||||
|> mapToSignal { threadInfo -> Signal<(MessageHistoryView, ViewUpdateType, InitialMessageHistoryData?), NoError> in
|
||||
if let threadInfo = threadInfo {
|
||||
let anchor: HistoryViewInputAnchor
|
||||
if threadInfo.maxIncomingReadId <= 1 {
|
||||
anchor = .message(MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: 1))
|
||||
} else if threadInfo.incomingUnreadCount > 0 && tagMask == nil {
|
||||
let customUnreadMessageId = MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: threadInfo.maxIncomingReadId)
|
||||
anchor = .message(customUnreadMessageId)
|
||||
} else {
|
||||
anchor = .upperBound
|
||||
}
|
||||
|
||||
if peerId == account.peerId {
|
||||
return account.postbox.aroundMessageHistoryViewForLocation(
|
||||
chatLocation,
|
||||
anchor: anchor,
|
||||
anchor: .upperBound,
|
||||
ignoreMessagesInTimestampRange: ignoreMessagesInTimestampRange,
|
||||
count: count,
|
||||
fixedCombinedReadStates: nil,
|
||||
fixedCombinedReadStates: .peer([peerId: CombinedPeerReadState(states: [
|
||||
(Namespaces.Message.Cloud, PeerReadState.idBased(maxIncomingReadId: Int32.max - 1, maxOutgoingReadId: Int32.max - 1, maxKnownId: Int32.max - 1, count: 0, markedUnread: false))
|
||||
])]),
|
||||
topTaggedMessageIdNamespaces: [],
|
||||
tagMask: tagMask,
|
||||
appendMessagesFromTheSameGroup: false,
|
||||
@ -1884,6 +1876,32 @@ public final class AccountViewTracker {
|
||||
orderStatistics: orderStatistics,
|
||||
additionalData: wrappedHistoryViewAdditionalData(chatLocation: chatLocation, additionalData: additionalData)
|
||||
)
|
||||
} else {
|
||||
if let threadInfo = threadInfo {
|
||||
let anchor: HistoryViewInputAnchor
|
||||
if threadInfo.maxIncomingReadId <= 1 {
|
||||
anchor = .message(MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: 1))
|
||||
} else if threadInfo.incomingUnreadCount > 0 && tagMask == nil {
|
||||
let customUnreadMessageId = MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: threadInfo.maxIncomingReadId)
|
||||
anchor = .message(customUnreadMessageId)
|
||||
} else {
|
||||
anchor = .upperBound
|
||||
}
|
||||
|
||||
return account.postbox.aroundMessageHistoryViewForLocation(
|
||||
chatLocation,
|
||||
anchor: anchor,
|
||||
ignoreMessagesInTimestampRange: ignoreMessagesInTimestampRange,
|
||||
count: count,
|
||||
fixedCombinedReadStates: nil,
|
||||
topTaggedMessageIdNamespaces: [],
|
||||
tagMask: tagMask,
|
||||
appendMessagesFromTheSameGroup: false,
|
||||
namespaces: .not(Namespaces.Message.allScheduled),
|
||||
orderStatistics: orderStatistics,
|
||||
additionalData: wrappedHistoryViewAdditionalData(chatLocation: chatLocation, additionalData: additionalData)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return account.postbox.aroundMessageOfInterestHistoryViewForChatLocation(chatLocation, ignoreMessagesInTimestampRange: ignoreMessagesInTimestampRange, count: count, topTaggedMessageIdNamespaces: [Namespaces.Message.Cloud], tagMask: tagMask, appendMessagesFromTheSameGroup: appendMessagesFromTheSameGroup, namespaces: .not(Namespaces.Message.allScheduled), orderStatistics: orderStatistics, customUnreadMessageId: nil, additionalData: wrappedHistoryViewAdditionalData(chatLocation: chatLocation, additionalData: additionalData))
|
||||
|
@ -183,7 +183,17 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode {
|
||||
}
|
||||
|
||||
let messageTheme = incoming ? presentationData.theme.theme.chat.message.incoming : presentationData.theme.theme.chat.message.outgoing
|
||||
let author = message.author
|
||||
|
||||
var author = message.effectiveAuthor
|
||||
|
||||
if let forwardInfo = message.forwardInfo {
|
||||
if let peer = forwardInfo.author {
|
||||
author = peer
|
||||
} else if let authorSignature = forwardInfo.authorSignature {
|
||||
author = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(Int64(authorSignature.persistentHashValue % 32))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil)
|
||||
}
|
||||
}
|
||||
|
||||
let nameColors = author?.nameColor.flatMap { context.peerNameColors.get($0, dark: presentationData.theme.theme.overallDarkAppearance) }
|
||||
|
||||
let mainColor: UIColor
|
||||
|
@ -203,7 +203,15 @@ public class ChatMessageReplyInfoNode: ASDisplayNode {
|
||||
var dashSecondaryColor: UIColor?
|
||||
var dashTertiaryColor: UIColor?
|
||||
|
||||
let author = arguments.message?.effectiveAuthor
|
||||
var author = arguments.message?.effectiveAuthor
|
||||
|
||||
if let forwardInfo = arguments.message?.forwardInfo {
|
||||
if let peer = forwardInfo.author {
|
||||
author = peer
|
||||
} else if let authorSignature = forwardInfo.authorSignature {
|
||||
author = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(Int64(authorSignature.persistentHashValue % 32))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil)
|
||||
}
|
||||
}
|
||||
|
||||
let colors = author?.nameColor.flatMap { arguments.context.peerNameColors.get($0, dark: arguments.presentationData.theme.theme.overallDarkAppearance) }
|
||||
authorNameColor = colors?.main
|
||||
|
@ -87,7 +87,7 @@ public final class PeerInfoChatPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScro
|
||||
}
|
||||
|
||||
public func scrollToTop() -> Bool {
|
||||
return false
|
||||
return self.chatController.performScrollToTop()
|
||||
}
|
||||
|
||||
public func hitTestResultForScrolling() -> UIView? {
|
||||
|
@ -393,7 +393,7 @@ extension ChatControllerImpl {
|
||||
quote = params.quote.flatMap { quote in ChatControllerSubject.MessageHighlight.Quote(string: quote.string, offset: quote.offset) }
|
||||
}
|
||||
|
||||
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(peer), subject: messageLocation.messageId.flatMap { .message(id: .id($0), highlight: ChatControllerSubject.MessageHighlight(quote: quote), timecode: nil) }))
|
||||
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(peer), subject: messageLocation.messageId.flatMap { .message(id: .id($0), highlight: ChatControllerSubject.MessageHighlight(quote: quote), timecode: nil) }, keepStack: .always))
|
||||
}
|
||||
})
|
||||
completion?()
|
||||
|
@ -18986,6 +18986,17 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
public func transferScrollingVelocity(_ velocity: CGFloat) {
|
||||
self.chatDisplayNode.historyNode.transferVelocity(velocity)
|
||||
}
|
||||
|
||||
public func performScrollToTop() -> Bool {
|
||||
let offset = self.chatDisplayNode.historyNode.visibleContentOffset()
|
||||
switch offset {
|
||||
case let .known(value) where value <= CGFloat.ulpOfOne:
|
||||
return false
|
||||
default:
|
||||
self.chatDisplayNode.historyNode.scrollToEndOfHistory()
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final class ChatContextControllerContentSourceImpl: ContextControllerContentSource {
|
||||
|
Loading…
x
Reference in New Issue
Block a user