Skip to content

Commit c15b9d5

Browse files
authored
Merge pull request #59 from BuildFire/fix/map-locations-listing
handle map hidden markers on initialize - WEB2-12924
2 parents ab10796 + 15c1eea commit c15b9d5

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/widget/js/views/mapView.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,14 @@ const triggerSearchOnMapIdle = () => {
9696
}
9797

9898
MapSearchService.searchLocations().then((_data) => {
99-
handleMapSearchResponse(_data);
100-
clearMapViewList();
101-
renderListingLocations(state.listLocations);
99+
handleMapSearchResponse(_data).then(() => {
100+
clearMapViewList();
101+
renderListingLocations(state.listLocations);
102+
});
102103
});
103104
};
104105

105-
const handleMapSearchResponse = (data) => {
106+
const handleMapSearchResponse = (data) => new Promise((resolve, reject) => {
106107
if (!data.aggregateLocations || !data.aggregateLocations.length) {
107108
if (!state.listLocations.length) {
108109
// if there's no result and no cached data then call "renderListingLocations" to show the empty state
@@ -143,7 +144,7 @@ const handleMapSearchResponse = (data) => {
143144
if (searchableTitles && searchableTitles.length > 0) {
144145
state.searchableTitles = searchableTitles;
145146
return MapSearchService.searchLocations().then((_data) => {
146-
handleMapSearchResponse(_data);
147+
resolve(handleMapSearchResponse(_data));
147148
});
148149
}
149150
}
@@ -155,11 +156,11 @@ const handleMapSearchResponse = (data) => {
155156

156157
if (!state.fetchingEndReached && state.listLocations.length < 200) {
157158
return MapSearchService.searchLocations().then((_data) => {
158-
handleMapSearchResponse(_data);
159+
resolve(handleMapSearchResponse(_data));
159160
});
160161
}
161162

162-
return result;
163-
};
163+
return resolve(state.listLocations);
164+
});
164165

165166
export default { renderListingLocations, clearMapViewList, handleMapSearchResponse };

src/widget/widget.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,8 @@ const handleCPSync = (message) => {
13711371
state.clearLocations();
13721372
searchLocations().then((result) => {
13731373
mapView.clearMapViewList();
1374-
mapView.renderListingLocations(state.listLocations);
1374+
mapView.renderListingLocations(result);
1375+
result.forEach((location) => state.maps.map.addMarker(location, handleMarkerClick));
13751376
});
13761377
}
13771378
}

0 commit comments

Comments
 (0)