@@ -183,6 +183,7 @@ import org.thoughtcrime.securesms.mms.AudioSlide
183183import org.thoughtcrime.securesms.mms.GifSlide
184184import org.thoughtcrime.securesms.mms.ImageSlide
185185import org.thoughtcrime.securesms.mms.MediaConstraints
186+ import org.thoughtcrime.securesms.mms.MmsException
186187import org.thoughtcrime.securesms.mms.Slide
187188import org.thoughtcrime.securesms.mms.SlideDeck
188189import org.thoughtcrime.securesms.mms.VideoSlide
@@ -2092,25 +2093,36 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
20922093
20932094 // do the heavy work in the bg
20942095 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+ )
21022106
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+ }
21102114
2111- waitForApprovalJobToBeSubmitted()
2115+ waitForApprovalJobToBeSubmitted()
21122116
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+ }
21142126 }
21152127
21162128 // Send a typing stopped message
0 commit comments