From e14cd98903a7d9ec6fbe14a7b9f12d25ad675ffc Mon Sep 17 00:00:00 2001 From: Hannu Lyytikainen Date: Tue, 21 Aug 2018 11:54:50 +0300 Subject: [PATCH] Add path check for search page --- src/containers/SearchPage/SearchPage.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/containers/SearchPage/SearchPage.js b/src/containers/SearchPage/SearchPage.js index 447b2e0a..44a5093a 100644 --- a/src/containers/SearchPage/SearchPage.js +++ b/src/containers/SearchPage/SearchPage.js @@ -16,7 +16,7 @@ import { sdkBoundsToFixedCoordinates, hasSameSDKBounds, } from '../../util/googleMaps'; -import { createResourceLocatorString } from '../../util/routes'; +import { createResourceLocatorString, pathByRouteName } from '../../util/routes'; import { parse, stringify } from '../../util/urlHelpers'; import { propTypes } from '../../util/types'; import { getListingsById } from '../../ducks/marketplaceData.duck'; @@ -116,10 +116,17 @@ export class SearchPageComponent extends Component { const viewportBoundsChanged = this.viewportBounds && !hasSameSDKBounds(this.viewportBounds, viewportBounds); + const routes = routeConfiguration(); + const searchPagePath = pathByRouteName('SearchPage', routes); + const currentPath = window && window.location && window.location.pathname; + + // When using the ReusableMapContainer onIdle can fire from other pages than SearchPage too + const isSearchPage = currentPath === searchPagePath; + // If mapSearch url param is given (and we have not just opened mobile map modal) // or original location search is rendered once, // we start to react to 'bounds_changed' event by generating new searches - if (viewportBoundsChanged && !this.modalOpenedBoundsChange) { + if (viewportBoundsChanged && !this.modalOpenedBoundsChange && isSearchPage) { const originMaybe = config.sortSearchByDistance ? { origin: googleLatLngToSDKLatLng(viewportGMapBounds.getCenter()) } : {}; @@ -132,9 +139,7 @@ export class SearchPageComponent extends Component { }; this.viewportBounds = viewportBounds; - history.push( - createResourceLocatorString('SearchPage', routeConfiguration(), {}, searchParams) - ); + history.push(createResourceLocatorString('SearchPage', routes, {}, searchParams)); } else { this.viewportBounds = viewportBounds; this.modalOpenedBoundsChange = false;