Fix detekt issues

This commit is contained in:
Benoit Marty 2024-04-26 15:23:24 +02:00
parent ee7f0bac8b
commit 9b4fa0f03d
4 changed files with 9 additions and 3 deletions

View file

@ -235,6 +235,7 @@ private fun BoxScope.TimelineScrollHelper(
} }
} }
val latestOnClearFocusRequestState by rememberUpdatedState(onClearFocusRequestState)
LaunchedEffect(focusRequestState) { LaunchedEffect(focusRequestState) {
if (focusRequestState is FocusRequestState.Cached) { if (focusRequestState is FocusRequestState.Cached) {
if (abs(lazyListState.firstVisibleItemIndex - focusRequestState.index) < 10) { if (abs(lazyListState.firstVisibleItemIndex - focusRequestState.index) < 10) {
@ -242,7 +243,7 @@ private fun BoxScope.TimelineScrollHelper(
} else { } else {
lazyListState.scrollToItem(focusRequestState.index) lazyListState.scrollToItem(focusRequestState.index)
} }
onClearFocusRequestState() latestOnClearFocusRequestState()
} }
} }

View file

@ -135,6 +135,7 @@ internal fun TimelineItemRow(
} }
} }
@Suppress("ModifierComposable")
@Composable @Composable
private fun Modifier.focusedEvent( private fun Modifier.focusedEvent(
focusedEventOffset: Dp focusedEventOffset: Dp

View file

@ -20,6 +20,8 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import io.element.android.features.messages.impl.timeline.TimelineEvents import io.element.android.features.messages.impl.timeline.TimelineEvents
import io.element.android.features.messages.impl.timeline.TimelineRoomInfo import io.element.android.features.messages.impl.timeline.TimelineRoomInfo
@ -51,8 +53,9 @@ fun TimelineItemVirtualRow(
TimelineItemRoomBeginningModel -> TimelineItemRoomBeginningView(roomName = timelineRoomInfo.name) TimelineItemRoomBeginningModel -> TimelineItemRoomBeginningView(roomName = timelineRoomInfo.name)
is TimelineItemLoadingIndicatorModel -> { is TimelineItemLoadingIndicatorModel -> {
TimelineLoadingMoreIndicator(virtual.model.direction) TimelineLoadingMoreIndicator(virtual.model.direction)
val latestEventSink by rememberUpdatedState(eventSink)
LaunchedEffect(virtual.model.timestamp) { LaunchedEffect(virtual.model.timestamp) {
eventSink(TimelineEvents.LoadMore(virtual.model.direction)) latestEventSink(TimelineEvents.LoadMore(virtual.model.direction))
} }
} }
is TimelineItemLastForwardIndicatorModel -> { is TimelineItemLastForwardIndicatorModel -> {

View file

@ -222,7 +222,8 @@ class RustTimeline(
isDm = matrixRoom.isDm, isDm = matrixRoom.isDm,
hasMoreToLoadBackwards = hasMoreToLoadBackward hasMoreToLoadBackwards = hasMoreToLoadBackward
) )
}.let { items -> loadingIndicatorsPostProcessor.process(items, hasMoreToLoadBackward, hasMoreToLoadForward) } }
.let { items -> loadingIndicatorsPostProcessor.process(items, hasMoreToLoadBackward, hasMoreToLoadForward) }
// Keep lastForwardIndicatorsPostProcessor last // Keep lastForwardIndicatorsPostProcessor last
.let { items -> lastForwardIndicatorsPostProcessor.process(items) } .let { items -> lastForwardIndicatorsPostProcessor.process(items) }
} }