mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-14 00:05:04 +01:00
Improve loading on rotation
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
e88b49b506
commit
d74bc116ba
@ -67,7 +67,6 @@ class ContactsView<T : Any>(private val bundle: Bundle? = null) : BaseView() {
|
||||
setHasOptionsMenu(true)
|
||||
|
||||
viewModel = viewModelProvider(factory).get(ContactsViewModel::class.java)
|
||||
viewModel.conversationToken = bundle?.getString(BundleKeys.KEY_CONVERSATION_TOKEN)
|
||||
val view = super.onCreateView(inflater, container)
|
||||
|
||||
// todo - change empty state magic
|
||||
@ -137,7 +136,7 @@ class ContactsView<T : Any>(private val bundle: Bundle? = null) : BaseView() {
|
||||
|
||||
}
|
||||
|
||||
viewModel.loadContacts()
|
||||
viewModel.initialize(bundle?.getString(BundleKeys.KEY_CONVERSATION_TOKEN))
|
||||
|
||||
return view
|
||||
}
|
||||
|
@ -44,7 +44,15 @@ class ContactsViewModel constructor(
|
||||
val contactsLiveData: MutableLiveData<List<Participant>> = MutableLiveData()
|
||||
|
||||
private var searchQuery: String? = null
|
||||
var conversationToken: String? = null
|
||||
private var conversationToken: String? = null
|
||||
private var initialized = false
|
||||
|
||||
fun initialize(conversationToken: String?) {
|
||||
if (!initialized || conversationToken != this.conversationToken) {
|
||||
this.conversationToken = conversationToken
|
||||
loadContacts()
|
||||
}
|
||||
}
|
||||
|
||||
fun setSearchQuery(query: String?) {
|
||||
searchQuery = query
|
||||
@ -77,6 +85,13 @@ class ContactsViewModel constructor(
|
||||
it.displayName.toLowerCase()
|
||||
}))
|
||||
|
||||
val selectedUserIds = selectedParticipants.map { it.userId }
|
||||
for (participant in sortedList) {
|
||||
if (participant.userId in selectedUserIds) {
|
||||
participant.selected = true
|
||||
}
|
||||
}
|
||||
|
||||
contactsLiveData.postValue(sortedList)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user