android: sync pin and archive changes immediately on chat_updated
This commit is contained in:
@@ -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`.
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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 -> {
|
||||
|
||||
Reference in New Issue
Block a user