@@ -31,6 +31,9 @@ import androidx.compose.ui.graphics.ColorFilter
3131import androidx.compose.ui.res.painterResource
3232import androidx.compose.ui.res.stringResource
3333import androidx.compose.ui.text.AnnotatedString
34+ import androidx.compose.ui.text.SpanStyle
35+ import androidx.compose.ui.text.buildAnnotatedString
36+ import androidx.compose.ui.text.font.FontStyle
3437import androidx.compose.ui.unit.dp
3538import cafe.adriel.voyager.navigator.currentOrThrow
3639import com.getcode.theme.CodeTheme
@@ -157,21 +160,30 @@ private val ConversationWithMembersAndLastMessage.messagePreview: Pair<Annotated
157160 @Composable get() {
158161 val user = LocalUserManager .currentOrThrow
159162 val contents = messageContentPreview ? : return AnnotatedString (" No content" ) to emptyMap()
160- val messageBody = if (this .lastMessage?.isDeleted == true ) {
161- when {
162- user.isSelf(this .lastMessage?.deletedBy) -> {
163- stringResource(R .string.title_messageDeletedByYou)
164- }
165- this .ownerId == this .lastMessage?.deletedBy -> {
166- stringResource(R .string.title_messageDeletedByHost)
167- }
168- else -> {
169- stringResource(R .string.title_messageWasDeleted)
163+
164+ val messageBody = buildAnnotatedString {
165+ if (lastMessage?.isDeleted == true ) {
166+ when {
167+ user.isSelf(lastMessage?.deletedBy) -> {
168+ pushStyle(SpanStyle (fontStyle = FontStyle .Italic ))
169+ append(stringResource(R .string.title_messageDeletedByYou))
170+ pop()
171+ }
172+ ownerId == lastMessage?.deletedBy -> {
173+ pushStyle(SpanStyle (fontStyle = FontStyle .Italic ))
174+ append(stringResource(R .string.title_messageDeletedByHost))
175+ pop()
176+ }
177+ else -> {
178+ pushStyle(SpanStyle (fontStyle = FontStyle .Italic ))
179+ append(stringResource(R .string.title_messageWasDeleted))
180+ pop()
181+ }
170182 }
183+ } else {
184+ append(contents.localizedText)
171185 }
172- } else {
173- contents.localizedText
174186 }
175187
176- return AnnotatedString ( messageBody) to emptyMap()
188+ return messageBody to emptyMap()
177189 }
0 commit comments