fix: reduce heavy realtime refreshes
fix: reconcile deleted and read messages with targeted chat updates
This commit is contained in:
@@ -161,14 +161,15 @@ class HandleRealtimeEventsUseCase @Inject constructor(
|
||||
|
||||
is RealtimeEvent.MessageDeleted -> {
|
||||
event.messageId?.let { messageDao.deleteMessage(it) }
|
||||
chatRepository.refreshChats(archived = false)
|
||||
chatRepository.refreshChats(archived = true)
|
||||
if (activeChatTracker.activeChatId.value == event.chatId) {
|
||||
messageRepository.syncRecentMessages(chatId = event.chatId)
|
||||
chatDao.markChatRead(chatId = event.chatId)
|
||||
}
|
||||
chatRepository.refreshChat(chatId = event.chatId)
|
||||
}
|
||||
|
||||
is RealtimeEvent.ChatUpdated -> {
|
||||
chatRepository.refreshChat(chatId = event.chatId)
|
||||
chatRepository.refreshChats(archived = false)
|
||||
chatRepository.refreshChats(archived = true)
|
||||
}
|
||||
|
||||
is RealtimeEvent.ChatDeleted -> {
|
||||
@@ -203,6 +204,9 @@ class HandleRealtimeEventsUseCase @Inject constructor(
|
||||
messageId = event.messageId,
|
||||
status = "read",
|
||||
)
|
||||
if (activeChatTracker.activeChatId.value == event.chatId) {
|
||||
chatDao.markChatRead(chatId = event.chatId)
|
||||
}
|
||||
chatRepository.refreshChat(chatId = event.chatId)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user