Skip to content

Commit

Permalink
Fix duplicate contacts during story selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtang-signal authored and greyson-signal committed Dec 12, 2024
1 parent 010c45d commit dadf782
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ abstract class BaseStoryRecipientSelectionFragment : Fragment(R.layout.stories_b

viewModel.state.observe(viewLifecycleOwner) {
if (it.distributionListId == null || it.privateStory != null) {
getAttachedContactSelectionFragment().markSelected(it.selection.toSet())
if (it.isStartingSelection) {
getAttachedContactSelectionFragment().markSelected(it.selection.toSet())
viewModel.onStartingSelectionAdded()
}
presentTitle(toolbar, it.selection.size)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ import org.thoughtcrime.securesms.recipients.RecipientId
data class BaseStoryRecipientSelectionState(
val distributionListId: DistributionListId?,
val privateStory: DistributionListRecord? = null,
val selection: Set<RecipientId> = emptySet()
val selection: Set<RecipientId> = emptySet(),
val isStartingSelection: Boolean = false
)
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BaseStoryRecipientSelectionViewModel(
disposable += repository.getRecord(distributionListId)
.subscribe { record ->
val startingSelection = if (record.privacyMode == DistributionListPrivacyMode.ALL_EXCEPT) record.rawMembers else record.members
store.update { it.copy(privateStory = record, selection = it.selection + startingSelection) }
store.update { it.copy(privateStory = record, selection = it.selection + startingSelection, isStartingSelection = true) }
}
}
}
Expand Down Expand Up @@ -61,6 +61,10 @@ class BaseStoryRecipientSelectionViewModel(
}
}

fun onStartingSelectionAdded() {
store.update { it.copy(isStartingSelection = false) }
}

sealed class Action {
data class GoToNextScreen(val recipients: Set<RecipientId>) : Action()
object ExitFlow : Action()
Expand Down

0 comments on commit dadf782

Please sign in to comment.