Fixes jumpy thread view

This commit is contained in:
Vitor Pamplona 2024-10-28 16:10:47 -04:00
parent 4a43a87a79
commit d1b4f81083
2 changed files with 8 additions and 5 deletions

View File

@ -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 {

View File

@ -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)
},
)
}