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.
This commit is contained in:
Jorge Martin Espinosa
2025-07-25 13:36:09 +02:00
committed by GitHub
parent 040fde7f22
commit e14ef24927
@@ -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()
}