From a64e9bb3cf15a7ced78f24ee55b1cee4c5ceb88c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 10 Mar 2026 15:15:27 +0000 Subject: [PATCH] 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 --- .../vitorpamplona/amethyst/ui/feeds/RememberForeverStates.kt | 2 ++ .../amethyst/ui/screen/loggedIn/search/SearchScreen.kt | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/RememberForeverStates.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/RememberForeverStates.kt index fbc6b5135..2cc7b942c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/RememberForeverStates.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/RememberForeverStates.kt @@ -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 { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchScreen.kt index 12ac914aa..acf6814c6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchScreen.kt @@ -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()