feat: improve message delivery status handling and UI indicators in chat screens
This commit is contained in:
@@ -396,6 +396,7 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
|
||||
val currentDialogKey = getDialogKey(account, opponent)
|
||||
|
||||
if (update.dialogKey == currentDialogKey) {
|
||||
if (!isDialogActive) return@collect
|
||||
when (update.status) {
|
||||
DeliveryStatus.DELIVERED -> {
|
||||
// Обновляем конкретное сообщение
|
||||
@@ -4097,7 +4098,7 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
|
||||
content = encryptedContent,
|
||||
timestamp = timestamp,
|
||||
chachaKey = encryptedKey,
|
||||
read = if (isFromMe) 1 else 0,
|
||||
read = if (isFromMe && opponent == account) 1 else 0,
|
||||
fromMe = if (isFromMe) 1 else 0,
|
||||
delivered = delivered,
|
||||
messageId = finalMessageId,
|
||||
|
||||
@@ -3800,30 +3800,14 @@ fun DialogItemContent(
|
||||
// - lastMessageDelivered == 0 → часики
|
||||
// (отправляется)
|
||||
// - lastMessageDelivered == 2 → ошибка
|
||||
when (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)
|
||||
)
|
||||
}
|
||||
3 -> {
|
||||
// READ (delivered=3) - две синие
|
||||
// галочки
|
||||
val isReadByOpponent =
|
||||
dialog.lastMessageDelivered == 3 ||
|
||||
(dialog.lastMessageDelivered == 1 &&
|
||||
dialog.lastMessageRead == 1)
|
||||
|
||||
when {
|
||||
isReadByOpponent -> {
|
||||
// READ - две синие галочки
|
||||
Box(
|
||||
modifier =
|
||||
Modifier.width(20.dp)
|
||||
@@ -3867,7 +3851,27 @@ fun DialogItemContent(
|
||||
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 - одна серая галочка
|
||||
Icon(
|
||||
painter =
|
||||
|
||||
Reference in New Issue
Block a user