-
Notifications
You must be signed in to change notification settings - Fork 309
dialog [nfc]: Wrap showErrorDialog's return value #970
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
Conversation
c74d3cc
to
5c9b550
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small comments below, otherwise LGTM. Thanks!
lib/widgets/dialog.dart
Outdated
final Future<void> _closed; | ||
/// Resolves when the dialog is closed. | ||
Future<void> get closed => _closed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lib/widgets/lightbox.dart
Outdated
// Wait until the dialog is closed | ||
await dialog.closed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happily, I think the comment is now redundant and can be swept away :)
1e20eba
to
59fd8ae
Compare
Thanks for the review! Updated the PR. |
de48f34
to
59fd8ae
Compare
LGTM, thanks! Over to Greg. |
As a result, showErrorDialog no longer returns a Future that can be mistakenly awaited. The wrapped return value offers clarity on how the Future is supposed to be used. There is no user visible change because existing callers (other than lightbox's) that wait for its return value are all asynchronous handlers for UI elements like buttons, and waits unnecessarily. See also discussion zulip#937 (comment). Signed-off-by: Zixuan James Li <[email protected]>
Unlike ScaffoldFeatureController which inspired it, this class doesn't offer a way to control the dialog, so it's not really a "controller"; just call it DialogStatus. A private final field with a public getter (of the same type) is equivalent to just a public final field: nothing can set it, and any library can get it. Also generalize the description a bit: we currently use this only for AlertDialog, but it'd apply equally well for any dialog box.
59fd8ae
to
c5f4e93
Compare
Thanks to you both! Looks good; merging, with some tweaks to the interface on top: |
As a result, showErrorDialog no longer returns a Future that can be mistakenly awaited. The wrapped return value offers clarity on how the Future is supposed to be used.
There is no user visible change because existing callers (other than lightbox's) that wait for its return value are all asynchronous handlers for UI elements like buttons, and waits unnecessarily.
See also discussion
#937 (comment).