diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedViewModel.kt index b8c5e8eb1..2eaeaf9a8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedViewModel.kt @@ -21,7 +21,11 @@ package com.vitorpamplona.amethyst.ui.screen import android.util.Log +import androidx.compose.foundation.lazy.LazyListState import androidx.compose.runtime.Stable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.viewModelScope @@ -268,6 +272,8 @@ abstract class FeedViewModel( override fun invalidateData(ignoreIfDoing: Boolean) = feedState.invalidateData(ignoreIfDoing) + var llState: LazyListState by mutableStateOf(LazyListState(0, 0)) + private var collectorJob: Job? = null init { 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 60fb5849c..1d827ccc3 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 @@ -35,7 +35,6 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.itemsIndexed -import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon @@ -210,17 +209,15 @@ fun ThreadFeedView( accountViewModel: AccountViewModel, nav: INav, ) { - val listState = rememberLazyListState() - RefresheableBox(viewModel) { RenderFeedState( viewModel = viewModel, accountViewModel = accountViewModel, - listState = listState, + listState = viewModel.llState, nav = nav, routeForLastRead = null, onLoaded = { - RenderThreadFeed(noteId, it, listState, accountViewModel, nav) + RenderThreadFeed(noteId, it, viewModel.llState, accountViewModel, nav) }, ) }