android: show message time instead of message id in bubbles
Some checks failed
CI / test (push) Failing after 2m10s

This commit is contained in:
Codex
2026-03-09 14:19:14 +03:00
parent c835dfda15
commit e2a87ffb2e

View File

@@ -55,6 +55,9 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import coil.compose.AsyncImage import coil.compose.AsyncImage
import ru.daemonlord.messenger.domain.message.model.MessageItem import ru.daemonlord.messenger.domain.message.model.MessageItem
import java.time.Instant
import java.time.ZoneId
import java.time.format.DateTimeFormatter
@Composable @Composable
fun ChatRoute( fun ChatRoute(
@@ -609,7 +612,7 @@ private fun MessageBubble(
else -> "" else -> ""
} }
Text( Text(
text = "${message.id}$status", text = "${formatMessageTime(message.createdAt)}$status",
style = MaterialTheme.typography.labelSmall, style = MaterialTheme.typography.labelSmall,
) )
} }
@@ -617,6 +620,17 @@ private fun MessageBubble(
} }
} }
private val messageTimeFormatter: DateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm")
private fun formatMessageTime(createdAt: String): String {
return runCatching {
Instant.parse(createdAt)
.atZone(ZoneId.systemDefault())
.toLocalTime()
.format(messageTimeFormatter)
}.getOrElse { "--:--" }
}
@Composable @Composable
private fun AudioAttachmentPlayer(url: String) { private fun AudioAttachmentPlayer(url: String) {
var isPlaying by remember(url) { mutableStateOf(false) } var isPlaying by remember(url) { mutableStateOf(false) }