mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Fix history loading
This commit is contained in:
parent
7e5173cf32
commit
b82a085116
@ -159,7 +159,6 @@ private final class ChannelMemberSingleCategoryListContext: ChannelMemberCategor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private func loadSignal(offset: Int32, count: Int32, hash: Int32) -> Signal<[RenderedChannelParticipant]?, NoError> {
|
private func loadSignal(offset: Int32, count: Int32, hash: Int32) -> Signal<[RenderedChannelParticipant]?, NoError> {
|
||||||
let requestCategory: ChannelMembersCategory
|
let requestCategory: ChannelMembersCategory
|
||||||
var adminQuery: String? = nil
|
var adminQuery: String? = nil
|
||||||
|
@ -268,23 +268,27 @@ private func ChannelMembersControllerEntries(context: AccountContext, presentati
|
|||||||
|
|
||||||
|
|
||||||
var index: Int32 = 0
|
var index: Int32 = 0
|
||||||
for participant in participants.sorted(by: { lhs, rhs in
|
let sortedParticipants = participants
|
||||||
let lhsInvitedAt: Int32
|
/*
|
||||||
switch lhs.participant {
|
participants.sorted(by: { lhs, rhs in
|
||||||
case .creator:
|
let lhsInvitedAt: Int32
|
||||||
lhsInvitedAt = Int32.min
|
switch lhs.participant {
|
||||||
case let .member(_, invitedAt, _, _):
|
case .creator:
|
||||||
lhsInvitedAt = invitedAt
|
lhsInvitedAt = Int32.min
|
||||||
}
|
case let .member(_, invitedAt, _, _):
|
||||||
let rhsInvitedAt: Int32
|
lhsInvitedAt = invitedAt
|
||||||
switch rhs.participant {
|
}
|
||||||
case .creator:
|
let rhsInvitedAt: Int32
|
||||||
rhsInvitedAt = Int32.min
|
switch rhs.participant {
|
||||||
case let .member(_, invitedAt, _, _):
|
case .creator:
|
||||||
rhsInvitedAt = invitedAt
|
rhsInvitedAt = Int32.min
|
||||||
}
|
case let .member(_, invitedAt, _, _):
|
||||||
return lhsInvitedAt < rhsInvitedAt
|
rhsInvitedAt = invitedAt
|
||||||
}) {
|
}
|
||||||
|
return lhsInvitedAt < rhsInvitedAt
|
||||||
|
})
|
||||||
|
*/
|
||||||
|
for participant in sortedParticipants {
|
||||||
var editable = true
|
var editable = true
|
||||||
var canEditMembers = false
|
var canEditMembers = false
|
||||||
if let peer = view.peers[view.peerId] as? TelegramChannel {
|
if let peer = view.peers[view.peerId] as? TelegramChannel {
|
||||||
|
@ -5123,7 +5123,7 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
|
|||||||
case .upperBound:
|
case .upperBound:
|
||||||
searchLocation = .index(MessageIndex.upperBound(peerId: peerId))
|
searchLocation = .index(MessageIndex.upperBound(peerId: peerId))
|
||||||
}
|
}
|
||||||
let historyView = chatHistoryViewForLocation(ChatHistoryLocationInput(content: .InitialSearch(location: searchLocation, count: 50), id: 0), account: self.context.account, chatLocation: self.chatLocation, fixedCombinedReadStates: nil, tagMask: nil, additionalData: [])
|
let historyView = preloadedShatHistoryViewForLocation(ChatHistoryLocationInput(content: .InitialSearch(location: searchLocation, count: 50), id: 0), account: self.context.account, chatLocation: self.chatLocation, fixedCombinedReadStates: nil, tagMask: nil, additionalData: [])
|
||||||
let signal = historyView
|
let signal = historyView
|
||||||
|> mapToSignal { historyView -> Signal<(MessageIndex?, Bool), NoError> in
|
|> mapToSignal { historyView -> Signal<(MessageIndex?, Bool), NoError> in
|
||||||
switch historyView {
|
switch historyView {
|
||||||
@ -5212,7 +5212,7 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
|
|||||||
self.historyNavigationStack.add(fromIndex)
|
self.historyNavigationStack.add(fromIndex)
|
||||||
}
|
}
|
||||||
self.loadingMessage.set(true)
|
self.loadingMessage.set(true)
|
||||||
let historyView = chatHistoryViewForLocation(ChatHistoryLocationInput(content: .InitialSearch(location: searchLocation, count: 50), id: 0), account: self.context.account, chatLocation: self.chatLocation, fixedCombinedReadStates: nil, tagMask: nil, additionalData: [])
|
let historyView = preloadedShatHistoryViewForLocation(ChatHistoryLocationInput(content: .InitialSearch(location: searchLocation, count: 50), id: 0), account: self.context.account, chatLocation: self.chatLocation, fixedCombinedReadStates: nil, tagMask: nil, additionalData: [])
|
||||||
let signal = historyView
|
let signal = historyView
|
||||||
|> mapToSignal { historyView -> Signal<MessageIndex?, NoError> in
|
|> mapToSignal { historyView -> Signal<MessageIndex?, NoError> in
|
||||||
switch historyView {
|
switch historyView {
|
||||||
|
@ -493,7 +493,11 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
|
|||||||
|
|
||||||
strongSelf.chatHistoryLocation.set(ChatHistoryLocationInput(content: .Navigation(index: .message(lastEntry.index), anchorIndex: .message(lastEntry.index), count: historyMessageCount), id: 0))
|
strongSelf.chatHistoryLocation.set(ChatHistoryLocationInput(content: .Navigation(index: .message(lastEntry.index), anchorIndex: .message(lastEntry.index), count: historyMessageCount), id: 0))
|
||||||
} else {
|
} else {
|
||||||
strongSelf.chatHistoryLocation.set(ChatHistoryLocationInput(content: .Initial(count: 60), id: 0))
|
if let messageId = messageId {
|
||||||
|
strongSelf.chatHistoryLocation.set(ChatHistoryLocationInput(content: .InitialSearch(location: .id(messageId), count: 60), id: 0))
|
||||||
|
} else {
|
||||||
|
strongSelf.chatHistoryLocation.set(ChatHistoryLocationInput(content: .Initial(count: 60), id: 0))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,25 @@ import TelegramCore
|
|||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Display
|
import Display
|
||||||
|
|
||||||
|
func preloadedShatHistoryViewForLocation(_ location: ChatHistoryLocationInput, account: Account, chatLocation: ChatLocation, fixedCombinedReadStates: MessageHistoryViewReadState?, tagMask: MessageTags?, additionalData: [AdditionalMessageHistoryViewData], orderStatistics: MessageHistoryViewOrderStatistics = []) -> Signal<ChatHistoryViewUpdate, NoError> {
|
||||||
|
return chatHistoryViewForLocation(location, account: account, chatLocation: chatLocation, fixedCombinedReadStates: fixedCombinedReadStates, tagMask: tagMask, additionalData: additionalData, orderStatistics: orderStatistics)
|
||||||
|
|> introduceError(Bool.self)
|
||||||
|
|> mapToSignal { update -> Signal<ChatHistoryViewUpdate, Bool> in
|
||||||
|
switch update {
|
||||||
|
case let .Loading(value):
|
||||||
|
if case .Generic(.FillHole) = value.type {
|
||||||
|
return .fail(true)
|
||||||
|
}
|
||||||
|
case let .HistoryView(value):
|
||||||
|
if case .Generic(.FillHole) = value.type {
|
||||||
|
return .fail(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return .single(update)
|
||||||
|
}
|
||||||
|
|> restartIfError
|
||||||
|
}
|
||||||
|
|
||||||
func chatHistoryViewForLocation(_ location: ChatHistoryLocationInput, account: Account, chatLocation: ChatLocation, fixedCombinedReadStates: MessageHistoryViewReadState?, tagMask: MessageTags?, additionalData: [AdditionalMessageHistoryViewData], orderStatistics: MessageHistoryViewOrderStatistics = []) -> Signal<ChatHistoryViewUpdate, NoError> {
|
func chatHistoryViewForLocation(_ location: ChatHistoryLocationInput, account: Account, chatLocation: ChatLocation, fixedCombinedReadStates: MessageHistoryViewReadState?, tagMask: MessageTags?, additionalData: [AdditionalMessageHistoryViewData], orderStatistics: MessageHistoryViewOrderStatistics = []) -> Signal<ChatHistoryViewUpdate, NoError> {
|
||||||
switch location.content {
|
switch location.content {
|
||||||
case let .Initial(count):
|
case let .Initial(count):
|
||||||
@ -116,8 +135,13 @@ func chatHistoryViewForLocation(_ location: ChatHistoryLocationInput, account: A
|
|||||||
return .Loading(initialData: combinedInitialData, type: .Generic(type: updateType))
|
return .Loading(initialData: combinedInitialData, type: .Generic(type: updateType))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var reportUpdateType: ChatHistoryViewUpdateType = .Initial(fadeIn: fadeIn)
|
||||||
|
if case .FillHole = updateType {
|
||||||
|
reportUpdateType = .Generic(type: updateType)
|
||||||
|
}
|
||||||
|
|
||||||
preloaded = true
|
preloaded = true
|
||||||
return .HistoryView(view: view, type: .Initial(fadeIn: fadeIn), scrollPosition: .index(index: anchorIndex, position: .center(.bottom), directionHint: .Down, animated: false), originalScrollPosition: nil, initialData: ChatHistoryCombinedInitialData(initialData: initialData, buttonKeyboardMessage: view.topTaggedMessages.first, cachedData: cachedData, cachedDataMessages: cachedDataMessages, readStateData: readStateData), id: location.id)
|
return .HistoryView(view: view, type: reportUpdateType, scrollPosition: .index(index: anchorIndex, position: .center(.bottom), directionHint: .Down, animated: false), originalScrollPosition: nil, initialData: ChatHistoryCombinedInitialData(initialData: initialData, buttonKeyboardMessage: view.topTaggedMessages.first, cachedData: cachedData, cachedDataMessages: cachedDataMessages, readStateData: readStateData), id: location.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case let .Navigation(index, anchorIndex, count):
|
case let .Navigation(index, anchorIndex, count):
|
||||||
|
@ -503,7 +503,7 @@ public class TelegramController: ViewController {
|
|||||||
}
|
}
|
||||||
if let id = state.id as? PeerMessagesMediaPlaylistItemId {
|
if let id = state.id as? PeerMessagesMediaPlaylistItemId {
|
||||||
if type == .music {
|
if type == .music {
|
||||||
let historyView = chatHistoryViewForLocation(ChatHistoryLocationInput(content: .InitialSearch(location: .id(id.messageId), count: 60), id: 0), account: account, chatLocation: .peer(id.messageId.peerId), fixedCombinedReadStates: nil, tagMask: MessageTags.music, additionalData: [])
|
let historyView = preloadedShatHistoryViewForLocation(ChatHistoryLocationInput(content: .InitialSearch(location: .id(id.messageId), count: 60), id: 0), account: account, chatLocation: .peer(id.messageId.peerId), fixedCombinedReadStates: nil, tagMask: MessageTags.music, additionalData: [])
|
||||||
let signal = historyView
|
let signal = historyView
|
||||||
|> mapToSignal { historyView -> Signal<(MessageIndex?, Bool), NoError> in
|
|> mapToSignal { historyView -> Signal<(MessageIndex?, Bool), NoError> in
|
||||||
switch historyView {
|
switch historyView {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user