Fix pagination. Closes #17

This commit is contained in:
Lucas Verney 2016-08-11 01:05:33 +02:00
parent d8a7d4f66a
commit 4e12da3a22
9 changed files with 42 additions and 29 deletions

View File

@ -64,10 +64,11 @@ export default function (action, requestType, successType, failureType) {
* @param pageNumber Number of the page that was fetched.
*/
const fetchPaginatedItemsSuccess = function (jsonData, pageNumber, limit) {
const totalCount = jsonData.totalCount;
jsonData = _normalizeAPIResponse(jsonData);
// Compute the total number of pages
const nPages = Math.ceil(jsonData.result[itemName].length / limit);
const nPages = Math.ceil(totalCount / limit);
// Return success actions
return [

View File

@ -104,7 +104,6 @@ button.toggle {
*/
.main-panel {
padding: $mainPadding;
z-index: -10;
}
/*
@ -134,6 +133,10 @@ button.toggle {
}
@media (max-width: 991px) {
.main-panel {
z-index: -10;
}
.sidebar {
position: static;
}

View File

@ -36,6 +36,9 @@ class AlbumsPageIntl extends Component {
const currentPage = parseInt(this.props.location.query.page) || 1;
const nextPage = parseInt(nextProps.location.query.page) || 1;
if (currentPage != nextPage) {
// Unload data on page change
this.props.actions.clearPaginatedResults();
// Load new data
this.props.actions.loadAlbums({pageNumber: nextPage});
}
}

View File

@ -36,6 +36,9 @@ class ArtistsPageIntl extends Component {
const currentPage = parseInt(this.props.location.query.page) || 1;
const nextPage = parseInt(nextProps.location.query.page) || 1;
if (currentPage != nextPage) {
// Unload data on page change
this.props.actions.clearPaginatedResults();
// Load new data
this.props.actions.loadPaginatedArtists({pageNumber: nextPage});
}
}

View File

@ -36,6 +36,9 @@ class SongsPageIntl extends Component {
const currentPage = parseInt(this.props.location.query.page) || 1;
const nextPage = parseInt(nextProps.location.query.page) || 1;
if (currentPage != nextPage) {
// Unload data on page change
this.props.actions.clearPaginatedResults();
// Load new data
this.props.actions.loadPaginatedSongs({pageNumber: nextPage});
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long