Update/frontend logic #30 #33

Merged
KevinMidboe merged 19 commits from update/frontend_logic into master 2017-09-26 22:47:26 +00:00
Showing only changes of commit b219242787 - Show all commits

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 => {
this.setState({ if (this.state.page === 1) {
responseMovieList: responseData.results.map(searchResultItem => this.createMovieObjects(searchResultItem)), this.setState({
lastApiCallURI: uri // Save the value of the last sucessfull api call responseMovieList: responseData.results.map(searchResultItem => this.createMovieObjects(searchResultItem)),
}) 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(() => {