mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 19:38:08 +00:00
Fixed favourite status in contacts list not matching reality after a change
This commit is contained in:
parent
9070b77b30
commit
3e7e2000d5
4 changed files with 9 additions and 4 deletions
|
|
@ -143,6 +143,7 @@ class ContactsListAdapter(
|
|||
|
||||
override fun areContentsTheSame(oldItem: ContactAvatarModel, newItem: ContactAvatarModel): Boolean {
|
||||
return oldItem.presenceStatus.value == newItem.presenceStatus.value &&
|
||||
oldItem.isFavourite.value == newItem.isFavourite.value &&
|
||||
(newItem.presenceStatus.value == ConsolidatedPresence.Busy || newItem.presenceStatus.value == ConsolidatedPresence.Online)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ class ContactsListFragment : AbstractTopBarFragment() {
|
|||
adapter.contactLongClickedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { model ->
|
||||
val modalBottomSheet = ContactsListMenuDialogFragment(
|
||||
model.starred,
|
||||
model.isFavourite.value == true,
|
||||
{ // onDismiss
|
||||
adapter.resetSelection()
|
||||
},
|
||||
|
|
@ -211,7 +211,7 @@ class ContactsListFragment : AbstractTopBarFragment() {
|
|||
model.friend.edit()
|
||||
val starred = !model.friend.starred
|
||||
Log.i(
|
||||
"$TAG Friend [${model.name.value}] will be ${if (starred) "added" else "removed"} from favourites"
|
||||
"$TAG Friend [${model.name.value}] will be ${if (starred) "added to" else "removed from"} favourites"
|
||||
)
|
||||
model.friend.starred = starred
|
||||
model.friend.done()
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class ContactAvatarModel @WorkerThread constructor(val friend: Friend) : Abstrac
|
|||
|
||||
val contactName = friend.name
|
||||
|
||||
val starred = friend.starred
|
||||
val isFavourite = MutableLiveData<Boolean>()
|
||||
|
||||
val lastPresenceInfo = MutableLiveData<String>()
|
||||
|
||||
|
|
@ -69,6 +69,7 @@ class ContactAvatarModel @WorkerThread constructor(val friend: Friend) : Abstrac
|
|||
friend.addListener(friendListener)
|
||||
}
|
||||
|
||||
isFavourite.postValue(friend.starred)
|
||||
initials.postValue(AppUtils.getInitials(friend.name.orEmpty()))
|
||||
trust.postValue(SecurityLevel.Encrypted) // TODO FIXME: use API
|
||||
showTrust.postValue(coreContext.core.defaultAccount?.isInSecureMode())
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ class ContactsListViewModel @UiThread constructor() : AbstractTopBarViewModel()
|
|||
@WorkerThread
|
||||
override fun onContactsLoaded() {
|
||||
Log.i("$TAG Contacts have been (re)loaded, updating list")
|
||||
magicSearch.resetSearchCache()
|
||||
applyFilter(
|
||||
currentFilter,
|
||||
if (limitSearchToLinphoneAccounts) corePreferences.defaultDomain else "",
|
||||
|
|
@ -226,7 +227,9 @@ class ContactsListViewModel @UiThread constructor() : AbstractTopBarViewModel()
|
|||
list.add(model)
|
||||
count += 1
|
||||
|
||||
if (friend?.starred == true) {
|
||||
val starred = friend?.starred ?: false
|
||||
model.isFavourite.postValue(starred)
|
||||
if (starred) {
|
||||
favouritesList.add(model)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue