Skip to content

Commit 9f5ec65

Browse files
committed
Update RS version and some fixes
1 parent 9a502b2 commit 9f5ec65

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

WordPress/src/main/java/org/wordpress/android/support/he/ui/HESupportActivity.kt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ import org.wordpress.android.ui.compose.theme.AppThemeM3
2929
import org.wordpress.android.R
3030
import org.wordpress.android.fluxc.utils.AppLogWrapper
3131
import org.wordpress.android.support.common.ui.ConversationsSupportViewModel
32+
import org.wordpress.android.support.common.ui.ConversationsSupportViewModel.ErrorType
3233
import org.wordpress.android.ui.photopicker.MediaPickerConstants
3334
import org.wordpress.android.ui.reader.ReaderFileDownloadManager
3435
import org.wordpress.android.ui.mediapicker.MediaPickerSetup
3536
import org.wordpress.android.ui.mediapicker.MediaType
37+
import org.wordpress.android.util.AppLog
3638
import javax.inject.Inject
3739

3840
@AndroidEntryPoint
@@ -44,15 +46,22 @@ class HESupportActivity : AppCompatActivity() {
4446
private lateinit var composeView: ComposeView
4547
private lateinit var navController: NavHostController
4648

49+
@Suppress("TooGenericExceptionCaught")
4750
private val photoPickerLauncher = registerForActivityResult(
4851
androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult()
4952
) { result ->
50-
if (result.resultCode == RESULT_OK && result.data != null) {
51-
val uris = result.data?.getStringArrayExtra(MediaPickerConstants.EXTRA_MEDIA_URIS)
52-
uris?.let { uriStrings ->
53-
val newUris = uriStrings.map { it.toUri() }
54-
viewModel.addAttachments(newUris)
53+
try {
54+
if (result.resultCode == RESULT_OK && result.data != null) {
55+
val uris = result.data?.getStringArrayExtra(MediaPickerConstants.EXTRA_MEDIA_URIS)
56+
uris?.let { uriStrings ->
57+
val newUris = uriStrings.map { it.toUri() }
58+
viewModel.addAttachments(newUris)
59+
}
5560
}
61+
} catch (e: Exception) {
62+
viewModel.notifyGeneralError()
63+
appLogWrapper.e(
64+
AppLog.T.SUPPORT, "Error getting attachments to add: ${e.stackTraceToString()}")
5665
}
5766
}
5867

WordPress/src/main/java/org/wordpress/android/support/he/ui/HESupportViewModel.kt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ class HESupportViewModel @Inject constructor(
9595
_isSendingMessage.value = false
9696
} catch (e: Exception) {
9797
_errorMessage.value = ErrorType.GENERAL
98-
appLogWrapper.e(AppLog.T.SUPPORT, "Error creating HE conversation")
98+
appLogWrapper.e(
99+
AppLog.T.SUPPORT,
100+
"Error creating HE conversation ${e.stackTraceToString()}"
101+
)
99102
}
100103
}
101104
}
@@ -145,8 +148,10 @@ class HESupportViewModel @Inject constructor(
145148
_isSendingMessage.value = false
146149
} catch (e: Exception) {
147150
_errorMessage.value = ErrorType.GENERAL
148-
appLogWrapper.e(AppLog.T.SUPPORT, "Error adding message to HE conversation: " +
149-
e.stackTraceToString())
151+
appLogWrapper.e(
152+
AppLog.T.SUPPORT,
153+
"Error adding message to HE conversation: ${e.stackTraceToString()}"
154+
)
150155
}
151156
}
152157
}
@@ -167,6 +172,10 @@ class HESupportViewModel @Inject constructor(
167172
_attachments.value = emptyList()
168173
}
169174

175+
fun notifyGeneralError() {
176+
_errorMessage.value = ErrorType.GENERAL
177+
}
178+
170179
@Suppress("TooGenericExceptionCaught")
171180
private suspend fun copyUrisToTempFiles(uris: List<Uri>): List<File> = withContext(ioDispatcher) {
172181
uris.map{ it.toTempFile() }
@@ -175,11 +184,13 @@ class HESupportViewModel @Inject constructor(
175184
@Suppress("TooGenericExceptionCaught")
176185
private suspend fun removeTempFiles(files: List<File>) = withContext(ioDispatcher) {
177186
try {
187+
var removed = files.isEmpty() // If empty, count them as removed
178188
files.forEach { file ->
179189
if (file.exists()) {
180-
file.delete()
190+
removed = removed && file.delete()
181191
}
182192
}
193+
removed
183194
} catch (e: Exception) {
184195
appLogWrapper.e(AppLog.T.SUPPORT, "Error removing attachment temp files temp files: " +
185196
e.stackTraceToString())

gradle/libs.versions.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ wellsql = '2.0.0'
101101
wordpress-aztec = 'v2.1.4'
102102
wordpress-lint = '2.2.0'
103103
wordpress-persistent-edittext = '1.0.2'
104-
## TODO: Use trunk commit when merge
105-
wordpress-rs = '995-5b34ff29422a4db847044c72bd06672be922af22'
104+
wordpress-rs = 'trunk-fb107b497caaf2b1f4ffcf9f487784792561a645'
106105
wordpress-utils = '3.14.0'
107106
automattic-ucrop = '2.2.11'
108107
zendesk = '5.5.1'

0 commit comments

Comments
 (0)