android: keep read ack strictly bounded by visible incoming messages
This commit is contained in:
@@ -714,3 +714,8 @@
|
||||
- Improved cross-device sync (web <-> android):
|
||||
- `message_read` realtime event now parses `user_id` and `last_read_message_id`.
|
||||
- on `message_read`, Android refreshes chat snapshot from backend to keep unread counters aligned across devices.
|
||||
|
||||
### Step 108 - Strict read boundary by visible incoming only
|
||||
- Removed fallback read-pointer advancement in `ChatViewModel.acknowledgeLatestMessages(...)` that previously moved `lastReadMessageId` by latest loaded message id.
|
||||
- Read pointer is now advanced only via `onVisibleIncomingMessageId(...)` from visible incoming rows in `ChatScreen`.
|
||||
- This prevents read acknowledgements from overshooting beyond what user actually saw during refresh/recompose scenarios.
|
||||
|
||||
@@ -656,7 +656,6 @@ class ChatViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
private fun acknowledgeLatestMessages(messages: List<MessageItem>) {
|
||||
val latestVisible = messages.maxByOrNull { it.id } ?: return
|
||||
val latestIncoming = messages.asReversed().firstOrNull { !it.isOutgoing }
|
||||
|
||||
if (latestIncoming != null && lastDeliveredMessageId != latestIncoming.id) {
|
||||
@@ -665,9 +664,6 @@ class ChatViewModel @Inject constructor(
|
||||
markMessageDeliveredUseCase(chatId = chatId, messageId = latestIncoming.id)
|
||||
}
|
||||
}
|
||||
if ((lastReadMessageId ?: 0L) < latestVisible.id) {
|
||||
lastReadMessageId = latestVisible.id
|
||||
}
|
||||
}
|
||||
|
||||
fun canEdit(message: MessageItem): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user