diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt index 77350a7a8..60fb5849c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt @@ -197,7 +197,6 @@ import com.vitorpamplona.quartz.events.TorrentCommentEvent import com.vitorpamplona.quartz.events.TorrentEvent import com.vitorpamplona.quartz.events.VideoEvent import com.vitorpamplona.quartz.events.WikiNoteEvent -import com.vitorpamplona.quartz.utils.TimeUtils import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -236,7 +235,6 @@ fun RenderThreadFeed( nav: INav, ) { val items by loaded.feed.collectAsStateWithLifecycle() - val firstTimeScrolled = remember { TimeUtils.now() } LaunchedEffect(noteId, items.list) { // hack to allow multiple scrolls to Item while posts on the screen load. @@ -252,10 +250,15 @@ fun RenderThreadFeed( // records before setting up the position on the feed. // // It jumps around, but it is the best we can do. - if (TimeUtils.now() - firstTimeScrolled < 1000) { + if (listState.firstVisibleItemIndex == 0 && listState.firstVisibleItemScrollOffset == 0 && items.list.size > 3) { val position = items.list.indexOfFirst { it.idHex == noteId } + if (position >= 0) { - listState.scrollToItem(position, -200) + if (position > items.list.size - 3) { + listState.scrollToItem(position, 0) + } else { + listState.scrollToItem(position, -200) + } } } }