Skip to content

Commit

Permalink
Check ID instead of entire source object when toggling source selection
Browse files Browse the repository at this point in the history
  • Loading branch information
msasikanth committed Apr 30, 2024
1 parent 15cf446 commit 8cee489
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,10 @@ class FeedsPresenter(
private fun onToggleSourceSelection(source: Source) {
_state.update {
val selectedFeeds = _state.value.selectedSources
if (selectedFeeds.contains(source)) {
it.copy(selectedSources = selectedFeeds - setOf(source))
if (selectedFeeds.any { selectedFeed -> selectedFeed.id == source.id }) {
it.copy(
selectedSources = selectedFeeds.filterNot { feed -> feed.id == source.id }.toSet()
)
} else {
it.copy(selectedSources = selectedFeeds + setOf(source))
}
Expand Down

0 comments on commit 8cee489

Please sign in to comment.