Skip to content

Commit

Permalink
Fixes jumpy thread view
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorpamplona committed Oct 28, 2024
1 parent 4a43a87 commit d1b4f81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
},
)
}
Expand Down

0 comments on commit d1b4f81

Please sign in to comment.