Fitlers too many reposts out of the main feed.

pull/804/head
Vitor Pamplona 2024-03-11 13:10:29 -04:00
rodzic 64d6d6753c
commit afb5169ede
1 zmienionych plików z 8 dodań i 16 usunięć

Wyświetl plik

@ -74,7 +74,6 @@ class HomeNewThreadFeedFilter(val account: Account) : AdditiveFeedFilter<Note>()
val followingCommunities = account.liveHomeFollowLists.value?.communities ?: emptySet()
val oneMinuteInTheFuture = TimeUtils.now() + (1 * 60) // one minute in the future.
val oneHr = 60 * 60
return collection
.asSequence()
@ -104,25 +103,18 @@ class HomeNewThreadFeedFilter(val account: Account) : AdditiveFeedFilter<Note>()
// acceptable
(isHiddenList || it.author?.let { !account.isHidden(it.pubkeyHex) } ?: true) &&
((it.event?.createdAt() ?: 0) < oneMinuteInTheFuture) &&
it.isNewThread() &&
(
(noteEvent !is RepostEvent && noteEvent !is GenericRepostEvent) || // not a repost
(
it.replyTo?.lastOrNull()?.author?.pubkeyHex !in followingKeySet ||
(
noteEvent.createdAt() >
(
it.replyTo?.lastOrNull()?.createdAt()
?: 0
) + oneHr
)
) // or a repost of by a non-follower's post (likely not seen yet)
)
it.isNewThread()
}
.toSet()
}
override fun sort(collection: Set<Note>): List<Note> {
return collection.sortedWith(compareBy({ it.createdAt() }, { it.idHex })).reversed()
return collection.distinctBy {
if (it.event is RepostEvent || it.event is GenericRepostEvent) {
it.replyTo?.lastOrNull()?.idHex ?: it.idHex // only the most recent repost per feed.
} else {
it.idHex
}
}.sortedWith(compareBy({ it.createdAt() }, { it.idHex })).reversed()
}
}