mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Use symmetric chat list loading
This commit is contained in:
parent
974c2d8e17
commit
5ad48b0af8
@ -433,7 +433,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
|
||||
}
|
||||
let (totalCount, items) = countAndFilterItems
|
||||
var filterItems: [ChatListFilterTabEntry] = []
|
||||
filterItems.append(.all(unreadCount: totalCount))
|
||||
filterItems.append(.all(unreadCount: 0))
|
||||
for (filter, unreadCount) in items {
|
||||
filterItems.append(.filter(id: filter.id, text: filter.title, unreadCount: unreadCount))
|
||||
}
|
||||
|
@ -421,8 +421,8 @@ final class ChatListTable: Table {
|
||||
lowerEntries.append(entry)
|
||||
return .accept
|
||||
}
|
||||
}, limit: count / 2 + 1)
|
||||
if lowerEntries.count >= count / 2 + 1 {
|
||||
}, limit: count + 1)
|
||||
if lowerEntries.count >= count + 1 {
|
||||
lower = lowerEntries.last
|
||||
lowerEntries.removeLast()
|
||||
}
|
||||
@ -440,42 +440,12 @@ final class ChatListTable: Table {
|
||||
upperEntries.append(entry)
|
||||
return .accept
|
||||
}
|
||||
}, limit: count - lowerEntries.count + 1)
|
||||
if upperEntries.count >= count - lowerEntries.count + 1 {
|
||||
}, limit: count + 1)
|
||||
if upperEntries.count >= count + 1 {
|
||||
upper = upperEntries.last
|
||||
upperEntries.removeLast()
|
||||
}
|
||||
|
||||
if lowerEntries.count != 0 && lowerEntries.count + upperEntries.count < count {
|
||||
var additionalLowerEntries: [ChatListIntermediateEntry] = []
|
||||
let startEntryType: ChatListEntryType
|
||||
switch lowerEntries.last! {
|
||||
case .message:
|
||||
startEntryType = .message
|
||||
case .hole:
|
||||
startEntryType = .hole
|
||||
}
|
||||
self.valueBox.filteredRange(self.table, start: self.key(groupId: groupId, index: lowerEntries.last!.index, type: startEntryType), end: self.lowerBound(groupId: groupId), values: { key, value in
|
||||
let entry = readEntry(groupId: groupId, messageHistoryTable: messageHistoryTable, peerChatInterfaceStateTable: peerChatInterfaceStateTable, key: key, value: value)
|
||||
if let predicate = predicate {
|
||||
if predicate(entry) {
|
||||
additionalLowerEntries.append(entry)
|
||||
return .accept
|
||||
} else {
|
||||
return .skip
|
||||
}
|
||||
} else {
|
||||
additionalLowerEntries.append(entry)
|
||||
return .accept
|
||||
}
|
||||
}, limit: count - lowerEntries.count - upperEntries.count + 1)
|
||||
if additionalLowerEntries.count >= count - lowerEntries.count + upperEntries.count + 1 {
|
||||
lower = additionalLowerEntries.last
|
||||
additionalLowerEntries.removeLast()
|
||||
}
|
||||
lowerEntries.append(contentsOf: additionalLowerEntries)
|
||||
}
|
||||
|
||||
var entries: [ChatListIntermediateEntry] = []
|
||||
entries.append(contentsOf: lowerEntries.reversed())
|
||||
entries.append(contentsOf: upperEntries)
|
||||
|
Loading…
x
Reference in New Issue
Block a user