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
Refactor decidePolicyForNavigationAction #94
Refactor decidePolicyForNavigationAction #94
Conversation
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.
This mostly seems good, but it looks like the "login" use case is not handled properly.
A user should be able to go and come back from the log in screens. If you try logging in with these refactoring, it should be clear what I mean. Other than that, it looks good!
|
Oops! Hopefully fixed now and tests added |
|
Does this PR also fix issue with mailto link in contacts? (#97) |
|
It does not, I believe. But it's related. I'll give that a look ASAP. @Ceri-anne I'll merge soon. Travis is giving false failures. Will figure it out tomorrow. If you want to give #97 a look and include the fix in this PR before it gets merged, be my guest. Otherwise we'll get to it after. |
|
I'll add the fix for #97 before it gets merged @benhalpern. There's a couple of linting errors to fix too so I'll do those |
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.
Would it be cleaner to move navigationPolicy to use a switch statement? I.e.
switch url {
case url.scheme == "mailto":
openURL(url)
return .cancel
case url.absoluteString == "about:blank":
return .allow
case isAuthLink(url):
return .allow
case url.host != "dev.to" && navigationType.rawValue == 0:
loadInBrowserView(url: url)
return .cancel
default:
return .allow
}|
Yep! Good thinking 😊 Although we’re not switching on the url directly... |
|
Travis is failing but I think it's misconfigured. I'll be merging this later today. |
@Ceri-anne You are totally right! 😁 What about this? if url.scheme == "mailto" {
openURL(url)
return .cancel
}
if url.absoluteString == "about:blank" {
return .allow
}
if isAuthLink(url) {
return .allow
}
if url.host != "dev.to" && navigationType.rawValue == 0 {
loadInBrowserView(url: url)
return .cancel
}
return .allowJust think that it would make it a bit more readable for new comers.. |
|
I agree that it’s more readable but it also implies that those if statements can be reordered and it would still work but that’s not true |
Refactored decidePolicyForNavigationAction function to remove force unwraps and hopefully make intent clearer