Repository navigation
fix(ui): stop the poll option votes and comments dialogs listing other votes (v9) - #3060
Conversation
…r votes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## fix/flu-974_poll_vote_list_other_polls_v9 #3060 +/- ##
=============================================================================
+ Coverage 68.87% 69.55% +0.68%
=============================================================================
Files 435 435
Lines 27711 27738 +27
=============================================================================
+ Hits 19085 19294 +209
+ Misses 8626 8444 -182 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
xsahil03x
left a comment
There was a problem hiding this comment.
Faithful port of #3059: the controller is identical apart from v9's own base (package: import, no disposed guard), the dialogs get the same one-line swaps, and v9's answer resolver keeps the payload the same way. Correct for the same reasons as #3059, and CI is green.
The inline comments mirror #3059: rename option / answers → forOption / forAnswers and fix the "live votes" wording. The handler-doc suggestions are rewrapped for v9's 80-column limit. None block.
On the description: same as #3059, the "Notes:" section reads better as comments on the lines it justifies.
| /// Creates a Stream poll vote list controller that lists only the votes for | ||
| /// the poll option with `optionId`. | ||
| /// | ||
| /// Live votes for other options and answers are ignored, and a vote changed | ||
| /// to another option is removed. Setting [filter] later changes only the | ||
| /// query; live votes stay limited to this option. | ||
| StreamPollVoteListController.option({ |
There was a problem hiding this comment.
Same as #3059: StreamPollVoteListController.option(...) reads as if the controller were an option. Suggest forOption (paired with forAnswers below), which reads as "the vote list for this option". Singular, since it takes one optionId.
Also: "live votes" isn't defined anywhere; saying when the votes arrive is clearer.
| /// Creates a Stream poll vote list controller that lists only the votes for | |
| /// the poll option with `optionId`. | |
| /// | |
| /// Live votes for other options and answers are ignored, and a vote changed | |
| /// to another option is removed. Setting [filter] later changes only the | |
| /// query; live votes stay limited to this option. | |
| StreamPollVoteListController.option({ | |
| /// Creates a Stream poll vote list controller that lists only the votes for | |
| /// the poll option with `optionId`. | |
| /// | |
| /// Votes for other options and answers cast while the list is loaded are | |
| /// ignored, and a vote changed to another option is removed. Setting [filter] | |
| /// later changes only the query; incoming votes stay limited to this option. | |
| StreamPollVoteListController.forOption({ |
There was a problem hiding this comment.
Renamed to forOption and applied the wording in 04862ec.
| /// Creates a Stream poll vote list controller that lists only the answers of | ||
| /// the poll. | ||
| /// | ||
| /// Live votes for poll options are ignored. Setting [filter] later changes | ||
| /// only the query; live votes stay limited to answers. | ||
| StreamPollVoteListController.answers({ |
There was a problem hiding this comment.
Pair with forOption above, and the same "live votes" wording fix.
| /// Creates a Stream poll vote list controller that lists only the answers of | |
| /// the poll. | |
| /// | |
| /// Live votes for poll options are ignored. Setting [filter] later changes | |
| /// only the query; live votes stay limited to answers. | |
| StreamPollVoteListController.answers({ | |
| /// Creates a Stream poll vote list controller that lists only the answers of | |
| /// the poll. | |
| /// | |
| /// Option votes cast while the list is loaded are ignored. Setting [filter] | |
| /// later changes only the query; incoming votes stay limited to answers. | |
| StreamPollVoteListController.forAnswers({ |
There was a problem hiding this comment.
Renamed to forAnswers and applied the wording in 04862ec.
| /// [StreamPollVoteListController.option] or | ||
| /// [StreamPollVoteListController.answers] ignores votes for other options or | ||
| /// votes that aren't answers, respectively. |
There was a problem hiding this comment.
Rename to match forOption / forAnswers, rewrapped to stay within 80 columns.
| /// [StreamPollVoteListController.option] or | |
| /// [StreamPollVoteListController.answers] ignores votes for other options or | |
| /// votes that aren't answers, respectively. | |
| /// [StreamPollVoteListController.forOption] or | |
| /// [StreamPollVoteListController.forAnswers] ignores votes for other options | |
| /// or votes that aren't answers, respectively. |
| /// [StreamPollVoteListController.option] or | ||
| /// [StreamPollVoteListController.answers] instead removes a vote that is no | ||
| /// longer for that option or isn't an answer, respectively. |
There was a problem hiding this comment.
Rename to match forOption / forAnswers, rewrapped to stay within 80 columns.
| /// [StreamPollVoteListController.option] or | |
| /// [StreamPollVoteListController.answers] instead removes a vote that is no | |
| /// longer for that option or isn't an answer, respectively. | |
| /// [StreamPollVoteListController.forOption] or | |
| /// [StreamPollVoteListController.forAnswers] instead removes a vote that is | |
| /// no longer for that option or isn't an answer, respectively. |
|
|
||
| void _initializeController() { | ||
| _controller = StreamPollVoteListController( | ||
| _controller = StreamPollVoteListController.answers( |
There was a problem hiding this comment.
Rename to match forOption / forAnswers.
| _controller = StreamPollVoteListController.answers( | |
| _controller = StreamPollVoteListController.forAnswers( |
| group('when the list is scoped to an option', () { | ||
| test('queries only the votes for the scoped option', () async { | ||
| final filter = await _queriedFilter( | ||
| (channel) => StreamPollVoteListController.option( |
There was a problem hiding this comment.
Rename to match forOption / forAnswers.
| (channel) => StreamPollVoteListController.option( | |
| (channel) => StreamPollVoteListController.forOption( |
| group('when the list is scoped to answers', () { | ||
| test('queries only the answers', () async { | ||
| final filter = await _queriedFilter( | ||
| (channel) => StreamPollVoteListController.answers( |
There was a problem hiding this comment.
Rename to match forOption / forAnswers.
| (channel) => StreamPollVoteListController.answers( | |
| (channel) => StreamPollVoteListController.forAnswers( |
| }) { | ||
| return _loadedController( | ||
| votes: votes, | ||
| create: (channel) => StreamPollVoteListController.option( |
There was a problem hiding this comment.
Rename to match forOption / forAnswers.
| create: (channel) => StreamPollVoteListController.option( | |
| create: (channel) => StreamPollVoteListController.forOption( |
| StreamController<Event> events | ||
| })> _loadedAnswersController() { | ||
| return _loadedController( | ||
| create: (channel) => StreamPollVoteListController.answers( |
There was a problem hiding this comment.
Rename to match forOption / forAnswers.
| create: (channel) => StreamPollVoteListController.answers( | |
| create: (channel) => StreamPollVoteListController.forAnswers( |
|
|
||
| ✅ Added | ||
|
|
||
| - Added `StreamPollVoteListController.option` and `StreamPollVoteListController.answers`, which list only a poll's votes for one option or only its answers. |
There was a problem hiding this comment.
Rename to match forOption / forAnswers.
| - Added `StreamPollVoteListController.option` and `StreamPollVoteListController.answers`, which list only a poll's votes for one option or only its answers. | |
| - Added `StreamPollVoteListController.forOption` and `StreamPollVoteListController.forAnswers`, which list only a poll's votes for one option or only its answers. |
…ption and forAnswers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks! Also trimmed the "Notes:" section in the description down to the compatibility note and the iOS comparison. |
Submit a pull request
Linear: FLU-975
Github Issue: #
CLA
Description of the pull request
Port of #3059 to
v9. Stacked on #3058 (thev9port of #3057) — review that first; this PR's base is its branch.StreamPollOptionVotesDialogandStreamPollCommentsDialogscoped theirStreamPollVoteListControlleronly with aFilter(option_id/is_answer), which applies to the REST query alone. Live events went through the defaultStreamPollVoteEventHandler, which adds every cast vote and upserts every changed vote by id. So:The SDK can't evaluate an arbitrary
Filterlocally, sostream_chat_flutter_coregets two constructors that tell the controller what the list covers:StreamPollVoteListController.forOption(channel:, pollId:, optionId:)StreamPollVoteListController.forAnswers(channel:, pollId:)Each queries only those votes and makes the default handler ignore cast votes outside the list and remove a vote changed out of it. Both dialogs use them.
Additive only: the default constructor and
.fromValuebehave as before, andStreamPollVoteEventHandler's signatures are unchanged.This matches iOS, whose
PollVoteListQuery(pollId:optionId:)only links a non-answer vote whenquery.optionId == vote.optionId.Same change as #3059; only formatting (80 columns) and the sheet → dialog naming differ.
Testing
stream_poll_vote_list_controller_test.dart(fix(core): ignore other polls' votes inStreamPollVoteListController(v9) #3058's file): option and answers scopes — the queried filter, cast votes inside/outside the scope, votes changed into/out of an option, answers vs option votes — plus whole-poll removal and change. The out-of-scope tests fail without the fix.stream_poll_option_votes_dialog_test.dartandstream_poll_comments_dialog_test.dart: an other-option vote isn't listed, a vote changed to another option stops being listed, an option vote isn't shown as a comment. They fail on the old dialogs.stream_chat_flutter_coresuite passes.Screenshots / Videos
🤖 Generated with Claude Code