Ranks communities by the last post in each community in the discovery screen
This commit is contained in:
@@ -23,7 +23,6 @@ package com.vitorpamplona.amethyst.ui.dal
|
|||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
import com.vitorpamplona.amethyst.model.LocalCache
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.model.ParticipantListBuilder
|
|
||||||
import com.vitorpamplona.quartz.encoders.ATag
|
import com.vitorpamplona.quartz.encoders.ATag
|
||||||
import com.vitorpamplona.quartz.events.CommunityDefinitionEvent
|
import com.vitorpamplona.quartz.events.CommunityDefinitionEvent
|
||||||
import com.vitorpamplona.quartz.events.CommunityPostApprovalEvent
|
import com.vitorpamplona.quartz.events.CommunityPostApprovalEvent
|
||||||
@@ -112,21 +111,15 @@ open class DiscoverCommunityFeedFilter(val account: Account) : AdditiveFeedFilte
|
|||||||
) = aTag != null && aTag.kind == CommunityDefinitionEvent.KIND && params.match(aTag)
|
) = aTag != null && aTag.kind == CommunityDefinitionEvent.KIND && params.match(aTag)
|
||||||
|
|
||||||
override fun sort(collection: Set<Note>): List<Note> {
|
override fun sort(collection: Set<Note>): List<Note> {
|
||||||
val followingKeySet =
|
val lastNote =
|
||||||
account.liveDiscoveryFollowLists.value?.users ?: account.liveKind3Follows.value.users
|
collection.associateWith { note ->
|
||||||
|
note.boosts.maxOfOrNull { it.createdAt() ?: 0 } ?: 0
|
||||||
val counter = ParticipantListBuilder()
|
}
|
||||||
val participantCounts =
|
|
||||||
collection.associate { it to counter.countFollowsThatParticipateOn(it, followingKeySet) }
|
|
||||||
|
|
||||||
val allParticipants =
|
|
||||||
collection.associate { it to counter.countFollowsThatParticipateOn(it, null) }
|
|
||||||
|
|
||||||
return collection
|
return collection
|
||||||
.sortedWith(
|
.sortedWith(
|
||||||
compareBy(
|
compareBy(
|
||||||
{ participantCounts[it] },
|
{ lastNote[it] },
|
||||||
{ allParticipants[it] },
|
|
||||||
{ it.createdAt() },
|
{ it.createdAt() },
|
||||||
{ it.idHex },
|
{ it.idHex },
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user