'Back to results' handled properly
This commit is contained in:
@@ -9,9 +9,7 @@ export default class ListingDetails extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onBackClick() {
|
onBackClick() {
|
||||||
if (this.props.onBackClick) {
|
this.props.dispatch({type: 'BACK_TO_RESULTS'});
|
||||||
this.props.onBackClick();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
@@ -132,7 +132,6 @@ class Main extends React.Component {
|
|||||||
refreshListings() {
|
refreshListings() {
|
||||||
console.log('refreshListings');
|
console.log('refreshListings');
|
||||||
|
|
||||||
|
|
||||||
const map = this.map;
|
const map = this.map;
|
||||||
const {
|
const {
|
||||||
rooms,
|
rooms,
|
||||||
@@ -221,7 +220,6 @@ class Main extends React.Component {
|
|||||||
const prevSelected = this.findMarker(this.state.listingId);
|
const prevSelected = this.findMarker(this.state.listingId);
|
||||||
if (prevSelected) {
|
if (prevSelected) {
|
||||||
console.log('prevselected', prevSelected);
|
console.log('prevselected', prevSelected);
|
||||||
//prevSelected.marker.setIcon(this.defaultMarkerIcon());
|
|
||||||
prevSelected.marker.setIcon(this.visitedMarkerIcon());
|
prevSelected.marker.setIcon(this.visitedMarkerIcon());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,18 +247,6 @@ class Main extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onListingClick() {
|
|
||||||
this.setState({
|
|
||||||
listingDetails: true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
onBackClick() {
|
|
||||||
this.setState({
|
|
||||||
listingDetails: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get default marker icon
|
* Get default marker icon
|
||||||
*/
|
*/
|
||||||
@@ -359,13 +345,13 @@ class Main extends React.Component {
|
|||||||
imageIndex={this.state.imageIndex}
|
imageIndex={this.state.imageIndex}
|
||||||
dispatch={this.dispatch.bind(this)}
|
dispatch={this.dispatch.bind(this)}
|
||||||
descriptionExpanded={this.state.descriptionExpanded}
|
descriptionExpanded={this.state.descriptionExpanded}
|
||||||
onBackClick={this.onBackClick.bind(this)}/>);
|
/>);
|
||||||
} else {
|
} else {
|
||||||
children.push(<Filters filters={this.state.filters} dispatch={this.dispatch.bind(this)} onClose={this.onCloseClick.bind(this)}/>);
|
children.push(<Filters filters={this.state.filters} dispatch={this.dispatch.bind(this)} onClose={this.onCloseClick.bind(this)}/>);
|
||||||
children.push(<Listings
|
children.push(<Listings
|
||||||
listings={this.state.listings}
|
listings={this.state.listings}
|
||||||
dispatch={this.dispatch.bind(this)}
|
dispatch={this.dispatch.bind(this)}
|
||||||
onListingClick={this.onListingClick.bind(this)}/>);
|
/>);
|
||||||
}
|
}
|
||||||
const content = (
|
const content = (
|
||||||
<div className="right-content">
|
<div className="right-content">
|
||||||
|
|||||||
@@ -185,6 +185,19 @@ const onListingMouseOver = ({type, action}, component) => {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const backToResults = ({type, action}, component) => {
|
||||||
|
const prevSelected = component.findMarker(component.state.listingId);
|
||||||
|
component.setState({
|
||||||
|
listingId: undefined,
|
||||||
|
listingDetails: false
|
||||||
|
}, () => {
|
||||||
|
|
||||||
|
if (prevSelected) {
|
||||||
|
prevSelected.marker.setIcon(component.visitedMarkerIcon());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const handlers = {
|
const handlers = {
|
||||||
SET_MIN_PRICE: setMinPrice,
|
SET_MIN_PRICE: setMinPrice,
|
||||||
SET_MAX_PRICE: setMaxPrice,
|
SET_MAX_PRICE: setMaxPrice,
|
||||||
@@ -200,7 +213,8 @@ const handlers = {
|
|||||||
VIEW_LISTING_DETAILS: viewListingDetails,
|
VIEW_LISTING_DETAILS: viewListingDetails,
|
||||||
UPDATE_SEARCH: updateSearch,
|
UPDATE_SEARCH: updateSearch,
|
||||||
SET_CATEGORY: setCategory,
|
SET_CATEGORY: setCategory,
|
||||||
ON_LISTING_MOUSE_OVER: onListingMouseOver
|
ON_LISTING_MOUSE_OVER: onListingMouseOver,
|
||||||
|
BACK_TO_RESULTS: backToResults
|
||||||
};
|
};
|
||||||
|
|
||||||
export const handleMessage = ({ type, action }, component) => {
|
export const handleMessage = ({ type, action }, component) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user