Fixed messages marked as read even when conversation is not visible

This commit is contained in:
Sylvain Berfini 2021-06-10 16:39:38 +02:00
parent bce660fbdd
commit e2a04f2e95

View file

@ -23,6 +23,7 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import java.util.*
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.core.*
import org.linphone.core.tools.Log
import org.linphone.mediastream.Version
@ -56,7 +57,10 @@ class ChatMessagesListViewModel(private val chatRoom: ChatRoom) : ViewModel() {
private val chatRoomListener: ChatRoomListenerStub = object : ChatRoomListenerStub() {
override fun onChatMessageReceived(chatRoom: ChatRoom, eventLog: EventLog) {
// Do not mark as read if DetailChatRoomFragment was opened before app was put in background
if (coreContext.notificationsManager.currentlyDisplayedChatRoomAddress == chatRoom.peerAddress.asStringUriOnly()) {
chatRoom.markAsRead()
}
if (eventLog.type == EventLog.Type.ConferenceChatMessage) {
val chatMessage = eventLog.chatMessage