mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Clicking on already selected contact will remove it from the selection
This commit is contained in:
parent
c88917ac68
commit
135ca527ee
2 changed files with 19 additions and 2 deletions
|
|
@ -147,6 +147,23 @@ abstract class GenericAddressPickerFragment : GenericMainFragment() {
|
|||
}
|
||||
|
||||
private fun handleClickOnContactModel(model: ConversationContactOrSuggestionModel) {
|
||||
if (model.selected.value == true) {
|
||||
Log.i(
|
||||
"$TAG User clicked on already selected item [${model.name}], removing it from selection"
|
||||
)
|
||||
val found = viewModel.selection.value.orEmpty().find {
|
||||
it.address.weakEqual(model.address) || it.avatarModel?.friend == model.friend
|
||||
}
|
||||
if (found != null) {
|
||||
coreContext.postOnCoreThread {
|
||||
viewModel.removeAddressModelFromSelection(found)
|
||||
}
|
||||
return
|
||||
} else {
|
||||
Log.e("$TAG Failed to find already selected entry matching the one clicked")
|
||||
}
|
||||
}
|
||||
|
||||
coreContext.postOnCoreThread { core ->
|
||||
val friend = model.friend
|
||||
if (friend == null) {
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ abstract class AddressSelectionViewModel @UiThread constructor() : DefaultAccoun
|
|||
list.addAll(actual)
|
||||
|
||||
val found = modelsList.value.orEmpty().find {
|
||||
it.address.weakEqual(model.address)
|
||||
it.address.weakEqual(model.address) || it.friend == model.avatarModel?.friend
|
||||
}
|
||||
found?.selected?.postValue(true)
|
||||
|
||||
|
|
@ -191,7 +191,7 @@ abstract class AddressSelectionViewModel @UiThread constructor() : DefaultAccoun
|
|||
list.remove(model)
|
||||
|
||||
val found = modelsList.value.orEmpty().find {
|
||||
it.address.weakEqual(model.address)
|
||||
it.address.weakEqual(model.address) || it.friend == model.avatarModel?.friend
|
||||
}
|
||||
found?.selected?.postValue(false)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue