Room : continue improving members loading

This commit is contained in:
ganfra 2023-04-21 14:39:47 +02:00
parent f02ee307cc
commit b0152059ff
26 changed files with 329 additions and 166 deletions

View file

@ -75,6 +75,7 @@ import io.element.android.libraries.designsystem.theme.components.Text
import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.launch
import timber.log.Timber
@Composable
fun TimelineView(
@ -100,11 +101,11 @@ fun TimelineView(
itemsIndexed(
items = state.timelineItems,
contentType = { _, timelineItem -> timelineItem.contentType() },
key = { _, timelineItem -> timelineItem.key() },
key = { _, timelineItem -> timelineItem.identifier() },
) { index, timelineItem ->
TimelineItemRow(
timelineItem = timelineItem,
isHighlighted = timelineItem.key() == state.highlightedEventId?.value,
isHighlighted = timelineItem.identifier() == state.highlightedEventId?.value,
onClick = onMessageClicked,
onLongClick = onMessageLongClicked
)
@ -114,27 +115,22 @@ fun TimelineView(
}
}
/*
TimelineScrollHelper(
lazyListState = lazyListState,
timelineItems = state.timelineItems,
onLoadMore = ::onReachedLoadMore
)
*/
}
}
private fun TimelineItem.key(): String {
return when (this) {
is TimelineItem.Event -> id
is TimelineItem.Virtual -> id
}
}
private fun TimelineItem.contentType(): Int {
// Todo optimize for each subtype
return when (this) {
is TimelineItem.Event -> 0
is TimelineItem.Virtual -> 1
}
private fun TimelineItem.contentType() = when (this) {
is TimelineItem.Event -> content.javaClass.simpleName
is TimelineItem.Virtual -> model.javaClass.simpleName
}.also {
Timber.v("ContentType = $it")
}
@Composable

View file

@ -25,7 +25,6 @@ import io.element.android.libraries.designsystem.components.avatar.AvatarSize
import io.element.android.libraries.matrix.api.timeline.MatrixTimelineItem
import io.element.android.libraries.matrix.api.timeline.item.event.ProfileTimelineDetails
import kotlinx.collections.immutable.toImmutableList
import timber.log.Timber
import javax.inject.Inject
class TimelineItemEventFactory @Inject constructor(
@ -43,7 +42,6 @@ class TimelineItemEventFactory @Inject constructor(
val senderDisplayName: String?
val senderAvatarUrl: String?
Timber.v("SenderProfile($currentSender) = ${currentTimelineItem.event.senderProfile}")
when (val senderProfile = currentTimelineItem.event.senderProfile) {
ProfileTimelineDetails.Unavailable,
ProfileTimelineDetails.Pending,