Фикс: откат агрессивной проверки в updateMessageStatusInDb — ломала все статусы
All checks were successful
Android Kernel Build / build (push) Successful in 19m55s

Оставлена защита только в updateMessageStatusAndAttachmentsInDb (для фото race condition).
findMessageById обёрнут в отдельный try/catch чтобы ошибка в нём не блокировала основной update.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-09 01:11:48 +05:00
parent d94b3ec37a
commit d02f03516c

View File

@@ -724,9 +724,6 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
private suspend fun updateMessageStatusInDb(messageId: String, delivered: Int) { private suspend fun updateMessageStatusInDb(messageId: String, delivered: Int) {
val account = myPublicKey ?: return val account = myPublicKey ?: return
try { try {
// Never downgrade delivery status
val existing = messageDao.findMessageById(account, messageId)
if (existing != null && existing.delivered > delivered) return
messageDao.updateDeliveryStatus(account, messageId, delivered) messageDao.updateDeliveryStatus(account, messageId, delivered)
} catch (e: Exception) {} } catch (e: Exception) {}
} }
@@ -740,8 +737,11 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
val account = myPublicKey ?: return val account = myPublicKey ?: return
try { try {
// Never downgrade delivery status (e.g. DELIVERED→WAITING race) // Never downgrade delivery status (e.g. DELIVERED→WAITING race)
val existing = messageDao.findMessageById(account, messageId) val safeDelivered = try {
val safeDelivered = if (existing != null && existing.delivered > delivered) existing.delivered else delivered val existing = messageDao.findMessageById(account, messageId)
if (existing != null && existing.delivered > delivered) existing.delivered else delivered
} catch (_: Exception) { delivered }
messageDao.updateDeliveryStatusAndAttachments( messageDao.updateDeliveryStatusAndAttachments(
account, account,
messageId, messageId,