Skip to content

Commit ca24ee8

Browse files
committed
Keep attachment picker open when selecting an unavailable command
1 parent 618ec31 commit ca24ee8

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/attachments/AttachmentPickerActions.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import io.getstream.chat.android.compose.viewmodel.messages.MessageComposerViewM
2323
import io.getstream.chat.android.models.Attachment
2424
import io.getstream.chat.android.models.Command
2525
import io.getstream.chat.android.models.CreatePollParams
26+
import io.getstream.chat.android.ui.common.state.messages.composer.isAvailableFor
2627

2728
/**
2829
* Actions that can be performed in the attachment picker.
@@ -118,8 +119,13 @@ public data class AttachmentPickerActions(
118119
// Must run before consumePickerSession: selectCommand stashes the current composer
119120
// attachments for restore-on-cancel, and consumePickerSession would otherwise clear
120121
// them first.
122+
val action = composerViewModel.messageComposerState.value.action
121123
composerViewModel.selectCommand(command)
122-
consumePickerSession(attachmentsPickerViewModel, composerViewModel)
124+
// Keep the picker open when the command was unavailable so the user can see the
125+
// emitted notice in context and try another command.
126+
if (command.isAvailableFor(action)) {
127+
consumePickerSession(attachmentsPickerViewModel, composerViewModel)
128+
}
123129
},
124130
onDismiss = { attachmentsPickerViewModel.setPickerVisible(visible = false) },
125131
)

0 commit comments

Comments
 (0)