Skip to content

Commit

Permalink
Fix browser intial load (#1623)
Browse files Browse the repository at this point in the history
* Fix browser intial load

* Fix unit testing

Co-authored-by: Esteban Miño <efmino@uc.cl>
  • Loading branch information
andrepimenta and estebanmino authored Jun 10, 2020
1 parent 2abca82 commit 4e41b80
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 48 deletions.
40 changes: 1 addition & 39 deletions app/components/Views/BrowserTab/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,7 @@ exports[`Browser should render correctly 1`] = `
"zIndex": 1,
}
}
>
<WebView
allowsInlineMediaPlayback={true}
cacheEnabled={true}
injectedJavaScript={null}
javaScriptEnabled={true}
javascriptEnabled={true}
onError={[Function]}
onLoadEnd={[Function]}
onLoadProgress={[Function]}
onLoadStart={[Function]}
onMessage={[Function]}
onNavigationStateChange={[Function]}
onShouldStartLoadWithRequest={[Function]}
originWhitelist={
Array [
"http://*",
"https://*",
]
}
renderError={[Function]}
sendCookies={true}
source={
Object {
"uri": null,
}
}
style={
Object {
"flex": 1,
"zIndex": 1,
}
}
testID="browser-webview"
useSharedProcessPool={true}
useWebkit={true}
userAgent="Mozilla/5.0 (iPhone; CPU iPhone OS 13_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/76.0.3809.123 Mobile/15E148 Safari/605.1"
/>
</View>
/>
<View
style={
Object {
Expand Down
11 changes: 2 additions & 9 deletions app/components/Views/BrowserTab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1125,21 +1125,14 @@ export class BrowserTab extends PureComponent {
current && current.reload();
};

forceReload = initialReload => {
forceReload = () => {
this.isReloading = true;

this.toggleOptionsIfNeeded();
// As we're reloading to other url we should remove this callback
this.approvalRequest = undefined;
const url2Reload = this.state.inputValue;

// If it is the first time the component is being mounted, there should be no cache problem and no need for remounting the component
if (initialReload) {
this.isReloading = false;
this.go(url2Reload);
return;
}

// Force unmount the webview to avoid caching problems
this.setState({ forceReload: true }, () => {
// Make sure we're not calling last mounted webview during this time threshold
Expand All @@ -1157,7 +1150,7 @@ export class BrowserTab extends PureComponent {
if (this.webview && this.webview.current) {
this.webview.current.stopLoading();
}
this.forceReload(true);
this.forceReload();
this.init();
};

Expand Down

0 comments on commit 4e41b80

Please sign in to comment.