mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-05 21:43:40 +01:00
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? {
|
||||
val content = timelineEvent.getVectorLastMessageContent()
|
||||
val pollResponseData = pollResponseDataFactory.create(timelineEvent)
|
||||
val eventId = timelineEvent.root.eventId.orEmpty()
|
||||
val creationTimestamp = timelineEvent.root.originServerTs ?: 0
|
||||
return if (eventId.isNotEmpty() && creationTimestamp > 0 && content is MessagePollContent) {
|
||||
convertToPollSummary(
|
||||
eventId = eventId,
|
||||
creationTimestamp = creationTimestamp,
|
||||
messagePollContent = content,
|
||||
pollResponseData = pollResponseData
|
||||
)
|
||||
} else {
|
||||
Timber.w("missing mandatory info about poll event with id=$eventId")
|
||||
null
|
||||
val result = runCatching {
|
||||
val content = timelineEvent.getVectorLastMessageContent()
|
||||
val pollResponseData = pollResponseDataFactory.create(timelineEvent)
|
||||
val creationTimestamp = timelineEvent.root.originServerTs ?: 0
|
||||
return if (eventId.isNotEmpty() && creationTimestamp > 0 && content is MessagePollContent) {
|
||||
convertToPollSummary(
|
||||
eventId = eventId,
|
||||
creationTimestamp = creationTimestamp,
|
||||
messagePollContent = content,
|
||||
pollResponseData = pollResponseData
|
||||
)
|
||||
} 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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user