feat: improve message delivery status handling and UI indicators in chat screens

This commit is contained in:
2026-03-02 11:35:03 +05:00
parent 7bf3db52a6
commit 6d379148b0
2 changed files with 31 additions and 26 deletions

View File

@@ -396,6 +396,7 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
val currentDialogKey = getDialogKey(account, opponent) val currentDialogKey = getDialogKey(account, opponent)
if (update.dialogKey == currentDialogKey) { if (update.dialogKey == currentDialogKey) {
if (!isDialogActive) return@collect
when (update.status) { when (update.status) {
DeliveryStatus.DELIVERED -> { DeliveryStatus.DELIVERED -> {
// Обновляем конкретное сообщение // Обновляем конкретное сообщение
@@ -4097,7 +4098,7 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
content = encryptedContent, content = encryptedContent,
timestamp = timestamp, timestamp = timestamp,
chachaKey = encryptedKey, chachaKey = encryptedKey,
read = if (isFromMe) 1 else 0, read = if (isFromMe && opponent == account) 1 else 0,
fromMe = if (isFromMe) 1 else 0, fromMe = if (isFromMe) 1 else 0,
delivered = delivered, delivered = delivered,
messageId = finalMessageId, messageId = finalMessageId,

View File

@@ -3800,30 +3800,14 @@ fun DialogItemContent(
// - lastMessageDelivered == 0 → часики // - lastMessageDelivered == 0 → часики
// (отправляется) // (отправляется)
// - lastMessageDelivered == 2 → ошибка // - lastMessageDelivered == 2 → ошибка
when (dialog.lastMessageDelivered) { val isReadByOpponent =
2 -> { dialog.lastMessageDelivered == 3 ||
// ERROR - показываем иконку ошибки (dialog.lastMessageDelivered == 1 &&
Icon( dialog.lastMessageRead == 1)
imageVector =
TablerIcons when {
.AlertCircle, isReadByOpponent -> {
contentDescription = // READ - две синие галочки
"Sending failed",
tint =
Color(
0xFFFF3B30
), // iOS красный
modifier =
Modifier.size(16.dp)
)
Spacer(
modifier =
Modifier.width(4.dp)
)
}
3 -> {
// READ (delivered=3) - две синие
// галочки
Box( Box(
modifier = modifier =
Modifier.width(20.dp) Modifier.width(20.dp)
@@ -3867,7 +3851,27 @@ fun DialogItemContent(
Modifier.width(4.dp) Modifier.width(4.dp)
) )
} }
1 -> { dialog.lastMessageDelivered == 2 -> {
// ERROR - показываем иконку ошибки
Icon(
imageVector =
TablerIcons
.AlertCircle,
contentDescription =
"Sending failed",
tint =
Color(
0xFFFF3B30
), // iOS красный
modifier =
Modifier.size(16.dp)
)
Spacer(
modifier =
Modifier.width(4.dp)
)
}
dialog.lastMessageDelivered == 1 -> {
// DELIVERED - одна серая галочка // DELIVERED - одна серая галочка
Icon( Icon(
painter = painter =