Commit db2ce910 authored by Sylvain Berfini's avatar Sylvain Berfini :cow:
Browse files

Fixed pre-selected contacts not having the checkmark in participants list edition

Showing with 19 additions and 3 deletions
......@@ -81,13 +81,14 @@ class AddParticipantsFragment : GenericAddressPickerFragment() {
setupRecyclerView(binding.contactsList)
val participants = args.selectedParticipants
if (!participants.isNullOrEmpty()) {
viewModel.addSelectedParticipants(participants)
}
viewModel.modelsList.observe(
viewLifecycleOwner
) {
if (!participants.isNullOrEmpty()) {
viewModel.addSelectedParticipants(participants)
}
Log.i("$TAG Contacts & suggestions list is ready with [${it.size}] items")
adapter.submitList(it)
......
......@@ -23,6 +23,7 @@ import androidx.annotation.UiThread
import androidx.lifecycle.MutableLiveData
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.R
import org.linphone.core.Address
import org.linphone.core.tools.Log
import org.linphone.ui.main.model.SelectedAddressModel
import org.linphone.utils.AppUtils
......@@ -45,6 +46,7 @@ class AddParticipantsViewModel @UiThread constructor() : AddressSelectionViewMod
coreContext.postOnCoreThread { core ->
Log.i("$TAG Adding [${participants.size}] pre-selected participants")
val list = arrayListOf<SelectedAddressModel>()
val addresses = arrayListOf<Address>()
for (uri in participants) {
val address = core.interpretUrl(uri, false)
......@@ -52,6 +54,7 @@ class AddParticipantsViewModel @UiThread constructor() : AddressSelectionViewMod
Log.e("$TAG Failed to parse participant URI [$uri] as address!")
continue
}
addresses.add(address)
val avatarModel = coreContext.contactsManager.getContactAvatarModelForAddress(
address
......@@ -70,6 +73,7 @@ class AddParticipantsViewModel @UiThread constructor() : AddressSelectionViewMod
)
)
selection.postValue(list)
updateSelectedParticipants(addresses)
}
}
......
......@@ -28,6 +28,7 @@ import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.LinphoneApplication.Companion.corePreferences
import org.linphone.R
import org.linphone.contacts.ContactsManager
import org.linphone.core.Address
import org.linphone.core.ChatRoom
import org.linphone.core.Friend
import org.linphone.core.MagicSearch
......@@ -135,6 +136,16 @@ abstract class AddressSelectionViewModel @UiThread constructor() : DefaultAccoun
)
}
@WorkerThread
fun updateSelectedParticipants(selectedAddresses: List<Address>) {
for (address in selectedAddresses) {
val found = modelsList.value.orEmpty().find {
it.address.weakEqual(address)
}
found?.selected?.postValue(true)
}
}
@WorkerThread
fun addAddressModelToSelection(model: SelectedAddressModel) {
val actual = selection.value.orEmpty()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment