Timeline permalink : scroll to fetched event when known
This commit is contained in:
@@ -146,7 +146,7 @@ class TimelinePresenter @AssistedInject constructor(
|
||||
timelineController.focusOnEvent(event.eventId)
|
||||
.fold(
|
||||
onSuccess = {
|
||||
focusRequestState.value = FocusRequestState.None
|
||||
focusRequestState.value = FocusRequestState.Fetched
|
||||
},
|
||||
onFailure = {
|
||||
focusRequestState.value = FocusRequestState.Failure(it)
|
||||
@@ -165,15 +165,20 @@ class TimelinePresenter @AssistedInject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
// Makes sure to get back to live when there is nothing more to load forwards
|
||||
LaunchedEffect(isLive) {
|
||||
|
||||
}
|
||||
|
||||
LaunchedEffect(timelineItems.size) {
|
||||
computeNewItemState(timelineItems, prevMostRecentItemId, newEventState)
|
||||
}
|
||||
|
||||
LaunchedEffect(timelineItems.size, focusRequestState.value, focusedEventId.value) {
|
||||
val currentFocusedEventId = focusedEventId.value
|
||||
if (focusRequestState.value is FocusRequestState.Fetched && currentFocusedEventId != null) {
|
||||
if (timelineItemIndexer.isKnown(currentFocusedEventId)) {
|
||||
val index = timelineItemIndexer.indexOf(currentFocusedEventId)
|
||||
focusRequestState.value = FocusRequestState.Cached(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
combine(timelineController.timelineItems(), room.membersStateFlow) { items, membersState ->
|
||||
timelineItemsFactory.replaceWith(
|
||||
|
||||
@@ -40,6 +40,7 @@ sealed interface FocusRequestState {
|
||||
data object None : FocusRequestState
|
||||
data class Cached(val index: Int): FocusRequestState
|
||||
data object Fetching : FocusRequestState
|
||||
data object Fetched: FocusRequestState
|
||||
data class Failure(val throwable: Throwable) : FocusRequestState
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ private fun FocusRequestStateView(
|
||||
FocusRequestState.Fetching -> {
|
||||
ProgressDialog(modifier = modifier, onDismissRequest = onClearFocusRequestState)
|
||||
}
|
||||
is FocusRequestState.Cached, FocusRequestState.None -> Unit
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ private fun BoxScope.TimelineScrollHelper(
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(key1 = focusRequestState) {
|
||||
LaunchedEffect(focusRequestState) {
|
||||
if (focusRequestState is FocusRequestState.Cached) {
|
||||
if (abs(lazyListState.firstVisibleItemIndex - focusRequestState.index) < 10) {
|
||||
lazyListState.animateScrollToItem(focusRequestState.index)
|
||||
|
||||
@@ -51,7 +51,7 @@ fun TimelineItemVirtualRow(
|
||||
TimelineItemRoomBeginningModel -> TimelineItemRoomBeginningView(roomName = timelineRoomInfo.name)
|
||||
is TimelineItemLoadingIndicatorModel -> {
|
||||
TimelineLoadingMoreIndicator()
|
||||
LaunchedEffect(key1 = virtual.model.timestamp) {
|
||||
LaunchedEffect(virtual.model.timestamp) {
|
||||
eventSink(TimelineEvents.LoadMore(virtual.model.direction))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user