Update bad calculation of content size for stories collection.

This commit is contained in:
Alex Hart 2022-09-26 12:03:57 -03:00 committed by Cody Henthorne
parent 457c3c0526
commit 2a82db2b02
2 changed files with 4 additions and 1 deletions

View file

@ -16,7 +16,7 @@ open class ContactSearchCollection<ContactRecord>(
private val activeContactCount: Int
) {
private val contentSize: Int = if (recordPredicate != null) {
protected open val contentSize: Int = if (recordPredicate != null) {
records.asSequence().filter(recordPredicate).count()
} else {
records.getCount()

View file

@ -14,6 +14,7 @@ class StoriesSearchCollection<ContactRecord>(
activeContactCount: Int,
private val storyComparator: Comparator<ContactSearchData.Story>
) : ContactSearchCollection<ContactRecord>(section, records, null, recordMapper, activeContactCount) {
private val aggregateStoryData: List<ContactSearchData.Story> by lazy {
if (section !is ContactSearchConfiguration.Section.Stories) {
error("Aggregate data creation is only necessary for stories.")
@ -24,6 +25,8 @@ class StoriesSearchCollection<ContactRecord>(
(cursorContacts + extraData).filterIsInstance(ContactSearchData.Story::class.java).sortedWith(storyComparator)
}
override val contentSize: Int = records.getCount() + extraData.size
override fun getItemAtCorrectedIndex(correctedIndex: Int): ContactSearchData {
return aggregateStoryData[correctedIndex]
}