diff --git a/composeApp/src/commonMain/kotlin/press/mantra/compose/database/model/intermdiate/LocalChatRoom.kt b/composeApp/src/commonMain/kotlin/press/mantra/compose/database/model/intermdiate/LocalChatRoom.kt index 021f0f0a..2529c8ee 100644 --- a/composeApp/src/commonMain/kotlin/press/mantra/compose/database/model/intermdiate/LocalChatRoom.kt +++ b/composeApp/src/commonMain/kotlin/press/mantra/compose/database/model/intermdiate/LocalChatRoom.kt @@ -42,12 +42,16 @@ data class LocalChatRoom( if (chatRoom.subject != null) { Text( text = chatRoom.subject, - color = ProfileColor.fromPublicKey(chatRoom.id) + color = ProfileColor.fromPublicKey(chatRoom.id), + maxLines = 1, + overflow = TextOverflow.Ellipsis ) } else { if (localParticipants.size == 1) { Text( - text = "Note to Self (${localParticipants.first().profile?.humanReadableNameOrPubkey()})" + text = "Note to Self (${localParticipants.first().profile?.humanReadableNameOrPubkey()})", + maxLines = 1, + overflow = TextOverflow.Ellipsis ) } else { // Remove the active user publicKey from participants... @@ -66,6 +70,8 @@ data class LocalChatRoom( append(participantName) } }, + maxLines = 1, + overflow = TextOverflow.Ellipsis ) } } diff --git a/composeApp/src/commonMain/kotlin/press/mantra/compose/ui/view/model/ChatRoomListViewModel.kt b/composeApp/src/commonMain/kotlin/press/mantra/compose/ui/view/model/ChatRoomListViewModel.kt index 6ef606ae..bf36213c 100755 --- a/composeApp/src/commonMain/kotlin/press/mantra/compose/ui/view/model/ChatRoomListViewModel.kt +++ b/composeApp/src/commonMain/kotlin/press/mantra/compose/ui/view/model/ChatRoomListViewModel.kt @@ -2,6 +2,7 @@ package press.mantra.compose.ui.view.model import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height @@ -11,6 +12,7 @@ import androidx.compose.foundation.lazy.items import androidx.compose.material3.Card import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi import androidx.compose.material3.LoadingIndicator +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -27,6 +29,7 @@ import androidx.lifecycle.viewmodel.initializer import androidx.lifecycle.viewmodel.viewModelFactory import press.mantra.compose.database.model.NegentropySynchronizeRequest import press.mantra.compose.database.model.types.SynchronizationFilter +import press.mantra.compose.extensions.toChatListTimestampString import press.mantra.compose.nostr.Nip17Filters import press.mantra.compose.nostr.Relays import press.mantra.compose.repository.ChatRepository @@ -186,11 +189,36 @@ class ChatRoomListViewModel( ) } ) { - Column( - modifier = Modifier.padding(20.dp), - horizontalAlignment = Alignment.CenterHorizontally, + Row( + modifier = Modifier.fillMaxWidth().padding(20.dp), + horizontalArrangement = Arrangement.spacedBy(10.dp), + verticalAlignment = Alignment.CenterVertically ) { - localChatRoom.RenderChatRoomTitleText() + // Both lines are clipped to one, so the name + // and the preview keep their width whatever + // was said -- a long message must not push + // the clock off the row. + Column( + modifier = Modifier.weight(1f), + verticalArrangement = Arrangement.spacedBy(4.dp) + ) { + localChatRoom.RenderChatRoomTitleText() + localChatRoom.RenderChatRoomLastMessageText() + } + + // Absent rather than blank for a room with + // nothing in it: there is no time to show, + // and the room's own creation -- which is + // what it sorts on -- is not one the user + // has any reason to read here. + localChatRoom.lastChatMessage?.let { lastChatMessage -> + Text( + text = lastChatMessage.createdAt.toChatListTimestampString(), + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + maxLines = 1 + ) + } } } }