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

Refactor decidePolicyForNavigationAction #94

Conversation

Ceri-anne
Copy link
Contributor

Refactored decidePolicyForNavigationAction function to remove force unwraps and hopefully make intent clearer

Copy link
Contributor

@benhalpern benhalpern left a 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!

@Ceri-anne
Copy link
Contributor Author

Oops! Hopefully fixed now and tests added

@nebloc
Copy link

nebloc commented Nov 15, 2018

Does this PR also fix issue with mailto link in contacts? (#97)

@benhalpern
Copy link
Contributor

@nebloc

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.

@Ceri-anne
Copy link
Contributor Author

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

Copy link

@nebloc nebloc left a 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
 }

@Ceri-anne
Copy link
Contributor Author

Ceri-anne commented Nov 17, 2018

Yep! Good thinking 😊 Although we’re not switching on the url directly...

@benhalpern
Copy link
Contributor

Travis is failing but I think it's misconfigured. I'll be merging this later today.

@nebloc
Copy link

nebloc commented Nov 19, 2018

Yep! Good thinking blush Although we’re not switching on the url directly...

@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 .allow

Just think that it would make it a bit more readable for new comers..

@Ceri-anne
Copy link
Contributor Author

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

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

Successfully merging this pull request may close these issues.

None yet

3 participants