diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feeds/FeedsEffect.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feeds/FeedsEffect.kt index c9c453d50..3ef2f8584 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feeds/FeedsEffect.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feeds/FeedsEffect.kt @@ -18,4 +18,6 @@ package dev.sasikanth.rss.reader.feeds sealed interface FeedsEffect { data object MinimizeSheet : FeedsEffect + + data object SelectedFeedChanged : FeedsEffect } diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feeds/FeedsPresenter.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feeds/FeedsPresenter.kt index 4973219dd..9be7b6f46 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feeds/FeedsPresenter.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feeds/FeedsPresenter.kt @@ -165,6 +165,8 @@ class FeedsPresenter( if (_state.value.selectedFeed?.link != feed.link) { observableSelectedFeed.selectFeed(feed) } + + effects.emit(FeedsEffect.SelectedFeedChanged) effects.emit(FeedsEffect.MinimizeSheet) } } diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feeds/ui/FeedsBottomSheet.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feeds/ui/FeedsBottomSheet.kt index fa6cb71e2..33059f0c1 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feeds/ui/FeedsBottomSheet.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/feeds/ui/FeedsBottomSheet.kt @@ -105,7 +105,8 @@ internal fun FeedsBottomSheet( feedsSheetMode: FeedsSheetMode, closeSheet: () -> Unit, editFeeds: () -> Unit, - exitFeedsEdit: () -> Unit + exitFeedsEdit: () -> Unit, + selectedFeedChanged: () -> Unit ) { val state by feedsPresenter.state.collectAsState() val selectedFeed = state.selectedFeed @@ -114,6 +115,7 @@ internal fun FeedsBottomSheet( feedsPresenter.effects.collect { effect -> when (effect) { FeedsEffect.MinimizeSheet -> closeSheet() + FeedsEffect.SelectedFeedChanged -> selectedFeedChanged() } } } diff --git a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/ui/HomeScreen.kt b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/ui/HomeScreen.kt index df2f1ec0b..60c165675 100644 --- a/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/ui/HomeScreen.kt +++ b/shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/home/ui/HomeScreen.kt @@ -71,7 +71,6 @@ import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.unit.coerceIn import androidx.compose.ui.unit.dp import androidx.paging.LoadState import app.cash.paging.compose.collectAsLazyPagingItems @@ -154,11 +153,6 @@ internal fun HomeScreen(homePresenter: HomePresenter, modifier: Modifier = Modif } } - LaunchedEffect(state.selectedFeed) { - listState.scrollToItem(0) - featuredPostsPagerState.scrollToPage(0) - } - LaunchedEffect(bottomSheetState.targetValue) { if (bottomSheetState.targetValue == BottomSheetValue.Collapsed) { homePresenter.dispatch(HomeEvent.OnCancelAddFeedClicked) @@ -204,7 +198,13 @@ internal fun HomeScreen(homePresenter: HomePresenter, modifier: Modifier = Modif feedsSheetMode = state.feedsSheetMode, closeSheet = { coroutineScope.launch { bottomSheetState.collapse() } }, editFeeds = { homePresenter.dispatch(HomeEvent.EditFeedsClicked) }, - exitFeedsEdit = { homePresenter.dispatch(HomeEvent.ExitFeedsEdit) } + exitFeedsEdit = { homePresenter.dispatch(HomeEvent.ExitFeedsEdit) }, + selectedFeedChanged = { + coroutineScope.launch { + listState.scrollToItem(0) + featuredPostsPagerState.scrollToPage(0) + } + } ) }, snackbarHost = {