diff --git a/TelegramUI/ChannelMemberCategoryListContext.swift b/TelegramUI/ChannelMemberCategoryListContext.swift index 45773f48f4..e80fa26b3f 100644 --- a/TelegramUI/ChannelMemberCategoryListContext.swift +++ b/TelegramUI/ChannelMemberCategoryListContext.swift @@ -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 diff --git a/TelegramUI/ChannelMembersController.swift b/TelegramUI/ChannelMembersController.swift index 9bc6e32e42..3c49e36e84 100644 --- a/TelegramUI/ChannelMembersController.swift +++ b/TelegramUI/ChannelMembersController.swift @@ -268,23 +268,27 @@ private func ChannelMembersControllerEntries(context: AccountContext, presentati var index: Int32 = 0 - for participant in participants.sorted(by: { lhs, rhs in - let lhsInvitedAt: Int32 - switch lhs.participant { - case .creator: - lhsInvitedAt = Int32.min - case let .member(_, invitedAt, _, _): - lhsInvitedAt = invitedAt - } - let rhsInvitedAt: Int32 - switch rhs.participant { - case .creator: - rhsInvitedAt = Int32.min - case let .member(_, invitedAt, _, _): - rhsInvitedAt = invitedAt - } - return lhsInvitedAt < rhsInvitedAt - }) { + let sortedParticipants = participants + /* + participants.sorted(by: { lhs, rhs in + let lhsInvitedAt: Int32 + switch lhs.participant { + case .creator: + lhsInvitedAt = Int32.min + case let .member(_, invitedAt, _, _): + lhsInvitedAt = invitedAt + } + let rhsInvitedAt: Int32 + switch rhs.participant { + case .creator: + rhsInvitedAt = Int32.min + case let .member(_, invitedAt, _, _): + rhsInvitedAt = invitedAt + } + return lhsInvitedAt < rhsInvitedAt + }) + */ + for participant in sortedParticipants { var editable = true var canEditMembers = false if let peer = view.peers[view.peerId] as? TelegramChannel { diff --git a/TelegramUI/ChatController.swift b/TelegramUI/ChatController.swift index 4a1d6da15c..297ac98aae 100644 --- a/TelegramUI/ChatController.swift +++ b/TelegramUI/ChatController.swift @@ -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 in switch historyView { diff --git a/TelegramUI/ChatHistoryListNode.swift b/TelegramUI/ChatHistoryListNode.swift index 96496e9d39..f750c0cdec 100644 --- a/TelegramUI/ChatHistoryListNode.swift +++ b/TelegramUI/ChatHistoryListNode.swift @@ -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)) } 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)) + } } } } diff --git a/TelegramUI/ChatHistoryViewForLocation.swift b/TelegramUI/ChatHistoryViewForLocation.swift index a7144aaa56..00ef8fd5c8 100644 --- a/TelegramUI/ChatHistoryViewForLocation.swift +++ b/TelegramUI/ChatHistoryViewForLocation.swift @@ -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 { + return chatHistoryViewForLocation(location, account: account, chatLocation: chatLocation, fixedCombinedReadStates: fixedCombinedReadStates, tagMask: tagMask, additionalData: additionalData, orderStatistics: orderStatistics) + |> introduceError(Bool.self) + |> mapToSignal { update -> Signal 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 { 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): diff --git a/TelegramUI/TelegramController.swift b/TelegramUI/TelegramController.swift index e37b1d2750..a098409f57 100644 --- a/TelegramUI/TelegramController.swift +++ b/TelegramUI/TelegramController.swift @@ -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 {