kopia lustrzana https://github.com/vitorpamplona/amethyst
30 wiersze
1.2 KiB
Kotlin
30 wiersze
1.2 KiB
Kotlin
package com.vitorpamplona.amethyst.ui.dal
|
|
|
|
import com.vitorpamplona.amethyst.model.Account
|
|
import com.vitorpamplona.amethyst.model.LocalCache
|
|
import com.vitorpamplona.amethyst.model.Note
|
|
import com.vitorpamplona.amethyst.service.model.PollNoteEvent
|
|
import com.vitorpamplona.amethyst.service.model.RepostEvent
|
|
import com.vitorpamplona.amethyst.service.model.TextNoteEvent
|
|
|
|
object HomeConversationsFeedFilter : FeedFilter<Note>() {
|
|
lateinit var account: Account
|
|
|
|
override fun feed(): List<Note> {
|
|
val user = account.userProfile()
|
|
val followingKeySet = user.cachedFollowingKeySet()
|
|
val followingTagSet = user.cachedFollowingTagSet()
|
|
|
|
return LocalCache.notes.values
|
|
.filter {
|
|
(it.event is TextNoteEvent || it.event is PollNoteEvent || it.event is RepostEvent) &&
|
|
(it.author?.pubkeyHex in followingKeySet || (it.event?.isTaggedHashes(followingTagSet) ?: false)) &&
|
|
// && account.isAcceptable(it) // This filter follows only. No need to check if acceptable
|
|
it.author?.let { !account.isHidden(it) } ?: true &&
|
|
!it.isNewThread()
|
|
}
|
|
.sortedBy { it.createdAt() }
|
|
.reversed()
|
|
}
|
|
}
|