Fixed chat messages not marked as read when chat bubble is opened when they are received
This commit is contained in:
parent
ef6bbbc3c8
commit
835b2dd863
1 changed files with 12 additions and 0 deletions
|
@ -37,6 +37,8 @@ import org.linphone.activities.main.chat.adapters.ChatMessagesListAdapter
|
||||||
import org.linphone.activities.main.chat.viewmodels.*
|
import org.linphone.activities.main.chat.viewmodels.*
|
||||||
import org.linphone.activities.main.viewmodels.ListTopBarViewModel
|
import org.linphone.activities.main.viewmodels.ListTopBarViewModel
|
||||||
import org.linphone.core.ChatRoom
|
import org.linphone.core.ChatRoom
|
||||||
|
import org.linphone.core.ChatRoomListenerStub
|
||||||
|
import org.linphone.core.EventLog
|
||||||
import org.linphone.core.Factory
|
import org.linphone.core.Factory
|
||||||
import org.linphone.core.tools.Log
|
import org.linphone.core.tools.Log
|
||||||
import org.linphone.databinding.ChatBubbleActivityBinding
|
import org.linphone.databinding.ChatBubbleActivityBinding
|
||||||
|
@ -58,6 +60,12 @@ class ChatBubbleActivity : GenericActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val listener = object : ChatRoomListenerStub() {
|
||||||
|
override fun onChatMessageReceived(chatRoom: ChatRoom, eventLog: EventLog) {
|
||||||
|
chatRoom.markAsRead()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
@ -172,6 +180,8 @@ class ChatBubbleActivity : GenericActivity() {
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
|
||||||
|
viewModel.chatRoom.addListener(listener)
|
||||||
|
|
||||||
val peerAddress = viewModel.chatRoom.peerAddress.asStringUriOnly()
|
val peerAddress = viewModel.chatRoom.peerAddress.asStringUriOnly()
|
||||||
coreContext.notificationsManager.currentlyDisplayedChatRoomAddress = peerAddress
|
coreContext.notificationsManager.currentlyDisplayedChatRoomAddress = peerAddress
|
||||||
coreContext.notificationsManager.resetChatNotificationCounterForSipUri(peerAddress)
|
coreContext.notificationsManager.resetChatNotificationCounterForSipUri(peerAddress)
|
||||||
|
@ -184,6 +194,8 @@ class ChatBubbleActivity : GenericActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
|
viewModel.chatRoom.removeListener(listener)
|
||||||
|
|
||||||
coreContext.notificationsManager.currentlyDisplayedChatRoomAddress = null
|
coreContext.notificationsManager.currentlyDisplayedChatRoomAddress = null
|
||||||
|
|
||||||
super.onPause()
|
super.onPause()
|
||||||
|
|
Loading…
Reference in a new issue