-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[url_launcher] When not fully loaded, clicking close causes the callback to not be triggered correctly. #8582
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
Changes from 1 commit
3403990
6082e8c
13e3058
87a4a3a
940b311
4f733e5
2c0d46b
4c258ab
2a095f2
39ef600
99359e7
a2c8559
1b53da5
68e865a
5e7b70e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…allback to not be triggered correctly.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -12,6 +12,7 @@ final class URLLaunchSession: NSObject, SFSafariViewControllerDelegate { | |||||
|
|
||||||
| private let completion: OpenInSafariCompletionHandler | ||||||
| private let url: URL | ||||||
| private var isLoadCompleted: Bool? | ||||||
|
|
||||||
| /// The Safari view controller used for displaying the URL. | ||||||
| let safariViewController: SFSafariViewController | ||||||
|
|
@@ -46,12 +47,16 @@ final class URLLaunchSession: NSObject, SFSafariViewControllerDelegate { | |||||
| } else { | ||||||
| completion(.success(.failedToLoad)) | ||||||
| } | ||||||
| isLoadCompleted = didLoadSuccessfully; | ||||||
| } | ||||||
|
|
||||||
| /// Called when the user finishes using the Safari view controller. | ||||||
| /// | ||||||
| /// - Parameter controller: The Safari view controller. | ||||||
| func safariViewControllerDidFinish(_ controller: SFSafariViewController) { | ||||||
| if isLoadCompleted == nil { | ||||||
| completion(.success(.failedToLoad)) | ||||||
|
||||||
| /// The URL did not load successfully. | |
| failedToLoad, |
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.
At first, I did consider adding a new InAppLoadResult to describe the close action, but it seems it could lead to confusion among developers. This is because, currently, after a successful load, clicking the close button does not trigger any callback.
Additionally, when the user clicks close before the loading is complete, triggering the failedToLoad callback seems reasonable in a broader sense, as the interruption of the loading process can be considered a loading failure.
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.
If this is the correct result, should we update this comment to indicate this case can happen if the user dismisses the Safari view before the initial load completes?
Do you think it’s possible to modify the comment like this:
// The URL did not load successfully (or close the SFSafariViewController earlier)
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.
Returning this will throw an exception saying there was an error loading the page, which seems misleading. I think a new Pigeon return type that Dart interprets to return false would be better.
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.
I created a new dismissed state to represent the current status.
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.
cc @stuartmorgan
Could you take another look?
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.
A nullable boolean should only be used when there are three conceptually different states. The code in this PR only actually recognizes two.