Breaks notification cards in chunks of 50 notifications each.

This commit is contained in:
Vitor Pamplona
2023-03-30 11:02:39 -04:00
parent 7f305f498b
commit eff07bfb1e

View File

@@ -100,14 +100,21 @@ open class CardFeedViewModel(val dataSource: FeedFilter<Note>) : ViewModel() {
} }
val allBaseNotes = zapsPerEvent.keys + boostsPerEvent.keys + reactionsPerEvent.keys val allBaseNotes = zapsPerEvent.keys + boostsPerEvent.keys + reactionsPerEvent.keys
val multiCards = allBaseNotes.map { val multiCards = allBaseNotes.map { baseNote ->
val boostsInCard = boostsPerEvent[baseNote] ?: emptyList()
val reactionsInCard = reactionsPerEvent[baseNote] ?: emptyList()
val zapsInCard = zapsPerEvent[baseNote] ?: emptyMap()
val singleList = (boostsInCard + zapsInCard.values + reactionsInCard).sortedBy { it.createdAt() }
singleList.chunked(50).map { chunk ->
MultiSetCard( MultiSetCard(
it, baseNote,
boostsPerEvent.get(it) ?: emptyList(), boostsInCard.filter { it in chunk },
reactionsPerEvent.get(it) ?: emptyList(), reactionsInCard.filter { it in chunk },
zapsPerEvent.get(it) ?: emptyMap() zapsInCard.filter { it.value in chunk }
) )
} }
}.flatten()
val textNoteCards = notes.filter { it.event !is ReactionEvent && it.event !is RepostEvent && it.event !is LnZapEvent }.map { val textNoteCards = notes.filter { it.event !is ReactionEvent && it.event !is RepostEvent && it.event !is LnZapEvent }.map {
if (it.event is PrivateDmEvent) { if (it.event is PrivateDmEvent) {