Catch error during mapping from domain to UI model
This commit is contained in:
parent
05c4de6c6c
commit
073eda75a2
@ -32,21 +32,28 @@ class PollSummaryMapper @Inject constructor(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
fun map(timelineEvent: TimelineEvent): PollSummary? {
|
fun map(timelineEvent: TimelineEvent): PollSummary? {
|
||||||
val content = timelineEvent.getVectorLastMessageContent()
|
|
||||||
val pollResponseData = pollResponseDataFactory.create(timelineEvent)
|
|
||||||
val eventId = timelineEvent.root.eventId.orEmpty()
|
val eventId = timelineEvent.root.eventId.orEmpty()
|
||||||
val creationTimestamp = timelineEvent.root.originServerTs ?: 0
|
val result = runCatching {
|
||||||
return if (eventId.isNotEmpty() && creationTimestamp > 0 && content is MessagePollContent) {
|
val content = timelineEvent.getVectorLastMessageContent()
|
||||||
convertToPollSummary(
|
val pollResponseData = pollResponseDataFactory.create(timelineEvent)
|
||||||
eventId = eventId,
|
val creationTimestamp = timelineEvent.root.originServerTs ?: 0
|
||||||
creationTimestamp = creationTimestamp,
|
return if (eventId.isNotEmpty() && creationTimestamp > 0 && content is MessagePollContent) {
|
||||||
messagePollContent = content,
|
convertToPollSummary(
|
||||||
pollResponseData = pollResponseData
|
eventId = eventId,
|
||||||
)
|
creationTimestamp = creationTimestamp,
|
||||||
} else {
|
messagePollContent = content,
|
||||||
Timber.w("missing mandatory info about poll event with id=$eventId")
|
pollResponseData = pollResponseData
|
||||||
null
|
)
|
||||||
|
} else {
|
||||||
|
Timber.w("missing mandatory info about poll event with id=$eventId")
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result.isFailure) {
|
||||||
|
Timber.w("failed to map event with id $eventId")
|
||||||
|
}
|
||||||
|
return result.getOrNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun convertToPollSummary(
|
private fun convertToPollSummary(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user