@@ -183,6 +183,7 @@ import org.thoughtcrime.securesms.mms.AudioSlide
183
183
import org.thoughtcrime.securesms.mms.GifSlide
184
184
import org.thoughtcrime.securesms.mms.ImageSlide
185
185
import org.thoughtcrime.securesms.mms.MediaConstraints
186
+ import org.thoughtcrime.securesms.mms.MmsException
186
187
import org.thoughtcrime.securesms.mms.Slide
187
188
import org.thoughtcrime.securesms.mms.SlideDeck
188
189
import org.thoughtcrime.securesms.mms.VideoSlide
@@ -2092,25 +2093,36 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
2092
2093
2093
2094
// do the heavy work in the bg
2094
2095
lifecycleScope.launch(Dispatchers .Default ) {
2095
- // Put the message in the database and send it
2096
- message.id = MessageId (mmsDb.insertMessageOutbox(
2097
- outgoingTextMessage,
2098
- viewModel.threadId,
2099
- false ,
2100
- runThreadUpdate = true
2101
- ), mms = true )
2096
+ runCatching {
2097
+ // Put the message in the database and send it
2098
+ message.id = MessageId (
2099
+ mmsDb.insertMessageOutbox(
2100
+ outgoingTextMessage,
2101
+ viewModel.threadId,
2102
+ false ,
2103
+ runThreadUpdate = true
2104
+ ), mms = true
2105
+ )
2102
2106
2103
- if (deleteAttachmentFilesAfterSave) {
2104
- attachments
2105
- .asSequence()
2106
- .mapNotNull { a -> a.dataUri?.takeIf { it.scheme == " file" }?.path?.let (::File ) }
2107
- .filter { it.exists() }
2108
- .forEach { it.delete() }
2109
- }
2107
+ if (deleteAttachmentFilesAfterSave) {
2108
+ attachments
2109
+ .asSequence()
2110
+ .mapNotNull { a -> a.dataUri?.takeIf { it.scheme == " file" }?.path?.let (::File ) }
2111
+ .filter { it.exists() }
2112
+ .forEach { it.delete() }
2113
+ }
2110
2114
2111
- waitForApprovalJobToBeSubmitted()
2115
+ waitForApprovalJobToBeSubmitted()
2112
2116
2113
- MessageSender .send(message, recipient.address, quote, linkPreview)
2117
+ MessageSender .send(message, recipient.address, quote, linkPreview)
2118
+ }.onFailure {
2119
+ withContext(Dispatchers .Main ){
2120
+ when (it) {
2121
+ is MmsException -> Toast .makeText(this @ConversationActivityV2, R .string.attachmentsErrorSending, Toast .LENGTH_LONG ).show()
2122
+ else -> Toast .makeText(this @ConversationActivityV2, R .string.errorGeneric, Toast .LENGTH_LONG ).show()
2123
+ }
2124
+ }
2125
+ }
2114
2126
}
2115
2127
2116
2128
// Send a typing stopped message
0 commit comments