Remove redundant total members count parameter from recipient picker callbacks.

This commit is contained in:
jeffrey-signal
2025-12-09 09:26:57 -05:00
committed by Michelle Tang
parent cf04bf8018
commit 6fba1b0153
5 changed files with 10 additions and 14 deletions

View File

@@ -121,7 +121,7 @@ private fun AddMembersScreen(
override fun onFindByUsername() = findByLauncher.launch(FindByMode.USERNAME) override fun onFindByUsername() = findByLauncher.launch(FindByMode.USERNAME)
override fun onFindByPhoneNumber() = findByLauncher.launch(FindByMode.PHONE_NUMBER) override fun onFindByPhoneNumber() = findByLauncher.launch(FindByMode.PHONE_NUMBER)
override suspend fun shouldAllowSelection(selection: RecipientSelection): Boolean = viewModel.shouldAllowSelection(selection) override suspend fun shouldAllowSelection(selection: RecipientSelection): Boolean = viewModel.shouldAllowSelection(selection)
override fun onSelectionChanged(newSelections: List<SelectedContact>, totalMembersCount: Int) = viewModel.onSelectionChanged(newSelections) override fun onSelectionChanged(newSelections: List<SelectedContact>) = viewModel.onSelectionChanged(newSelections)
override fun onPendingRecipientSelectionsConsumed() = viewModel.clearPendingRecipientSelections() override fun onPendingRecipientSelectionsConsumed() = viewModel.clearPendingRecipientSelections()
override fun onDoneClicked() = viewModel.addSelectedMembers() override fun onDoneClicked() = viewModel.addSelectedMembers()
override fun onAddConfirmed(recipientIds: Set<RecipientId>) { override fun onAddConfirmed(recipientIds: Set<RecipientId>) {

View File

@@ -101,7 +101,7 @@ private fun AddToGroupsScreen(
val callbacks = remember { val callbacks = remember {
object : UiCallbacks { object : UiCallbacks {
override fun onSearchQueryChanged(query: String) = viewModel.onSearchQueryChanged(query) override fun onSearchQueryChanged(query: String) = viewModel.onSearchQueryChanged(query)
override fun onSelectionChanged(newSelections: List<SelectedContact>, totalMembersCount: Int) = viewModel.selectGroups(newSelections) override fun onSelectionChanged(newSelections: List<SelectedContact>) = viewModel.selectGroups(newSelections)
override fun addToSelectedGroups() = viewModel.addToSelectedGroups() override fun addToSelectedGroups() = viewModel.addToSelectedGroups()
override fun onAddConfirmed(groupRecipient: Recipient) = viewModel.addToGroups(listOf(groupRecipient)) override fun onAddConfirmed(groupRecipient: Recipient) = viewModel.addToGroups(listOf(groupRecipient))
override fun onUserMessageDismissed(userMessage: UserMessage) = viewModel.clearUserMessage() override fun onUserMessageDismissed(userMessage: UserMessage) = viewModel.clearUserMessage()

View File

@@ -117,7 +117,7 @@ private fun CreateGroupScreen(
override fun onFindByUsername() = findByLauncher.launch(FindByMode.USERNAME) override fun onFindByUsername() = findByLauncher.launch(FindByMode.USERNAME)
override fun onFindByPhoneNumber() = findByLauncher.launch(FindByMode.PHONE_NUMBER) override fun onFindByPhoneNumber() = findByLauncher.launch(FindByMode.PHONE_NUMBER)
override suspend fun shouldAllowSelection(selection: RecipientSelection): Boolean = viewModel.shouldAllowSelection(selection) override suspend fun shouldAllowSelection(selection: RecipientSelection): Boolean = viewModel.shouldAllowSelection(selection)
override fun onSelectionChanged(newSelections: List<SelectedContact>, totalMembersCount: Int) = viewModel.onSelectionChanged(newSelections, totalMembersCount) override fun onSelectionChanged(newSelections: List<SelectedContact>) = viewModel.onSelectionChanged(newSelections)
override fun onPendingRecipientSelectionsConsumed() = viewModel.clearPendingRecipientSelections() override fun onPendingRecipientSelectionsConsumed() = viewModel.clearPendingRecipientSelections()
override fun onNextClicked(): Unit = viewModel.continueToGroupDetails() override fun onNextClicked(): Unit = viewModel.continueToGroupDetails()
override fun onUserMessageDismissed(userMessage: UserMessage) = viewModel.clearUserMessage() override fun onUserMessageDismissed(userMessage: UserMessage) = viewModel.clearUserMessage()
@@ -155,8 +155,8 @@ private fun CreateGroupScreenUi(
val title = if (uiState.newSelections.isNotEmpty()) { val title = if (uiState.newSelections.isNotEmpty()) {
pluralStringResource( pluralStringResource(
id = R.plurals.CreateGroupActivity__s_members, id = R.plurals.CreateGroupActivity__s_members,
count = uiState.totalMembersCount, count = uiState.newSelections.size,
NumberFormat.getInstance().format(uiState.totalMembersCount) NumberFormat.getInstance().format(uiState.newSelections.size)
) )
} else { } else {
stringResource(R.string.CreateGroupActivity__select_members) stringResource(R.string.CreateGroupActivity__select_members)

View File

@@ -62,12 +62,11 @@ class CreateGroupViewModel : ViewModel() {
} }
} }
fun onSelectionChanged(newSelections: List<SelectedContact>, totalMembersCount: Int) { fun onSelectionChanged(newSelections: List<SelectedContact>) {
internalUiState.update { internalUiState.update {
it.copy( it.copy(
searchQuery = "", searchQuery = "",
newSelections = newSelections, newSelections = newSelections
totalMembersCount = totalMembersCount
) )
} }
} }
@@ -125,7 +124,6 @@ data class CreateGroupUiState(
val searchQuery: String = "", val searchQuery: String = "",
val selectionLimits: SelectionLimits = RemoteConfig.groupLimits.excludingSelf(), val selectionLimits: SelectionLimits = RemoteConfig.groupLimits.excludingSelf(),
val newSelections: List<SelectedContact> = emptyList(), val newSelections: List<SelectedContact> = emptyList(),
val totalMembersCount: Int = 0,
val isLookingUpRecipient: Boolean = false, val isLookingUpRecipient: Boolean = false,
val pendingRecipientSelections: Set<RecipientId> = emptySet(), val pendingRecipientSelections: Set<RecipientId> = emptySet(),
val pendingDestination: NavTarget? = null, val pendingDestination: NavTarget? = null,

View File

@@ -213,8 +213,7 @@ private fun RecipientSearchResultsList(
callbacks.listActions.onPendingRecipientSelectionsConsumed() callbacks.listActions.onPendingRecipientSelectionsConsumed()
callbacks.listActions.onSelectionChanged( callbacks.listActions.onSelectionChanged(
newSelections = fragment.selectedContacts, newSelections = fragment.selectedContacts
totalMembersCount = fragment.totalMemberCount
) )
} }
} }
@@ -290,8 +289,7 @@ private fun ContactSelectionListFragment.setUpCallbacks(
override fun onSelectionChanged() { override fun onSelectionChanged() {
callbacks.listActions.onSelectionChanged( callbacks.listActions.onSelectionChanged(
newSelections = fragment.selectedContacts, newSelections = fragment.selectedContacts
totalMembersCount = fragment.totalMemberCount
) )
} }
}) })
@@ -411,7 +409,7 @@ class RecipientPickerCallbacks(
fun onSearchQueryChanged(query: String) fun onSearchQueryChanged(query: String)
suspend fun shouldAllowSelection(selection: RecipientSelection): Boolean suspend fun shouldAllowSelection(selection: RecipientSelection): Boolean
fun onRecipientSelected(selection: RecipientSelection) fun onRecipientSelected(selection: RecipientSelection)
fun onSelectionChanged(newSelections: List<SelectedContact>, totalMembersCount: Int) = Unit fun onSelectionChanged(newSelections: List<SelectedContact>) = Unit
fun onPendingRecipientSelectionsConsumed() = Unit fun onPendingRecipientSelectionsConsumed() = Unit
fun onContactsListReset() = Unit fun onContactsListReset() = Unit