Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

[WIP] Open external links in external browser #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ahstro
Copy link
Contributor

@ahstro ahstro commented Aug 29, 2019

Okay, so I was playing around with the code and wanted to see if I could get external links (i.e. ones not hosted on Settings.BASE_URL) to open in the external browser instead of in the WebView, but ran into a bit of a hurdle and wanted to see if anyone other than me want this before continuing.

The code I've got now seems to work fine with converting any external link present when the page loads, but since the website is an SPA and some links are created after the page has been loaded, we're going to need to do some (possibly horrifying) magic to make those open externally, possibly with a MutationObserver, unless anyone has any better suggestions (please 🙏 ).

This PR is based on #20, so 448c193 shouldn't really be in this PR, sorry about the mess.

Create injected JavaScript in a single place and then inject it both as
a WebView prop and with the `injectJavaScript`-method on `onLoadEnd`.
This is preparatory for adding more injected JavaScript.
Opens external links present onLoadEnd in external browser, but doesn't
yet handle the SPA-aspect of the site
@@ -303,7 +310,7 @@ export default class App extends React.Component {
<StatusBar backgroundColor={this.styles.statusBar.backgroundColor} barStyle="default" />
<WebView
domStorageEnabled
injectedJavaScript={this.appInfoJavaScript}
injectedJavaScript={this.injectedJavaScript}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure this line is actually needed at all, since we're loading the same code on every onLoadEnd, but I donno 🤷‍♀️

@simison
Copy link
Contributor

simison commented Sep 5, 2019

I merged #20 so this is now good to rebase

@ahstro
Copy link
Contributor Author

ahstro commented Sep 5, 2019

Cool, I'll get on that asap :) Any input on whether this should be done or not, and if so, if my potential solution makes sense?

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

Successfully merging this pull request may close these issues.

None yet

2 participants