Added simple (limited) message preview

This commit is contained in:
Valere 2019-06-04 12:02:34 +02:00
parent 9061d5c972
commit 0ecc53f59c
1 changed files with 9 additions and 1 deletions

View File

@ -18,7 +18,10 @@ package im.vector.riotredesign.features.home.room.list
import androidx.annotation.StringRes import androidx.annotation.StringRes
import com.airbnb.epoxy.TypedEpoxyController import com.airbnb.epoxy.TypedEpoxyController
import im.vector.matrix.android.api.session.events.model.EventType
import im.vector.matrix.android.api.session.events.model.toModel
import im.vector.matrix.android.api.session.room.model.RoomSummary import im.vector.matrix.android.api.session.room.model.RoomSummary
import im.vector.matrix.android.api.session.room.model.message.MessageContent
import im.vector.riotredesign.core.extensions.localDateTime import im.vector.riotredesign.core.extensions.localDateTime
import im.vector.riotredesign.core.resources.DateProvider import im.vector.riotredesign.core.resources.DateProvider
import im.vector.riotredesign.core.resources.StringProvider import im.vector.riotredesign.core.resources.StringProvider
@ -90,7 +93,12 @@ class RoomSummaryController(private val stringProvider: StringProvider,
val currentData = DateProvider.currentLocalDateTime() val currentData = DateProvider.currentLocalDateTime()
val isSameDay = date.toLocalDate() == currentData.toLocalDate() val isSameDay = date.toLocalDate() == currentData.toLocalDate()
//TODO: get formatted //TODO: get formatted
lastMessageFormatted = lastMessage.content?.toString() ?: "" if (lastMessage.type == EventType.MESSAGE) {
val content = lastMessage.content?.toModel<MessageContent>()
lastMessageFormatted = content?.body ?: ""
} else {
lastMessageFormatted = lastMessage.type
}
lastMessageTime = if (isSameDay) { lastMessageTime = if (isSameDay) {
timelineDateFormatter.formatMessageHour(date) timelineDateFormatter.formatMessageHour(date)
} else { } else {