From d02f03516c7c6e0527756ff097bf6ce2202bf776 Mon Sep 17 00:00:00 2001 From: k1ngsterr1 Date: Thu, 9 Apr 2026 01:11:48 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81:=20=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=B0=D1=82=20=D0=B0=D0=B3=D1=80=D0=B5=D1=81=D1=81=D0=B8=D0=B2?= =?UTF-8?q?=D0=BD=D0=BE=D0=B9=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B2=20updateMessageStatusInDb=20=E2=80=94=20=D0=BB?= =?UTF-8?q?=D0=BE=D0=BC=D0=B0=D0=BB=D0=B0=20=D0=B2=D1=81=D0=B5=20=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D1=82=D1=83=D1=81=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Оставлена защита только в updateMessageStatusAndAttachmentsInDb (для фото race condition). findMessageById обёрнут в отдельный try/catch чтобы ошибка в нём не блокировала основной update. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../com/rosetta/messenger/ui/chats/ChatViewModel.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/rosetta/messenger/ui/chats/ChatViewModel.kt b/app/src/main/java/com/rosetta/messenger/ui/chats/ChatViewModel.kt index 6a227eb..8231702 100644 --- a/app/src/main/java/com/rosetta/messenger/ui/chats/ChatViewModel.kt +++ b/app/src/main/java/com/rosetta/messenger/ui/chats/ChatViewModel.kt @@ -724,9 +724,6 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) { private suspend fun updateMessageStatusInDb(messageId: String, delivered: Int) { val account = myPublicKey ?: return try { - // Never downgrade delivery status - val existing = messageDao.findMessageById(account, messageId) - if (existing != null && existing.delivered > delivered) return messageDao.updateDeliveryStatus(account, messageId, delivered) } catch (e: Exception) {} } @@ -740,8 +737,11 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) { val account = myPublicKey ?: return try { // Never downgrade delivery status (e.g. DELIVERED→WAITING race) - val existing = messageDao.findMessageById(account, messageId) - val safeDelivered = if (existing != null && existing.delivered > delivered) existing.delivered else delivered + val safeDelivered = try { + val existing = messageDao.findMessageById(account, messageId) + if (existing != null && existing.delivered > delivered) existing.delivered else delivered + } catch (_: Exception) { delivered } + messageDao.updateDeliveryStatusAndAttachments( account, messageId,