Close the progress dialog when the treatment is over (avoid UI glitch)

This commit is contained in:
Benoit Marty 2024-11-25 17:18:07 +01:00
parent 7215786239
commit e752da70fb
3 changed files with 14 additions and 6 deletions

View file

@ -131,6 +131,7 @@ class AttachmentsPreviewPresenter @AssistedInject constructor(
attachment,
prePropressingJob,
mediaUploadInfoStateFlow.value,
sendActionState,
)
}
AttachmentsPreviewEvents.ClearSendState -> {
@ -192,6 +193,7 @@ class AttachmentsPreviewPresenter @AssistedInject constructor(
attachment: Attachment,
preProcessingJob: Job?,
mediaUploadInfo: AsyncData<MediaUploadInfo>,
sendActionState: MutableState<SendActionState>,
) = launch {
// Delete the temporary file
when (attachment) {
@ -203,6 +205,8 @@ class AttachmentsPreviewPresenter @AssistedInject constructor(
}
}
}
// Reset the sendActionState to ensure that dialog is closed before the screen
sendActionState.value = SendActionState.Done
onDoneListener()
}
@ -236,6 +240,8 @@ class AttachmentsPreviewPresenter @AssistedInject constructor(
}.fold(
onSuccess = {
cleanUp(mediaUploadInfo)
// Reset the sendActionState to ensure that dialog is closed before the screen
sendActionState.value = SendActionState.Done
onDoneListener()
},
onFailure = { error ->

View file

@ -33,4 +33,5 @@ sealed interface SendActionState {
}
data class Failure(val error: Throwable) : SendActionState
data object Done : SendActionState
}