Add additional check [skip ci]

This commit is contained in:
Ali 2020-04-05 20:25:35 +04:00
parent f2cc0bb423
commit bbd3a3af92

View File

@ -794,6 +794,7 @@ private final class ChatListViewSpaceState {
}
self.checkEntries(postbox: postbox)
self.checkReplayEntries(postbox: postbox)
return hasUpdates
}
@ -822,6 +823,14 @@ private final class ChatListViewSpaceState {
#endif
}
private func checkReplayEntries(postbox: Postbox) {
#if DEBUG
let cleanState = ChatListViewSpaceState(postbox: postbox, space: self.space, anchorIndex: self.anchorIndex, summaryComponents: self.summaryComponents, halfLimit: self.halfLimit)
assert(self.orderedEntries.lowerOrAtAnchor.map { $0.index } == cleanState.orderedEntries.lowerOrAtAnchor.map { $0.index })
assert(self.orderedEntries.higherThanAnchor.map { $0.index } == cleanState.orderedEntries.higherThanAnchor.map { $0.index })
#endif
}
private func add(entry: MutableChatListEntry) -> Bool {
if self.anchorIndex >= entry.entryIndex {
let insertionIndex = binaryInsertionIndex(self.orderedEntries.lowerOrAtAnchor, extract: { $0.entryIndex }, searchItem: entry.entryIndex)