Fix a bug where the image upload screen was unintentionally dismissed for some failures. (#4414)

This commit is contained in:
Doug
2025-08-14 18:19:57 +01:00
committed by GitHub
parent 8000dbe29f
commit f1f6cace77
2 changed files with 108 additions and 23 deletions
@@ -62,7 +62,6 @@ class MediaUploadPreviewScreenViewModel: MediaUploadPreviewScreenViewModelType,
Task {
defer { stopLoading() }
var shouldDismissOnCompletion = true
switch await processingTask.value {
case .success(let mediaInfos):
for mediaInfo in mediaInfos {
@@ -70,23 +69,20 @@ class MediaUploadPreviewScreenViewModel: MediaUploadPreviewScreenViewModelType,
case .success:
caption = nil // Set the caption only on the first uploaded file.
case .failure(let error):
MXLog.error("Failed processing media to upload with error: \(error)")
showError(label: L10n.screenMediaUploadPreviewErrorFailedProcessing)
MXLog.error("Failed sending media with error: \(error)")
showError(label: L10n.screenMediaUploadPreviewErrorFailedSending)
}
}
actionsSubject.send(.dismiss)
case .failure(.maxUploadSizeUnknown):
showAlert(.maxUploadSizeUnknown)
shouldDismissOnCompletion = false
case .failure(.maxUploadSizeExceeded(let limit)):
showAlert(.maxUploadSizeExceeded(limit: limit))
case .failure(let error):
MXLog.error("Failed processing media to upload with error: \(error)")
showError(label: L10n.screenMediaUploadPreviewErrorFailedProcessing)
}
if shouldDismissOnCompletion {
actionsSubject.send(.dismiss)
}
}
case .cancel:
requestHandle?.cancel()