Fix reload of chat rooms when toggling one of the two hide chat room setting
This commit is contained in:
parent
0d363a6868
commit
8f291145d2
9 changed files with 28 additions and 3 deletions
|
@ -141,7 +141,7 @@ class ChatRoomsListViewModel : MessageNotifierViewModel() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateChatRooms() {
|
fun updateChatRooms() {
|
||||||
chatRooms.value.orEmpty().forEach(ChatRoomViewModel::destroy)
|
chatRooms.value.orEmpty().forEach(ChatRoomViewModel::destroy)
|
||||||
|
|
||||||
val list = arrayListOf<ChatRoomViewModel>()
|
val list = arrayListOf<ChatRoomViewModel>()
|
||||||
|
|
|
@ -26,6 +26,7 @@ import android.provider.Settings
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import org.linphone.R
|
import org.linphone.R
|
||||||
|
import org.linphone.activities.main.chat.viewmodels.ChatRoomsListViewModel
|
||||||
import org.linphone.activities.main.settings.viewmodels.ChatSettingsViewModel
|
import org.linphone.activities.main.settings.viewmodels.ChatSettingsViewModel
|
||||||
import org.linphone.activities.navigateToEmptySetting
|
import org.linphone.activities.navigateToEmptySetting
|
||||||
import org.linphone.compatibility.Compatibility
|
import org.linphone.compatibility.Compatibility
|
||||||
|
@ -81,6 +82,12 @@ class ChatSettingsFragment : GenericSettingFragment<SettingsChatFragmentBinding>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewModel.reloadChatRoomsEvent.observe(viewLifecycleOwner) {
|
||||||
|
it.consume {
|
||||||
|
reloadChatRooms()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun goBack() {
|
override fun goBack() {
|
||||||
|
@ -90,4 +97,11 @@ class ChatSettingsFragment : GenericSettingFragment<SettingsChatFragmentBinding>
|
||||||
navigateToEmptySetting()
|
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() {
|
val hideEmptyRoomsListener = object : SettingListenerStub() {
|
||||||
override fun onBoolValueChanged(newValue: Boolean) {
|
override fun onBoolValueChanged(newValue: Boolean) {
|
||||||
prefs.hideEmptyRooms = newValue
|
prefs.hideEmptyRooms = newValue
|
||||||
|
reloadChatRoomsEvent.value = Event(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val hideEmptyRooms = MutableLiveData<Boolean>()
|
val hideEmptyRooms = MutableLiveData<Boolean>()
|
||||||
|
@ -123,6 +124,7 @@ class ChatSettingsViewModel : GenericSettingsViewModel() {
|
||||||
val hideRoomsRemovedProxiesListener = object : SettingListenerStub() {
|
val hideRoomsRemovedProxiesListener = object : SettingListenerStub() {
|
||||||
override fun onBoolValueChanged(newValue: Boolean) {
|
override fun onBoolValueChanged(newValue: Boolean) {
|
||||||
prefs.hideRoomsFromRemovedProxies = newValue
|
prefs.hideRoomsFromRemovedProxies = newValue
|
||||||
|
reloadChatRoomsEvent.value = Event(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val hideRoomsRemovedProxies = MutableLiveData<Boolean>()
|
val hideRoomsRemovedProxies = MutableLiveData<Boolean>()
|
||||||
|
@ -136,6 +138,10 @@ class ChatSettingsViewModel : GenericSettingsViewModel() {
|
||||||
|
|
||||||
val vfs = MutableLiveData<Boolean>()
|
val vfs = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
|
val reloadChatRoomsEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||||
|
MutableLiveData<Event<Boolean>>()
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
markAsReadNotifDismissal.value = prefs.markAsReadUponChatMessageNotificationDismissal
|
markAsReadNotifDismissal.value = prefs.markAsReadUponChatMessageNotificationDismissal
|
||||||
downloadedMediaPublic.value = prefs.makePublicMediaFilesDownloaded && !prefs.vfsEnabled
|
downloadedMediaPublic.value = prefs.makePublicMediaFilesDownloaded && !prefs.vfsEnabled
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/assistant_nav_graph"
|
||||||
app:startDestination="@id/welcomeFragment">
|
app:startDestination="@id/welcomeFragment">
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
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">
|
app:startDestination="@id/emptyChatFragment">
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/contacts_nav_graph"
|
||||||
app:startDestination="@id/emptyContactFragment">
|
app:startDestination="@id/emptyContactFragment">
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
|
@ -25,7 +26,7 @@
|
||||||
|
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_detailContactFragment_to_detailChatRoomFragment"
|
android:id="@+id/action_detailContactFragment_to_detailChatRoomFragment"
|
||||||
app:destination="@id/chat_nav_graph.xml" />
|
app:destination="@id/chat_nav_graph" />
|
||||||
</fragment>
|
</fragment>
|
||||||
|
|
||||||
<action
|
<action
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/history_nav_graph"
|
||||||
app:startDestination="@id/emptyCallHistoryFragment">
|
app:startDestination="@id/emptyCallHistoryFragment">
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/main_nav_graph"
|
||||||
app:startDestination="@id/dialerFragment">
|
app:startDestination="@id/dialerFragment">
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/settings_nav_graph"
|
||||||
app:startDestination="@id/emptySettingsFragment">
|
app:startDestination="@id/emptySettingsFragment">
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
|
|
Loading…
Reference in a new issue