Fix history loading

This commit is contained in:
Peter 2019-04-02 16:33:18 +04:00
parent 7e5173cf32
commit b82a085116
6 changed files with 54 additions and 23 deletions

View File

@ -159,7 +159,6 @@ private final class ChannelMemberSingleCategoryListContext: ChannelMemberCategor
}
}
private func loadSignal(offset: Int32, count: Int32, hash: Int32) -> Signal<[RenderedChannelParticipant]?, NoError> {
let requestCategory: ChannelMembersCategory
var adminQuery: String? = nil

View File

@ -268,7 +268,9 @@ private func ChannelMembersControllerEntries(context: AccountContext, presentati
var index: Int32 = 0
for participant in participants.sorted(by: { lhs, rhs in
let sortedParticipants = participants
/*
participants.sorted(by: { lhs, rhs in
let lhsInvitedAt: Int32
switch lhs.participant {
case .creator:
@ -284,7 +286,9 @@ private func ChannelMembersControllerEntries(context: AccountContext, presentati
rhsInvitedAt = invitedAt
}
return lhsInvitedAt < rhsInvitedAt
}) {
})
*/
for participant in sortedParticipants {
var editable = true
var canEditMembers = false
if let peer = view.peers[view.peerId] as? TelegramChannel {

View File

@ -5123,7 +5123,7 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
case .upperBound:
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
|> mapToSignal { historyView -> Signal<(MessageIndex?, Bool), NoError> in
switch historyView {
@ -5212,7 +5212,7 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
self.historyNavigationStack.add(fromIndex)
}
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
|> mapToSignal { historyView -> Signal<MessageIndex?, NoError> in
switch historyView {

View File

@ -492,12 +492,16 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
let lastEntry = filteredEntries[filteredEntries.count - 1 - visibleRange.lastIndex]
strongSelf.chatHistoryLocation.set(ChatHistoryLocationInput(content: .Navigation(index: .message(lastEntry.index), anchorIndex: .message(lastEntry.index), count: historyMessageCount), id: 0))
} else {
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))
}
}
}
}
}
let initialData: ChatHistoryCombinedInitialData?
switch update {

View File

@ -4,6 +4,25 @@ import TelegramCore
import SwiftSignalKit
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> {
switch location.content {
case let .Initial(count):
@ -116,8 +135,13 @@ func chatHistoryViewForLocation(_ location: ChatHistoryLocationInput, account: A
return .Loading(initialData: combinedInitialData, type: .Generic(type: updateType))
}
var reportUpdateType: ChatHistoryViewUpdateType = .Initial(fadeIn: fadeIn)
if case .FillHole = updateType {
reportUpdateType = .Generic(type: updateType)
}
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):

View File

@ -503,7 +503,7 @@ public class TelegramController: ViewController {
}
if let id = state.id as? PeerMessagesMediaPlaylistItemId {
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
|> mapToSignal { historyView -> Signal<(MessageIndex?, Bool), NoError> in
switch historyView {