From b57e79f8c6f85ed4edd01868334639c5713681cb Mon Sep 17 00:00:00 2001 From: Jorge Martin Espinosa Date: Fri, 25 Jul 2025 13:36:09 +0200 Subject: [PATCH] Prevent loop when exiting the attachments preview screen (#5078) Disable the custom `BackHandler` when the `sendState` is `Done`. Otherwise, it can get into a loop in some cases where `postCancel()` calls the `OnDoneListener`, which triggers an up navigation, which then simulates a back press... and we end up in the custom `BackHandler` again. --- .../messages/impl/attachments/preview/AttachmentsPreviewView.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/attachments/preview/AttachmentsPreviewView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/attachments/preview/AttachmentsPreviewView.kt index 61c71a233c..0ea99a9c35 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/attachments/preview/AttachmentsPreviewView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/attachments/preview/AttachmentsPreviewView.kt @@ -66,7 +66,7 @@ fun AttachmentsPreviewView( state.eventSink(AttachmentsPreviewEvents.CancelAndClearSendState) } - BackHandler(enabled = state.sendActionState !is SendActionState.Sending.Uploading) { + BackHandler(enabled = state.sendActionState !is SendActionState.Sending.Uploading && state.sendActionState !is SendActionState.Done) { postCancel() }