Skip to content

Commit 3ddc690

Browse files
author
MritunjayTiwari14
committed
poll: Add UI feedback on poll delay.
We replaced the unawaited call to sendSubmessage() with an awaited call. This ensures that the operation's start and completion can be tracked, which makes it possible to implement a loading indicator. With the previous unawaited behavior, there was no reliable way to measure the duration of the process. Fixes: #1808
1 parent f304ec4 commit 3ddc690

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/widgets/poll.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,24 @@ class _PollWidgetState extends State<PollWidget> {
4949
}
5050

5151
void _toggleVote(PollOption option) async {
52+
final navigator = Navigator.of(context);
53+
54+
unawaited(showDialog(context: context,
55+
barrierDismissible: false,
56+
builder: (_) {
57+
return Center(child: CircularProgressIndicator());
58+
}
59+
));
60+
5261
final store = PerAccountStoreWidget.of(context);
5362
final op = option.voters.contains(store.selfUserId)
5463
? PollVoteOp.remove
5564
: PollVoteOp.add;
56-
unawaited(sendSubmessage(store.connection, messageId: widget.messageId,
65+
await(sendSubmessage(store.connection, messageId: widget.messageId,
5766
submessageType: SubmessageType.widget,
5867
content: PollVoteEventSubmessage(key: option.key, op: op)));
68+
69+
navigator.pop();
5970
}
6071

6172
@override

0 commit comments

Comments
 (0)