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

fix: Stabilize opening connectors on the HomeView #82

Merged
merged 1 commit into from
Feb 23, 2022

Conversation

Ldoppea
Copy link
Member

@Ldoppea Ldoppea commented Feb 10, 2022

#74 introduced the ability to open a connector from the cozy-store
webview

This implementation had a side effect as the requested connector was
kept in the application state which would trigger the connector display
after each re-render

For example if the user opens a connector from the store, closes it and
the navigate to cozy-drive, then when navigating back to the Home, the
connector would be displayed again

To prevent this we now keep track of the webview's url in real time and
then use the navigation's focus and blur events to fix the rendered
url on the native context

We also clear the navigation konnector param when consumed. Which
would prevent an unexpected re-render of the connector after closing it

This new implementation does not need to inject a javascript chunk to
handle the navigation, so we deleted interceptHashAndNavigate method

@Ldoppea Ldoppea force-pushed the fix/stabilize-connectors-opening-from-store branch 2 times, most recently from 13bfe90 to 44c1b3d Compare February 10, 2022 10:47
@acezard acezard self-requested a review February 10, 2022 13:32
src/components/webviews/CozyWebView.js Show resolved Hide resolved
src/libs/functions/routeHelpers.js Show resolved Hide resolved
src/screens/home/components/HomeView.js Show resolved Hide resolved
src/screens/home/components/HomeView.js Show resolved Hide resolved
src/screens/home/components/HomeView.js Outdated Show resolved Hide resolved
#74 introduced the ability to open a connector from the cozy-store
webview

This implementation had a side effect as the requested connector was
kept in the application state which would trigger the connector display
after each re-render

For example if the user opens a connector from the store, closes it and
the navigate to cozy-drive, then when navigating back to the Home, the
connector would be displayed again

To prevent this we now keep track of the webview's url in real time and
then use the navigation's `focus` and `blur` events to fix the rendered
url on the native context

We also clear the navigation `konnector` param when consumed. Which
would prevent an unexpected re-render of the connector after closing it

This new implementation does not need to inject a javascript chunk to
handle the navigation, so we deleted `interceptHashAndNavigate` method
@Ldoppea Ldoppea force-pushed the fix/stabilize-connectors-opening-from-store branch from 44c1b3d to b8fa33b Compare February 22, 2022 18:44
@Ldoppea Ldoppea mentioned this pull request Feb 22, 2022
@acezard acezard self-requested a review February 23, 2022 07:36
@Ldoppea Ldoppea merged commit 78478bd into master Feb 23, 2022
@Ldoppea Ldoppea deleted the fix/stabilize-connectors-opening-from-store branch February 23, 2022 13:48
Ldoppea added a commit that referenced this pull request Sep 21, 2022
#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
Ldoppea added a commit that referenced this pull request Sep 22, 2022
#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants