Skip to content

Commit

Permalink
Timeline : makes sure we don't emit empty list when navigating back t…
Browse files Browse the repository at this point in the history
…o timeline.
  • Loading branch information
ganfra committed Sep 18, 2024
1 parent 05f2c71 commit b2ffba9
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
Expand Down Expand Up @@ -81,6 +82,7 @@ class TimelinePresenter @AssistedInject constructor(
computeReactions = true,
)
)
private val timelineItems = mutableStateOf<ImmutableList<TimelineItem>>(persistentListOf())

@Composable
override fun present(): TimelineState {
Expand All @@ -89,9 +91,13 @@ class TimelinePresenter @AssistedInject constructor(
mutableStateOf(FocusRequestState.None)
}

var timelineItems by this.timelineItems
LaunchedEffect(Unit) {
timelineItemsFactory.timelineItems.collect { timelineItems = it }
}

val lastReadReceiptId = rememberSaveable { mutableStateOf<EventId?>(null) }

val timelineItems by timelineItemsFactory.timelineItems.collectAsState(initial = persistentListOf())
val roomInfo by room.roomInfoFlow.collectAsState(initial = null)

val syncUpdateFlow = room.syncUpdateFlow.collectAsState()
Expand Down

0 comments on commit b2ffba9

Please sign in to comment.