-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Stabilize opening connectors on the HomeView
#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
- Loading branch information
Showing
4 changed files
with
63 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {get} from 'lodash' | ||
|
||
/** | ||
* Retrieve the specified route parameter and remove it from the navigation state | ||
* @param {string} paramName - Name of the parameter to retrieve | ||
* @param {*} route - Application's route | ||
* @param {*} navigation - Application's navigation | ||
* @returns the route parameter's value | ||
*/ | ||
export const consumeRouteParameter = (paramName, route, navigation) => { | ||
const param = get(route, `params.${paramName}`) | ||
|
||
if (param) { | ||
navigation.setParams({[paramName]: undefined}) | ||
} | ||
|
||
return param | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters