From c66f358aec778155d0f0430fc15563ec3c241e04 Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Fri, 14 Sep 2018 14:56:34 +0300 Subject: [PATCH] Fix: fuzzy location did not change after listing location changed. --- src/components/SearchMap/SearchMap.js | 4 +++- src/containers/ListingPage/SectionMapMaybe.js | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/SearchMap/SearchMap.js b/src/components/SearchMap/SearchMap.js index db100728..0c02cac8 100644 --- a/src/components/SearchMap/SearchMap.js +++ b/src/components/SearchMap/SearchMap.js @@ -79,7 +79,9 @@ const reducedToArray = mapListings => { const withCoordinatesObfuscated = listings => { return listings.map(listing => { const { id, attributes, ...rest } = listing; - const geolocation = obfuscatedCoordinates(attributes.geolocation, id ? id.uuid : null); + const origGeolocation = attributes.geolocation; + const cacheKey = id ? `${id.uuid}_${origGeolocation.lat}_${origGeolocation.lng}` : null; + const geolocation = obfuscatedCoordinates(origGeolocation, cacheKey); return { id, ...rest, diff --git a/src/containers/ListingPage/SectionMapMaybe.js b/src/containers/ListingPage/SectionMapMaybe.js index a6d0127c..a298620e 100644 --- a/src/containers/ListingPage/SectionMapMaybe.js +++ b/src/containers/ListingPage/SectionMapMaybe.js @@ -24,9 +24,10 @@ class SectionMapMaybe extends Component { const address = publicData.location ? publicData.location.address : ''; const classes = classNames(rootClassName || css.sectionMap, className); + const cacheKey = listingId ? `${listingId.uuid}_${geolocation.lat}_${geolocation.lng}` : null; const mapProps = config.maps.fuzzy.enabled - ? { obfuscatedCenter: obfuscatedCoordinates(geolocation, listingId ? listingId.uuid : null) } + ? { obfuscatedCenter: obfuscatedCoordinates(geolocation, cacheKey) } : { address, center: geolocation }; const map = ;