BugFix for too many streams (fix in max = 2 for now)

This commit is contained in:
Vitor Pamplona 2023-06-20 18:58:41 -04:00
parent ce207aed39
commit 2a47cd4fd1
2 changed files with 6 additions and 2 deletions

View File

@ -15,9 +15,11 @@ abstract class FeedFilter<T> {
}
Log.d("Time", "${this.javaClass.simpleName} Full Feed in $elapsed with ${feed.size} objects")
return feed.take(1000)
return feed.take(limit())
}
open fun limit() = 1000
/**
* Returns a string that serves as the key to invalidate the list if it changes.
*/
@ -38,7 +40,7 @@ abstract class AdditiveFeedFilter<T> : FeedFilter<T>() {
val newItemsToBeAdded = applyFilter(newItems)
if (newItemsToBeAdded.isNotEmpty()) {
val newList = oldList.toSet() + newItemsToBeAdded
sort(newList).take(1000)
sort(newList).take(limit())
} else {
oldList
}

View File

@ -49,6 +49,8 @@ class HomeLiveActivitiesFeedFilter(val account: Account) : AdditiveFeedFilter<No
.toSet()
}
override fun limit() = 2
override fun sort(collection: Set<Note>): List<Note> {
return collection.sortedWith(compareBy({ it.createdAt() }, { it.idHex })).reversed()
}