Added infinate scroll to lists also.

This commit is contained in:
2017-09-21 15:04:53 +02:00
parent 00d000b8f8
commit b219242787

View File

@@ -136,8 +136,6 @@ class SearchRequest extends React.Component {
}) })
} else { } else {
let responseMovieObjects = responseData.results.map(searchResultItem => this.createMovieObjects(searchResultItem)); let responseMovieObjects = responseData.results.map(searchResultItem => this.createMovieObjects(searchResultItem));
console.log(responseMovieObjects)
console.log(this.state.responseMovieList)
let growingReponseMovieObjectList = this.state.responseMovieList.concat(responseMovieObjects); let growingReponseMovieObjectList = this.state.responseMovieList.concat(responseMovieObjects);
this.setState({ this.setState({
responseMovieList: growingReponseMovieObjectList, responseMovieList: growingReponseMovieObjectList,
@@ -177,10 +175,19 @@ class SearchRequest extends React.Component {
// mapped as a movieObject. // mapped as a movieObject.
response.json() response.json()
.then(responseData => { .then(responseData => {
if (this.state.page === 1) {
this.setState({ this.setState({
responseMovieList: responseData.results.map(searchResultItem => this.createMovieObjects(searchResultItem)), responseMovieList: responseData.results.map(searchResultItem => this.createMovieObjects(searchResultItem)),
lastApiCallURI: uri // Save the value of the last sucessfull api call lastApiCallURI: uri // Save the value of the last sucessfull api call
}) })
} else {
let responseMovieObjects = responseData.results.map(searchResultItem => this.createMovieObjects(searchResultItem));
let growingReponseMovieObjectList = this.state.responseMovieList.concat(responseMovieObjects);
this.setState({
responseMovieList: growingReponseMovieObjectList,
lastApiCallURI: uri // Save the value of the last sucessfull api call
})
}
}) })
}) })
.catch(() => { .catch(() => {