From 703bcb2003b8d927b518364410d71f18a5e79f55 Mon Sep 17 00:00:00 2001 From: Sasikanth Miriyampalli Date: Sat, 27 Apr 2024 21:06:05 +0530 Subject: [PATCH] Clear active source if deleted sources contains active source --- .../dev/sasikanth/rss/reader/feeds/FeedsPresenter.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 1e21ac750..4b959019a 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 @@ -216,7 +216,12 @@ class FeedsPresenter( private fun onDeleteSelectedSources() { coroutineScope .launch { rssRepository.deleteSources(_state.value.selectedSources) } - .invokeOnCompletion { dispatch(FeedsEvent.CancelSourcesSelection) } + .invokeOnCompletion { + if (_state.value.selectedSources.any { it.id == _state.value.activeSource?.id }) { + _state.update { it.copy(activeSource = null) } + } + dispatch(FeedsEvent.CancelSourcesSelection) + } } private fun onCancelSourcesSelection() {