mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Fix crash when selecting a group to add a recipient.
This commit is contained in:
committed by
Alex Hart
parent
2c4d3b3ee4
commit
b81c1eb65c
@@ -43,6 +43,7 @@ class ContactSearchMediator(
|
||||
private val fragment: Fragment,
|
||||
private val fixedContacts: Set<ContactSearchKey> = setOf(),
|
||||
selectionLimits: SelectionLimits,
|
||||
private val isMultiSelect: Boolean = true,
|
||||
displayOptions: ContactSearchAdapter.DisplayOptions,
|
||||
mapStateToConfiguration: (ContactSearchState) -> ContactSearchConfiguration,
|
||||
private val callbacks: Callbacks = SimpleCallbacks(),
|
||||
@@ -61,6 +62,7 @@ class ContactSearchMediator(
|
||||
fragment,
|
||||
ContactSearchViewModel.Factory(
|
||||
selectionLimits = selectionLimits,
|
||||
isMultiSelect = isMultiSelect,
|
||||
repository = ContactSearchRepository(),
|
||||
performSafetyNumberChecks = performSafetyNumberChecks,
|
||||
arbitraryRepository = arbitraryRepository,
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.whispersystems.signalservice.api.util.Preconditions
|
||||
class ContactSearchViewModel(
|
||||
private val savedStateHandle: SavedStateHandle,
|
||||
private val selectionLimits: SelectionLimits,
|
||||
private val isMultiSelect: Boolean,
|
||||
private val contactSearchRepository: ContactSearchRepository,
|
||||
private val performSafetyNumberChecks: Boolean,
|
||||
private val arbitraryRepository: ArbitraryRepository?,
|
||||
@@ -116,7 +117,11 @@ class ContactSearchViewModel(
|
||||
safetyNumberRepository.batchSafetyNumberCheck(newSelectionEntries)
|
||||
}
|
||||
|
||||
internalSelectedContacts.update { it + newSelectionEntries }
|
||||
if (!isMultiSelect && newSelectionEntries.isNotEmpty()) {
|
||||
internalSelectedContacts.update { newSelectionEntries.toSet() }
|
||||
} else {
|
||||
internalSelectedContacts.update { it + newSelectionEntries }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,6 +177,7 @@ class ContactSearchViewModel(
|
||||
|
||||
class Factory(
|
||||
private val selectionLimits: SelectionLimits,
|
||||
private val isMultiSelect: Boolean = true,
|
||||
private val repository: ContactSearchRepository,
|
||||
private val performSafetyNumberChecks: Boolean,
|
||||
private val arbitraryRepository: ArbitraryRepository?,
|
||||
@@ -183,6 +189,7 @@ class ContactSearchViewModel(
|
||||
ContactSearchViewModel(
|
||||
savedStateHandle = handle,
|
||||
selectionLimits = selectionLimits,
|
||||
isMultiSelect = isMultiSelect,
|
||||
contactSearchRepository = repository,
|
||||
performSafetyNumberChecks = performSafetyNumberChecks,
|
||||
arbitraryRepository = arbitraryRepository,
|
||||
|
||||
Reference in New Issue
Block a user