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 onFindByPhoneNumber() = findByLauncher.launch(FindByMode.PHONE_NUMBER)
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 onDoneClicked() = viewModel.addSelectedMembers()
override fun onAddConfirmed(recipientIds: Set<RecipientId>) {

View File

@@ -101,7 +101,7 @@ private fun AddToGroupsScreen(
val callbacks = remember {
object : UiCallbacks {
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 onAddConfirmed(groupRecipient: Recipient) = viewModel.addToGroups(listOf(groupRecipient))
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 onFindByPhoneNumber() = findByLauncher.launch(FindByMode.PHONE_NUMBER)
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 onNextClicked(): Unit = viewModel.continueToGroupDetails()
override fun onUserMessageDismissed(userMessage: UserMessage) = viewModel.clearUserMessage()
@@ -155,8 +155,8 @@ private fun CreateGroupScreenUi(
val title = if (uiState.newSelections.isNotEmpty()) {
pluralStringResource(
id = R.plurals.CreateGroupActivity__s_members,
count = uiState.totalMembersCount,
NumberFormat.getInstance().format(uiState.totalMembersCount)
count = uiState.newSelections.size,
NumberFormat.getInstance().format(uiState.newSelections.size)
)
} else {
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 {
it.copy(
searchQuery = "",
newSelections = newSelections,
totalMembersCount = totalMembersCount
newSelections = newSelections
)
}
}
@@ -125,7 +124,6 @@ data class CreateGroupUiState(
val searchQuery: String = "",
val selectionLimits: SelectionLimits = RemoteConfig.groupLimits.excludingSelf(),
val newSelections: List<SelectedContact> = emptyList(),
val totalMembersCount: Int = 0,
val isLookingUpRecipient: Boolean = false,
val pendingRecipientSelections: Set<RecipientId> = emptySet(),
val pendingDestination: NavTarget? = null,

View File

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