Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): fix StreamChannel not available in various poll dialogs #2082

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/stream_flutter_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ jobs:
channel: stable
cache: true
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}
# This step is needed due to https://github.com/actions/runner-images/issues/11279
- name: Install SQLite3
run: sudo apt-get update && sudo apt-get install -y sqlite3 libsqlite3-dev
- name: "Install Tools"
run: |
flutter pub global activate melos
Expand Down
6 changes: 6 additions & 0 deletions packages/stream_chat_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Upcoming

🐞 Fixed

- Fixed `StreamChannel` not available in the widget tree for various poll-related dialogs.

## 9.1.0

✅ Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,34 @@
return navigator.push(
MaterialPageRoute(
fullscreenDialog: true,
builder: (_) => ValueListenableBuilder(
valueListenable: messageNotifier,
builder: (context, message, child) {
final poll = message.poll;
if (poll == null) return const SizedBox.shrink();

final channel = StreamChannel.of(context).channel;

Future<void> onUpdateComment() async {
final commentText = await showPollAddCommentDialog(
context: context,
// We use the first answer as the initial value because the
// user can only add one comment per poll.
initialValue: poll.ownAnswers.firstOrNull?.answerText ?? '',
builder: (_) => StreamChannel(
channel: StreamChannel.of(context).channel,
child: ValueListenableBuilder(

Check warning on line 26 in packages/stream_chat_flutter/lib/src/poll/stream_poll_comments_dialog.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/poll/stream_poll_comments_dialog.dart#L24-L26

Added lines #L24 - L26 were not covered by tests
valueListenable: messageNotifier,
builder: (context, message, child) {
final poll = message.poll;

Check warning on line 29 in packages/stream_chat_flutter/lib/src/poll/stream_poll_comments_dialog.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/poll/stream_poll_comments_dialog.dart#L28-L29

Added lines #L28 - L29 were not covered by tests
if (poll == null) return const SizedBox.shrink();

final channel = StreamChannel.of(context).channel;

Check warning on line 32 in packages/stream_chat_flutter/lib/src/poll/stream_poll_comments_dialog.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/poll/stream_poll_comments_dialog.dart#L32

Added line #L32 was not covered by tests

Future<void> onUpdateComment() async {
final commentText = await showPollAddCommentDialog(

Check warning on line 35 in packages/stream_chat_flutter/lib/src/poll/stream_poll_comments_dialog.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/poll/stream_poll_comments_dialog.dart#L34-L35

Added lines #L34 - L35 were not covered by tests
context: context,
// We use the first answer as the initial value because the
// user can only add one comment per poll.
initialValue: poll.ownAnswers.firstOrNull?.answerText ?? '',

Check warning on line 39 in packages/stream_chat_flutter/lib/src/poll/stream_poll_comments_dialog.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/poll/stream_poll_comments_dialog.dart#L39

Added line #L39 was not covered by tests
);

if (commentText == null) return;
channel.addPollAnswer(message, poll, answerText: commentText);

Check warning on line 43 in packages/stream_chat_flutter/lib/src/poll/stream_poll_comments_dialog.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/poll/stream_poll_comments_dialog.dart#L43

Added line #L43 was not covered by tests
}

return StreamPollCommentsDialog(

Check warning on line 46 in packages/stream_chat_flutter/lib/src/poll/stream_poll_comments_dialog.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/poll/stream_poll_comments_dialog.dart#L46

Added line #L46 was not covered by tests
poll: poll,
onUpdateComment: onUpdateComment,
);

if (commentText == null) return;
channel.addPollAnswer(message, poll, answerText: commentText);
}

return StreamPollCommentsDialog(
poll: poll,
onUpdateComment: onUpdateComment,
);
},
},
),
),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@
return navigator.push(
MaterialPageRoute(
fullscreenDialog: true,
builder: (_) => ValueListenableBuilder(
valueListenable: messageNotifier,
builder: (context, message, child) {
final poll = message.poll;
if (poll == null) return const SizedBox.shrink();
if (option.id == null) return const SizedBox.shrink();
builder: (_) => StreamChannel(
channel: StreamChannel.of(context).channel,
child: ValueListenableBuilder(

Check warning on line 25 in packages/stream_chat_flutter/lib/src/poll/stream_poll_option_votes_dialog.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/poll/stream_poll_option_votes_dialog.dart#L23-L25

Added lines #L23 - L25 were not covered by tests
valueListenable: messageNotifier,
builder: (context, message, child) {
final poll = message.poll;

Check warning on line 28 in packages/stream_chat_flutter/lib/src/poll/stream_poll_option_votes_dialog.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/poll/stream_poll_option_votes_dialog.dart#L27-L28

Added lines #L27 - L28 were not covered by tests
if (poll == null) return const SizedBox.shrink();
if (option.id == null) return const SizedBox.shrink();

Check warning on line 30 in packages/stream_chat_flutter/lib/src/poll/stream_poll_option_votes_dialog.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/poll/stream_poll_option_votes_dialog.dart#L30

Added line #L30 was not covered by tests

return StreamPollOptionVotesDialog(
poll: poll,
option: option,
pollVotesCount: poll.voteCountsByOption[option.id],
);
},
return StreamPollOptionVotesDialog(

Check warning on line 32 in packages/stream_chat_flutter/lib/src/poll/stream_poll_option_votes_dialog.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/poll/stream_poll_option_votes_dialog.dart#L32

Added line #L32 was not covered by tests
poll: poll,
option: option,
pollVotesCount: poll.voteCountsByOption[option.id],

Check warning on line 35 in packages/stream_chat_flutter/lib/src/poll/stream_poll_option_votes_dialog.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/poll/stream_poll_option_votes_dialog.dart#L35

Added line #L35 was not covered by tests
);
},
),
),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
return navigator.push(
MaterialPageRoute(
fullscreenDialog: true,
builder: (context) {
return ValueListenableBuilder(
builder: (_) => StreamChannel(
channel: StreamChannel.of(context).channel,
child: ValueListenableBuilder(

Check warning on line 23 in packages/stream_chat_flutter/lib/src/poll/stream_poll_options_dialog.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/poll/stream_poll_options_dialog.dart#L21-L23

Added lines #L21 - L23 were not covered by tests
valueListenable: messageNotifier,
builder: (context, message, child) {
final poll = message.poll;
Expand All @@ -41,8 +42,8 @@
onRemoveVote: onRemoveVote,
);
},
);
},
),
),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,29 @@
return navigator.push(
MaterialPageRoute(
fullscreenDialog: true,
builder: (_) => ValueListenableBuilder(
valueListenable: messageNotifier,
builder: (context, message, child) {
final poll = message.poll;
if (poll == null) return const SizedBox.shrink();
builder: (_) => StreamChannel(
channel: StreamChannel.of(context).channel,
child: ValueListenableBuilder(

Check warning on line 34 in packages/stream_chat_flutter/lib/src/poll/stream_poll_results_dialog.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/poll/stream_poll_results_dialog.dart#L32-L34

Added lines #L32 - L34 were not covered by tests
valueListenable: messageNotifier,
builder: (context, message, child) {
final poll = message.poll;

Check warning on line 37 in packages/stream_chat_flutter/lib/src/poll/stream_poll_results_dialog.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/poll/stream_poll_results_dialog.dart#L36-L37

Added lines #L36 - L37 were not covered by tests
if (poll == null) return const SizedBox.shrink();

void onShowAllVotesPressed(PollOption option) {
showStreamPollOptionVotesDialog(
context: context,
messageNotifier: messageNotifier,
option: option,
);
}
void onShowAllVotesPressed(PollOption option) {
showStreamPollOptionVotesDialog(

Check warning on line 41 in packages/stream_chat_flutter/lib/src/poll/stream_poll_results_dialog.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/poll/stream_poll_results_dialog.dart#L40-L41

Added lines #L40 - L41 were not covered by tests
context: context,
messageNotifier: messageNotifier,
option: option,
);
}

return StreamPollResultsDialog(
poll: poll,
visibleVotesCount: 5,
onShowAllVotesPressed: onShowAllVotesPressed,
);
},
return StreamPollResultsDialog(

Check warning on line 48 in packages/stream_chat_flutter/lib/src/poll/stream_poll_results_dialog.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/poll/stream_poll_results_dialog.dart#L48

Added line #L48 was not covered by tests
poll: poll,
visibleVotesCount: 5,
onShowAllVotesPressed: onShowAllVotesPressed,
);
},
),
),
),
);
Expand Down
Loading