fix: reduce heavy realtime refreshes
Some checks failed
Android CI / android (push) Has started running
Android Release / release (push) Has been cancelled
CI / test (push) Has been cancelled

fix: reconcile deleted and read messages with targeted chat updates
This commit is contained in:
2026-04-05 14:55:32 +03:00
parent ee5df806c1
commit a8be41c55e

View File

@@ -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)
}