From 20c29a6c091215f4b994d419230fb6c0e1975f93 Mon Sep 17 00:00:00 2001 From: Manuel Vivo Date: Fri, 27 Jan 2023 11:39:31 +0100 Subject: [PATCH] Fix bookmarking scrolling to top of the page bug (#548) --- .../apps/nowinandroid/feature/foryou/ForYouViewModel.kt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt b/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt index 4895f8306..d75965778 100644 --- a/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt +++ b/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt @@ -32,7 +32,6 @@ import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map -import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch import javax.inject.Inject @@ -68,7 +67,8 @@ class ForYouViewModel @Inject constructor( } else { getSaveableNewsResources( filterTopicIds = userData.followedTopics, - ).mapToFeedState() + ) + .map, NewsFeedUiState>(NewsFeedUiState::Success) } } // Flatten the feed flows. @@ -116,7 +116,3 @@ class ForYouViewModel @Inject constructor( } } } - -private fun Flow>.mapToFeedState(): Flow = - map, NewsFeedUiState>(NewsFeedUiState::Success) - .onStart { emit(NewsFeedUiState.Loading) }