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

Callbacks for Information and Error dialogs #851

Merged
merged 11 commits into from
Apr 19, 2020

Conversation

obsti8383
Copy link
Contributor

Description:

Motivation: (from #752): "Whenever I display an error message to the user in the error dialog, I'd like to have some way of handling when this window is dismissed.
In the case of my app, any error that I display in the error dialog is a critical one, after which I do not expect the user to continue using the app, thus dismiss action must call: window.Close() and some other cleanup code (e.g. closing DB connection, stopping goroutines).
I think callback function on the error dialog dismiss would be helpful to accomplish this task."

This pull request implements this behaviour for information and error dialogs with new "xxxWithCallback" methods.

Fixes #752

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

Where applicable:

  • Public APIs match existing style.
  • Any breaking changes have a deprecation path or have been discussed.

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, much cleaner. I think there is one issue though, inline.

dialog/base.go Outdated Show resolved Hide resolved
Copy link
Member

@toaster toaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some small things.

dialog/base.go Outdated Show resolved Hide resolved
func() {
select {
case <-tapped:
case <-time.After(1 * time.Second):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's way too long IMO.

Suggested change
case <-time.After(1 * time.Second):
case <-time.After(100 * time.Millisecond):

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, when using test.Tap you don't have to do concurrency, it's synchronous. However, using a chan and the select makes the test independent from the implementation of test.Tap.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is still 1 second

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, fixed.

@obsti8383
Copy link
Contributor Author

@andydotxyz @toaster Should be fixed now. Hope the solution for saving the callback for Confirm dialogs is OK?

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good solution, but could be simpler - no need for the field as the scope for “originalCallback” is within a single method

dialog/base.go Outdated Show resolved Hide resolved
dialog/base.go Outdated Show resolved Hide resolved
Copy link
Member

@toaster toaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seconds -> milliseconds

dialog/information_test.go Outdated Show resolved Hide resolved
@andydotxyz
Copy link
Member

Thanks.
There was another instance of a 1 second wait that we all missed - but I'm going to merge now and tweak that area a little anyway.

@andydotxyz andydotxyz merged commit b3b172d into fyne-io:master Apr 19, 2020
@andydotxyz
Copy link
Member

That's great thanks.
I missed this before unfortunately but we try to limit master work to hotfixes, so please do larger work off 'develop' branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Callback on error dialog dismiss
3 participants