Compute aggregatedReadReceipts in a background worker.
This commit is contained in:
parent
60332bf64a
commit
16f5705dff
5 changed files with 16 additions and 14 deletions
|
|
@ -204,11 +204,10 @@ internal fun aGroupedEvents(id: Long = 0): TimelineItem.GroupedEvents {
|
||||||
receipts = listOf(aReadReceiptData(1)).toPersistentList(),
|
receipts = listOf(aReadReceiptData(1)).toPersistentList(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
val events = listOf(event1, event2)
|
||||||
return TimelineItem.GroupedEvents(
|
return TimelineItem.GroupedEvents(
|
||||||
id = id.toString(),
|
id = id.toString(),
|
||||||
events = listOf(
|
events = events.toImmutableList(),
|
||||||
event1,
|
aggregatedReadReceipts = events.flatMap { it.readReceiptState.receipts }.toImmutableList(),
|
||||||
event2,
|
|
||||||
).toImmutableList()
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||||
import io.element.android.libraries.matrix.api.core.EventId
|
import io.element.android.libraries.matrix.api.core.EventId
|
||||||
import io.element.android.libraries.matrix.api.core.UserId
|
import io.element.android.libraries.matrix.api.core.UserId
|
||||||
import kotlinx.collections.immutable.toImmutableList
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun TimelineItemGroupedEventsRow(
|
fun TimelineItemGroupedEventsRow(
|
||||||
|
|
@ -147,7 +146,7 @@ private fun TimelineItemGroupedEventsRowContent(
|
||||||
state = ReadReceiptViewState(
|
state = ReadReceiptViewState(
|
||||||
sendState = null,
|
sendState = null,
|
||||||
isLastOutgoingMessage = false,
|
isLastOutgoingMessage = false,
|
||||||
receipts = timelineItem.events.flatMap { it.readReceiptState.receipts }.toImmutableList(),
|
receipts = timelineItem.aggregatedReadReceipts,
|
||||||
),
|
),
|
||||||
showReadReceipts = true,
|
showReadReceipts = true,
|
||||||
onReadReceiptsClicked = { /* No op for group event */ })
|
onReadReceiptsClicked = { /* No op for group event */ })
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,8 @@ private fun MutableList<TimelineItem>.addGroup(
|
||||||
add(
|
add(
|
||||||
TimelineItem.GroupedEvents(
|
TimelineItem.GroupedEvents(
|
||||||
id = groupId,
|
id = groupId,
|
||||||
events = groupOfItems.toImmutableList()
|
events = groupOfItems.toImmutableList(),
|
||||||
|
aggregatedReadReceipts = groupOfItems.flatMap { it.readReceiptState.receipts }.toImmutableList()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,6 @@ sealed interface TimelineItem {
|
||||||
data class GroupedEvents(
|
data class GroupedEvents(
|
||||||
val id: String,
|
val id: String,
|
||||||
val events: ImmutableList<Event>,
|
val events: ImmutableList<Event>,
|
||||||
|
val aggregatedReadReceipts: ImmutableList<ReadReceiptData>,
|
||||||
) : TimelineItem
|
) : TimelineItem
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,11 +86,12 @@ class TimelineItemGrouperTest {
|
||||||
assertThat(result).isEqualTo(
|
assertThat(result).isEqualTo(
|
||||||
listOf(
|
listOf(
|
||||||
TimelineItem.GroupedEvents(
|
TimelineItem.GroupedEvents(
|
||||||
computeGroupIdWith(aGroupableItem),
|
id = computeGroupIdWith(aGroupableItem),
|
||||||
events = listOf(
|
events = listOf(
|
||||||
aGroupableItem.copy("0"),
|
aGroupableItem.copy("0"),
|
||||||
aGroupableItem.copy(id = "1"),
|
aGroupableItem.copy(id = "1"),
|
||||||
).toImmutableList()
|
).toImmutableList(),
|
||||||
|
aggregatedReadReceipts = emptyList<ReadReceiptData>().toImmutableList(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -132,20 +133,22 @@ class TimelineItemGrouperTest {
|
||||||
assertThat(result).isEqualTo(
|
assertThat(result).isEqualTo(
|
||||||
listOf(
|
listOf(
|
||||||
TimelineItem.GroupedEvents(
|
TimelineItem.GroupedEvents(
|
||||||
computeGroupIdWith(aGroupableItem),
|
id = computeGroupIdWith(aGroupableItem),
|
||||||
events = listOf(
|
events = listOf(
|
||||||
aGroupableItem,
|
aGroupableItem,
|
||||||
aGroupableItem,
|
aGroupableItem,
|
||||||
).toImmutableList()
|
).toImmutableList(),
|
||||||
|
aggregatedReadReceipts = emptyList<ReadReceiptData>().toImmutableList(),
|
||||||
),
|
),
|
||||||
aNonGroupableItem,
|
aNonGroupableItem,
|
||||||
TimelineItem.GroupedEvents(
|
TimelineItem.GroupedEvents(
|
||||||
computeGroupIdWith(aGroupableItem),
|
id = computeGroupIdWith(aGroupableItem),
|
||||||
events = listOf(
|
events = listOf(
|
||||||
aGroupableItem,
|
aGroupableItem,
|
||||||
aGroupableItem,
|
aGroupableItem,
|
||||||
aGroupableItem,
|
aGroupableItem,
|
||||||
).toImmutableList()
|
).toImmutableList(),
|
||||||
|
aggregatedReadReceipts = emptyList<ReadReceiptData>().toImmutableList(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue