Hook to be called on the property show page which builds a search from the
current property and adds to the search history to the search_history
indexedDB store if no history is already present.
This search is subsequently used to build the url for the BackToSearchLink.
Due to the async behaviour of indexedDB transactions, the useEffect in the
BackToSearchLink runs before the addToStore has completed and so finds no
search history and does not set the correct search url.
Calling the functionality to generate the search from the property from inside
the BackToSearchLink results in multiple duplicate searches being added to
the search_history store if more than one BackToSearchLink included on the
property show.
In order to circumvent this, the useGenerateSearchFromProperty hook sets the
initialSearch redux state after adding the search to the indexedDB store.
This in turn reruns the useEffect in the BackToSearchLink which can then
successfully set the correct search url.
Hook to be called on the property show page which builds a search from the current property and adds to the search history to the
search_historyindexedDB store if no history is already present. This search is subsequently used to build the url for the BackToSearchLink.Due to the async behaviour of indexedDB transactions, the
useEffectin the BackToSearchLink runs before theaddToStorehas completed and so finds no search history and does not set the correct search url.Calling the functionality to generate the search from the property from inside the BackToSearchLink results in multiple duplicate searches being added to the
search_historystore if more than one BackToSearchLink included on the property show.In order to circumvent this, the
useGenerateSearchFromPropertyhook sets theinitialSearchredux state after adding the search to the indexedDB store. This in turn reruns theuseEffectin the BackToSearchLink which can then successfully set the correct search url.