Be robust to Exception.
And display details about it in the bottom sheet
This commit is contained in:
parent
2b70a8450c
commit
024dcf1f6c
@ -24,6 +24,7 @@ import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.error.ErrorFormatter
|
||||
import im.vector.app.core.extensions.canReact
|
||||
import im.vector.app.core.platform.EmptyViewEvents
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
@ -65,6 +66,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
||||
private val htmlCompressor: VectorHtmlCompressor,
|
||||
private val session: Session,
|
||||
private val noticeEventFormatter: NoticeEventFormatter,
|
||||
private val errorFormatter: ErrorFormatter,
|
||||
private val stringProvider: StringProvider,
|
||||
private val pillsPostProcessorFactory: PillsPostProcessor.Factory,
|
||||
private val vectorPreferences: VectorPreferences
|
||||
@ -171,11 +173,11 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
||||
}
|
||||
|
||||
private fun computeMessageBody(timelineEvent: TimelineEvent): CharSequence {
|
||||
return try {
|
||||
if (timelineEvent.root.isRedacted()) {
|
||||
return noticeEventFormatter.formatRedactedEvent(timelineEvent.root)
|
||||
}
|
||||
|
||||
return when (timelineEvent.root.getClearType()) {
|
||||
noticeEventFormatter.formatRedactedEvent(timelineEvent.root)
|
||||
} else {
|
||||
when (timelineEvent.root.getClearType()) {
|
||||
EventType.MESSAGE,
|
||||
EventType.STICKER -> {
|
||||
val messageContent: MessageContent? = timelineEvent.getLastMessageContent()
|
||||
@ -207,6 +209,10 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
||||
noticeEventFormatter.format(timelineEvent)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
} catch (failure: Throwable) {
|
||||
errorFormatter.toHumanReadable(failure)
|
||||
} ?: ""
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user