From cd01d694e7c48466daa646370fd07a7f29d9ba49 Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Wed, 4 Apr 2018 16:36:56 +0300 Subject: [PATCH] Remove unused fetchMoreListingsToMap --- src/containers/SearchPage/SearchPage.js | 54 ------------------------- 1 file changed, 54 deletions(-) diff --git a/src/containers/SearchPage/SearchPage.js b/src/containers/SearchPage/SearchPage.js index b6bd7784..4857ca9b 100644 --- a/src/containers/SearchPage/SearchPage.js +++ b/src/containers/SearchPage/SearchPage.js @@ -42,8 +42,6 @@ import css from './SearchPage.css'; // Current design has max 3 columns 12 is divisible by 2 and 3 // So, there's enough cards to fill all columns on full pagination pages const RESULT_PAGE_SIZE = 24; -const MAX_SEARCH_RESULT_PAGE_SIZE_ON_MAP = 80; // max page size is 100 in API -const MAX_SEARCH_RESULT_PAGES_ON_MAP = 1; // page size * n pages = number of listings shown on a map. const MODAL_BREAKPOINT = 768; // Search is in modal on mobile layout const SEARCH_WITH_MAP_DEBOUNCE = 300; // Little bit of debounce before search is initiated. const BOUNDS_FIXED_PRECISION = 8; @@ -77,18 +75,12 @@ export class SearchPageComponent extends Component { this.searchMapListingsInProgress = false; this.onIdle = debounce(this.onIdle.bind(this), SEARCH_WITH_MAP_DEBOUNCE); - this.fetchMoreListingsToMap = this.fetchMoreListingsToMap.bind(this); this.onOpenMobileModal = this.onOpenMobileModal.bind(this); this.onCloseMobileModal = this.onCloseMobileModal.bind(this); } - componentDidMount() { - this.fetchMoreListingsToMap(this.props.location); - } - componentWillReceiveProps(nextProps) { if (!isEqual(this.props.location, nextProps.location)) { - this.fetchMoreListingsToMap(nextProps.location); // If no mapSearch url parameter is given, this is original location search const { mapSearch } = parse(nextProps.location.search, { @@ -149,52 +141,6 @@ export class SearchPageComponent extends Component { } } - fetchMoreListingsToMap(location) { - // TODO Remove this function. - // Temporarily just return immediately to avoid merge conflicts. - return; - - // eslint-disable-next-line no-unreachable - const { onSearchMapListings } = this.props; - const searchInURL = parse(location.search, { - latlng: ['origin'], - latlngBounds: ['bounds'], - }); - - const perPage = MAX_SEARCH_RESULT_PAGE_SIZE_ON_MAP; - const page = 1; - const { address, country, origin, ...rest } = searchInURL; - const originMaybe = config.sortSearchByDistance ? { origin } : {}; - const searchParamsForMapResults = { - ...rest, - ...originMaybe, - include: ['images'], - page, - perPage, - 'fields.image': ['variants.landscape-crop', 'variants.landscape-crop2x'], - 'limit.images': 1, - }; - this.searchMapListingsInProgress = true; - - // Search more listings for map - onSearchMapListings(searchParamsForMapResults) - .then(response => { - const hasNextPage = - page < response.data.meta.totalPages && page < MAX_SEARCH_RESULT_PAGES_ON_MAP; - if (hasNextPage) { - onSearchMapListings({ ...searchParamsForMapResults, page: page + 1 }); - } else { - this.searchMapListingsInProgress = false; - } - }) - .catch(error => { - // In case of error, stop recursive loop and report error. - // TODO: Show and error in the listings column - // eslint-disable-next-line no-console - console.error(`An error (${error} occured while trying to retrieve map listings`); - }); - } - // Invoked when a modal is opened from a child component, // for example when a filter modal is opened in mobile view onOpenMobileModal() {