AttachmentsPreviewEvents -> AttachmentsPreviewEvent
This commit is contained in:
parent
f5b5bee326
commit
f74f6b0d45
5 changed files with 27 additions and 27 deletions
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
package io.element.android.features.messages.impl.attachments.preview
|
||||
|
||||
sealed interface AttachmentsPreviewEvents {
|
||||
data object SendAttachment : AttachmentsPreviewEvents
|
||||
data object CancelAndDismiss : AttachmentsPreviewEvents
|
||||
data object CancelAndClearSendState : AttachmentsPreviewEvents
|
||||
sealed interface AttachmentsPreviewEvent {
|
||||
data object SendAttachment : AttachmentsPreviewEvent
|
||||
data object CancelAndDismiss : AttachmentsPreviewEvent
|
||||
data object CancelAndClearSendState : AttachmentsPreviewEvent
|
||||
}
|
||||
|
|
@ -140,9 +140,9 @@ class AttachmentsPreviewPresenter(
|
|||
}
|
||||
}
|
||||
|
||||
fun handleEvent(event: AttachmentsPreviewEvents) {
|
||||
fun handleEvent(event: AttachmentsPreviewEvent) {
|
||||
when (event) {
|
||||
is AttachmentsPreviewEvents.SendAttachment -> {
|
||||
is AttachmentsPreviewEvent.SendAttachment -> {
|
||||
ongoingSendAttachmentJob.value = coroutineScope.launch {
|
||||
// If the media optimization selector is displayed, we need to wait for the user to select the options
|
||||
// before we can pre-process the media.
|
||||
|
|
@ -191,7 +191,7 @@ class AttachmentsPreviewPresenter(
|
|||
}
|
||||
}
|
||||
}
|
||||
AttachmentsPreviewEvents.CancelAndDismiss -> {
|
||||
AttachmentsPreviewEvent.CancelAndDismiss -> {
|
||||
displayFileTooLargeError = false
|
||||
|
||||
// Cancel media preprocessing and sending
|
||||
|
|
@ -206,7 +206,7 @@ class AttachmentsPreviewPresenter(
|
|||
sendActionState,
|
||||
)
|
||||
}
|
||||
AttachmentsPreviewEvents.CancelAndClearSendState -> {
|
||||
AttachmentsPreviewEvent.CancelAndClearSendState -> {
|
||||
// Cancel media sending
|
||||
ongoingSendAttachmentJob.value?.let {
|
||||
it.cancel()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ data class AttachmentsPreviewState(
|
|||
val textEditorState: TextEditorState,
|
||||
val mediaOptimizationSelectorState: MediaOptimizationSelectorState,
|
||||
val displayFileTooLargeError: Boolean,
|
||||
val eventSink: (AttachmentsPreviewEvents) -> Unit
|
||||
val eventSink: (AttachmentsPreviewEvent) -> Unit,
|
||||
)
|
||||
|
||||
@Immutable
|
||||
|
|
|
|||
|
|
@ -82,15 +82,15 @@ fun AttachmentsPreviewView(
|
|||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
fun postSendAttachment() {
|
||||
state.eventSink(AttachmentsPreviewEvents.SendAttachment)
|
||||
state.eventSink(AttachmentsPreviewEvent.SendAttachment)
|
||||
}
|
||||
|
||||
fun postCancel() {
|
||||
state.eventSink(AttachmentsPreviewEvents.CancelAndDismiss)
|
||||
state.eventSink(AttachmentsPreviewEvent.CancelAndDismiss)
|
||||
}
|
||||
|
||||
fun postClearSendState() {
|
||||
state.eventSink(AttachmentsPreviewEvents.CancelAndClearSendState)
|
||||
state.eventSink(AttachmentsPreviewEvent.CancelAndClearSendState)
|
||||
}
|
||||
|
||||
BackHandler(enabled = state.sendActionState !is SendActionState.Sending.Uploading && state.sendActionState !is SendActionState.Done) {
|
||||
|
|
@ -199,7 +199,7 @@ private fun AttachmentPreviewContent(
|
|||
AlertDialog(
|
||||
title = stringResource(CommonStrings.dialog_file_too_large_to_upload_title),
|
||||
content = content,
|
||||
onDismiss = { state.eventSink(AttachmentsPreviewEvents.CancelAndDismiss) },
|
||||
onDismiss = { state.eventSink(AttachmentsPreviewEvent.CancelAndDismiss) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue