Browse Source

Timeline : rename isTimelineEmpty to hasAnyEvent

pull/2759/head
ganfra 5 months ago
parent
commit
6632b2a998
  1. 2
      features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelineState.kt
  2. 10
      features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelineView.kt

2
features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelineState.kt

@ -33,7 +33,7 @@ data class TimelineState( @@ -33,7 +33,7 @@ data class TimelineState(
val focusRequestState: FocusRequestState,
val eventSink: (TimelineEvents) -> Unit,
){
val isTimelineEmpty = timelineItems.none { it is TimelineItem.Event }
val hasAnyEvent = timelineItems.any { it is TimelineItem.Event }
}
sealed interface FocusRequestState {

10
features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelineView.kt

@ -19,7 +19,6 @@ @@ -19,7 +19,6 @@
package io.element.android.features.messages.impl.timeline
import android.view.accessibility.AccessibilityManager
import androidx.activity.compose.BackHandler
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.core.tween
@ -75,7 +74,6 @@ import io.element.android.libraries.matrix.api.core.EventId @@ -75,7 +74,6 @@ import io.element.android.libraries.matrix.api.core.EventId
import io.element.android.libraries.matrix.api.core.UserId
import io.element.android.libraries.ui.strings.CommonStrings
import kotlinx.coroutines.launch
import timber.log.Timber
import kotlin.math.abs
@Composable
@ -166,7 +164,7 @@ fun TimelineView( @@ -166,7 +164,7 @@ fun TimelineView(
)
TimelineScrollHelper(
isTimelineEmpty = state.isTimelineEmpty,
hasAnyEvent = state.hasAnyEvent,
lazyListState = lazyListState,
forceJumpToBottomVisibility = forceJumpToBottomVisibility,
newEventState = state.newEventState,
@ -203,7 +201,7 @@ private fun FocusRequestStateView( @@ -203,7 +201,7 @@ private fun FocusRequestStateView(
@Composable
private fun BoxScope.TimelineScrollHelper(
isTimelineEmpty: Boolean,
hasAnyEvent: Boolean,
lazyListState: LazyListState,
newEventState: NewEventState,
isLive: Boolean,
@ -258,8 +256,8 @@ private fun BoxScope.TimelineScrollHelper( @@ -258,8 +256,8 @@ private fun BoxScope.TimelineScrollHelper(
}
val latestOnScrollFinishedAt by rememberUpdatedState(onScrollFinishedAt)
LaunchedEffect(isScrollFinished, isTimelineEmpty) {
if (isScrollFinished && !isTimelineEmpty) {
LaunchedEffect(isScrollFinished, hasAnyEvent) {
if (isScrollFinished && hasAnyEvent) {
// Notify the parent composable about the first visible item index when scrolling finishes
latestOnScrollFinishedAt(lazyListState.firstVisibleItemIndex)
}

Loading…
Cancel
Save