trying out

This commit is contained in:
Edin Dazdarevic
2017-04-07 04:02:01 +02:00
parent 6716dd3076
commit 5515774d17
6 changed files with 209 additions and 42 deletions

View File

@@ -129,7 +129,7 @@ class Main extends React.Component {
/*
* Refreshes search
*/
refreshListings() {
refreshListings(more = false) {
console.log('refreshListings');
const map = this.map;
@@ -150,7 +150,8 @@ class Main extends React.Component {
maxSize,
minPrice,
maxPrice,
category
category,
lastRecordId: this.state.lastRecordId
});
@@ -158,10 +159,19 @@ class Main extends React.Component {
return this.findMarker(id) != null;
}
properties.then(p => p.text()).then(p => {
properties
.then(p => {
const lastRecordId = p.headers.get('X-Last-Record-Id');
console.log('lastRecordId', lastRecordId, p.headers);
return {
body: p.text(),
lastRecordId: p.headers.get('X-Last-Record-Id')
};
})
.then(({body, lastRecordId}) => {
body.then(p => {
console.log('results_received: ', body, lastRecordId);
const data = JSON.parse(p);
console.log('results_received');
const listingExists = (id) => {
return data.findIndex(l => l._id === id) !== -1
@@ -241,9 +251,12 @@ class Main extends React.Component {
type: 'LISTINGS_LOADED',
action: {
listings: data,
newMarkers
newMarkers,
lastRecordId,
more
}
});
});
})
}
@@ -349,6 +362,7 @@ class Main extends React.Component {
} else {
children.push(<Filters filters={this.state.filters} dispatch={this.dispatch.bind(this)} onClose={this.onCloseClick.bind(this)}/>);
children.push(<Listings
loadingMore={this.state.loadingMore}
listings={this.state.listings}
dispatch={this.dispatch.bind(this)}
/>);