Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
| snackbarScope.launch { | ||
| snackbarHostState.showSnackbar( | ||
| message = pollEndedMessage, | ||
| duration = SnackbarDuration.Short, | ||
| ) | ||
| } |
There was a problem hiding this comment.
Here we're showing the snackbar as soon as we fire the action, but it could fail. The alternative would be to update the closePoll function to accept something like an onSuccess lambda. WDYT?
There was a problem hiding this comment.
Not sure if if would make sense to handle the success case similar to the error cases: ErrorEvent defined in the MessageListController. Basically to emit success/error events for this operation as well, and then collect and react to them in the UI.
There was a problem hiding this comment.
Good idea! I've added a new flow for generic events (so it can contain both successes and failures), but I also left the error flow there for compatibility. Let me know if you think this is overkill and we should just remove it
There was a problem hiding this comment.
From my point of view looks pretty good!
@andremion maybe you can also take a look!
|
@coderabbitai review |
SDK Size Comparison 📏
|
WalkthroughThis PR enhances poll functionality by introducing an end-poll confirmation dialog, extracting the add-answer input into a dedicated component, and improving spacing with modifiers. It updates snackbar integration in MessagesScreen to notify users when polls close, refines button styling in poll creation, and expands string resources for unlimited answer descriptions. Additionally, it updates generated ComposableSingletons lambda fields due to Compose compiler regeneration. Changes
Sequence DiagramsequenceDiagram
actor User
participant PollMessageContent
participant EndPollConfirmationDialog
participant MessagesScreen
participant ListViewModel
participant SnackbarHost
User->>PollMessageContent: Clicks end poll option
PollMessageContent->>PollMessageContent: Set showEndPollDialog = true
PollMessageContent->>EndPollConfirmationDialog: Display dialog
User->>EndPollConfirmationDialog: Confirms poll closure
EndPollConfirmationDialog->>MessagesScreen: Invoke onClosePoll(pollId)
MessagesScreen->>ListViewModel: closePoll(pollId)
ListViewModel->>ListViewModel: Process poll closure
MessagesScreen->>SnackbarHost: Show "Poll ended" message
SnackbarHost->>User: Display snackbar notification
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
♻️ Duplicate comments (1)
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/MessagesScreen.kt (1)
240-251:⚠️ Potential issue | 🟡 MinorSnackbar displays before confirming poll closure success.
The snackbar is shown immediately after calling
closePoll(), regardless of whether the operation succeeds. If the poll closure fails, users will see a misleading "Poll ended" message. Consider adding anonSuccesscallback toclosePollto show the snackbar only on successful completion.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/MessagesScreen.kt` around lines 240 - 251, The onClosePoll lambda currently calls listViewModel.closePoll(pollId) then immediately shows the snackbar via snackbarScope.launch and snackbarHostState.showSnackbar with pollEndedMessage; change this so the snackbar is only shown after closePoll reports success — either by using a provided onSuccess callback on listViewModel.closePoll (or updating closePoll to accept one) or by awaiting/collecting the result (e.g., a suspend function / Result/Flow) and only launching snackbarScope to show pollEndedMessage when the operation succeeds; also handle and surface failures (e.g., show an error snackbar) instead of unconditionally showing pollEndedMessage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In
`@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/MessagesScreen.kt`:
- Around line 240-251: The onClosePoll lambda currently calls
listViewModel.closePoll(pollId) then immediately shows the snackbar via
snackbarScope.launch and snackbarHostState.showSnackbar with pollEndedMessage;
change this so the snackbar is only shown after closePoll reports success —
either by using a provided onSuccess callback on listViewModel.closePoll (or
updating closePoll to accept one) or by awaiting/collecting the result (e.g., a
suspend function / Result/Flow) and only launching snackbarScope to show
pollEndedMessage when the operation succeeds; also handle and surface failures
(e.g., show an error snackbar) instead of unconditionally showing
pollEndedMessage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8c4b8e08-b5de-4264-ab3e-4ed72b5084de
⛔ Files ignored due to path filters (9)
stream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.components.messages_PollMessageContentTest_poll_content.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.components.poll_PollViewResultDialogTest_dark_mode.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.components.poll_PollViewResultDialogTest_light_mode.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.messages.attachments.poll_CreatePollScreenTest_dark_mode.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.messages.attachments.poll_CreatePollScreenTest_light_mode.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.messages.attachments.poll_PollCreationHeaderTest_disabled.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.messages.attachments.poll_PollCreationHeaderTest_enabled.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.messages_MessageListTest_loaded_messages.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.messages_MessageListTest_loaded_messages_in_dark_mode.pngis excluded by!**/*.png
📒 Files selected for processing (9)
stream-chat-android-compose/api/stream-chat-android-compose.apistream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/messages/PollMessageContent.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/poll/PollAnswers.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/poll/PollViewResultDialog.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/MessagesScreen.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/attachments/poll/PollCreationHeader.ktstream-chat-android-compose/src/main/res/values/strings.xmlstream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/utils/extensions/Poll.ktstream-chat-android-ui-common/src/main/res/values/strings.xml
0e35fd9 to
4df8cad
Compare
|


Goal
Apply UI fixes to the poll message and screens
Implementation
Describe the implementation
🎨 UI Changes
Please check the updated snapshots
Testing
Can be checked in hte sample
Summary by CodeRabbit
New Features
Improvements