fix: preserve search screen scroll position across navigation

Replace ephemeral rememberLazyListState() with rememberForeverLazyListState()
so the scroll position is persisted when navigating to a search result and back.

https://claude.ai/code/session_01PmSFQqSMzP51mtqPLwFEtp
This commit is contained in:
Claude
2026-03-10 15:15:27 +00:00
parent f42939c3b0
commit a64e9bb3cf
2 changed files with 5 additions and 2 deletions
@@ -54,6 +54,8 @@ object ScrollStateKeys {
const val DISCOVER_LIVE = "DiscoverLiveFeed"
const val DISCOVER_COMMUNITY = "DiscoverCommunitiesFeed"
const val DISCOVER_CHATS = "DiscoverChatsFeed"
const val SEARCH_SCREEN = "SearchFeed"
}
object PagerStateKeys {
@@ -33,7 +33,8 @@ import androidx.compose.foundation.layout.statusBarsPadding
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 com.vitorpamplona.amethyst.ui.feeds.ScrollStateKeys
import com.vitorpamplona.amethyst.ui.feeds.rememberForeverLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.HorizontalDivider
@@ -107,7 +108,7 @@ fun SearchScreen(
) {
WatchLifecycleAndUpdateModel(searchBarViewModel)
val listState = rememberLazyListState()
val listState = rememberForeverLazyListState(ScrollStateKeys.SEARCH_SCREEN)
LaunchedEffect(searchBarViewModel.focusRequester) {
searchBarViewModel.focusRequester.requestFocus()