mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Fix reload of chat rooms when toggling one of the two hide chat room setting
This commit is contained in:
parent
bad25d102b
commit
0da5d6d157
5 changed files with 23 additions and 3 deletions
|
|
@ -141,7 +141,7 @@ class ChatRoomsListViewModel : ErrorReportingViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun updateChatRooms() {
|
||||
fun updateChatRooms() {
|
||||
chatRooms.value.orEmpty().forEach(ChatRoomViewModel::destroy)
|
||||
|
||||
val list = arrayListOf<ChatRoomViewModel>()
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import android.provider.Settings
|
|||
import android.view.View
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import org.linphone.R
|
||||
import org.linphone.activities.main.chat.viewmodels.ChatRoomsListViewModel
|
||||
import org.linphone.activities.main.settings.viewmodels.ChatSettingsViewModel
|
||||
import org.linphone.activities.navigateToEmptySetting
|
||||
import org.linphone.compatibility.Compatibility
|
||||
|
|
@ -81,6 +82,12 @@ class ChatSettingsFragment : GenericSettingFragment<SettingsChatFragmentBinding>
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.reloadChatRoomsEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
reloadChatRooms()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun goBack() {
|
||||
|
|
@ -90,4 +97,11 @@ class ChatSettingsFragment : GenericSettingFragment<SettingsChatFragmentBinding>
|
|||
navigateToEmptySetting()
|
||||
}
|
||||
}
|
||||
|
||||
private fun reloadChatRooms() {
|
||||
val listViewModel = requireActivity().run {
|
||||
ViewModelProvider(this)[ChatRoomsListViewModel::class.java]
|
||||
}
|
||||
listViewModel.updateChatRooms()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ class ChatSettingsViewModel : GenericSettingsViewModel() {
|
|||
val hideEmptyRoomsListener = object : SettingListenerStub() {
|
||||
override fun onBoolValueChanged(newValue: Boolean) {
|
||||
prefs.hideEmptyRooms = newValue
|
||||
reloadChatRoomsEvent.value = Event(true)
|
||||
}
|
||||
}
|
||||
val hideEmptyRooms = MutableLiveData<Boolean>()
|
||||
|
|
@ -123,6 +124,7 @@ class ChatSettingsViewModel : GenericSettingsViewModel() {
|
|||
val hideRoomsRemovedProxiesListener = object : SettingListenerStub() {
|
||||
override fun onBoolValueChanged(newValue: Boolean) {
|
||||
prefs.hideRoomsFromRemovedProxies = newValue
|
||||
reloadChatRoomsEvent.value = Event(true)
|
||||
}
|
||||
}
|
||||
val hideRoomsRemovedProxies = MutableLiveData<Boolean>()
|
||||
|
|
@ -136,6 +138,10 @@ class ChatSettingsViewModel : GenericSettingsViewModel() {
|
|||
|
||||
val vfs = MutableLiveData<Boolean>()
|
||||
|
||||
val reloadChatRoomsEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
init {
|
||||
markAsReadNotifDismissal.value = prefs.markAsReadUponChatMessageNotificationDismissal
|
||||
downloadedMediaPublic.value = prefs.makePublicMediaFilesDownloaded && !prefs.vfsEnabled
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/chat_nav_graph.xml"
|
||||
android:id="@+id/chat_nav_graph"
|
||||
app:startDestination="@id/emptyChatFragment">
|
||||
|
||||
<fragment
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
<action
|
||||
android:id="@+id/action_detailContactFragment_to_detailChatRoomFragment"
|
||||
app:destination="@id/chat_nav_graph.xml" />
|
||||
app:destination="@id/chat_nav_graph" />
|
||||
</fragment>
|
||||
|
||||
<action
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue