Fixed hash change for links

no issue

- Hash handler was not updating Portal state if it pointed to a Portal link, which caused the need for a full refresh to reflect new link triggers
- Updates hash handler to use handle both preview and link states
This commit is contained in:
Rish 2020-10-02 19:57:43 +05:30
parent bcf2b5872b
commit 74a7232d0c

View File

@ -109,7 +109,7 @@ export default class App extends React.Component {
// Listen to preview mode changes
this.hashHandler = () => {
this.updateStateForPreview();
this.updateStateForPreviewLinks();
};
window.addEventListener('hashchange', this.hashHandler, false);
} catch (e) {
@ -295,13 +295,16 @@ export default class App extends React.Component {
}
/**Handle state update for preview url changes */
updateStateForPreview() {
updateStateForPreviewLinks() {
const {site: previewSite, ...restPreviewData} = this.fetchPreviewData();
const {site: linkSite, ...restLinkData} = this.fetchLinkData();
this.setState({
site: {
...this.state.site,
...(linkSite || {}),
...(previewSite || {})
},
...restLinkData,
...restPreviewData
});
}