Skip to content

Commit

Permalink
fix: Do not setUri on HomeView's blur if no trackedWebviewInnerUri
Browse files Browse the repository at this point in the history
#82 introduced `trackedWebviewInnerUri` state to keep track of
WebView's URI

On HomeView's blur, we would synchronize latest
`trackedWebviewInnerUri` state into the `uri` state

If the first user's action into the WebView is to open a cozy-app, then
the HomeView's would blur with `trackedWebviewInnerUri` being null
(because no navigation occurred inside of the WebView to trigger the
`setTrackedWebviewInnerUri` event)

This would result to calling `setUri(null)` in the blur event

This behaviour was invisible to the user as `uri` would be set to
cozy-home's root URL directly after that

But a side effect of this is the CozyProxyWebView being unmount and
remount, which would trigger the `index.html` generation process, which
is unwanted

By conditionally calling `setUri` based on `trackedWebviewInnerUri`
nullity will prevent this behaviour
  • Loading branch information
Ldoppea committed Sep 21, 2022
1 parent 4adca05 commit 476cc38
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/screens/home/components/HomeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ const HomeView = ({ route, navigation, setLauncherContext, setBarStyle }) => {
useEffect(() => {
const unsubscribe = navigation.addListener('blur', () => {
didBlurOnce.current = true
setUri(trackedWebviewInnerUri)
if (trackedWebviewInnerUri) {
setUri(trackedWebviewInnerUri)
}
})

return unsubscribe
Expand Down

0 comments on commit 476cc38

Please sign in to comment.