Skip to content

Commit e14ef24

Browse files
authored
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.
1 parent 040fde7 commit e14ef24

File tree

1 file changed

+1
-1
lines changed
  • features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/attachments/preview

1 file changed

+1
-1
lines changed

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/attachments/preview/AttachmentsPreviewView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fun AttachmentsPreviewView(
6666
state.eventSink(AttachmentsPreviewEvents.CancelAndClearSendState)
6767
}
6868

69-
BackHandler(enabled = state.sendActionState !is SendActionState.Sending.Uploading) {
69+
BackHandler(enabled = state.sendActionState !is SendActionState.Sending.Uploading && state.sendActionState !is SendActionState.Done) {
7070
postCancel()
7171
}
7272

0 commit comments

Comments
 (0)