android: sync pin and archive changes immediately on chat_updated
Some checks failed
Android CI / android (push) Has been cancelled
Android Release / release (push) Has been cancelled
CI / test (push) Has been cancelled

This commit is contained in:
Codex
2026-03-09 22:28:56 +03:00
parent f005b3f222
commit c040ebf059
3 changed files with 13 additions and 3 deletions

View File

@@ -629,3 +629,8 @@
- pin/unpin selected chats,
- clear selected chats,
- delete selected chats for current user.
### Step 98 - Realtime sync fix for pin/archive updates
- Improved `chat_updated` handling in realtime flow:
- now refreshes both active and archived chats lists to sync user-scoped flags (`pinned`, `archived`) immediately.
- Added parser fallback for realtime chat events to support payloads with either `chat_id` or `id`.

View File

@@ -67,12 +67,16 @@ class RealtimeEventParser @Inject constructor(
}
"chat_updated" -> {
val chatId = payload["chat_id"].longOrNull() ?: return RealtimeEvent.Ignored
val chatId = payload["chat_id"].longOrNull()
?: payload["id"].longOrNull()
?: return RealtimeEvent.Ignored
RealtimeEvent.ChatUpdated(chatId = chatId)
}
"chat_deleted" -> {
val chatId = payload["chat_id"].longOrNull() ?: return RealtimeEvent.Ignored
val chatId = payload["chat_id"].longOrNull()
?: payload["id"].longOrNull()
?: return RealtimeEvent.Ignored
RealtimeEvent.ChatDeleted(chatId = chatId)
}

View File

@@ -132,7 +132,8 @@ class HandleRealtimeEventsUseCase @Inject constructor(
}
is RealtimeEvent.ChatUpdated -> {
chatRepository.refreshChat(chatId = event.chatId)
chatRepository.refreshChats(archived = false)
chatRepository.refreshChats(archived = true)
}
is RealtimeEvent.ChatDeleted -> {