fixes
This commit is contained in:
@@ -20,9 +20,8 @@ moduleReducers[REQUEST_SHOP_PACKAGES] = (state, action) => {
|
|||||||
moduleReducers[RECIEVE_SHOP_PACKAGES] = (state = {}, action) => {
|
moduleReducers[RECIEVE_SHOP_PACKAGES] = (state = {}, action) => {
|
||||||
|
|
||||||
// implement paging
|
// implement paging
|
||||||
// paging is implemented in a way that with every request one more package is requested on top of
|
// paging is implemented in a way that requested number of packages is {page_size + 1}
|
||||||
// page size number
|
// this way if retrieved number of packages is greater than page size there may be more packages
|
||||||
// this means that if retrieved number of packages is greater than page size there may be more packages
|
|
||||||
|
|
||||||
const shopPage = action.page || 1;
|
const shopPage = action.page || 1;
|
||||||
let shopPackages = [];
|
let shopPackages = [];
|
||||||
@@ -30,9 +29,8 @@ moduleReducers[RECIEVE_SHOP_PACKAGES] = (state = {}, action) => {
|
|||||||
let retrievedShopPackages = action.shopPackages || [];
|
let retrievedShopPackages = action.shopPackages || [];
|
||||||
|
|
||||||
// append newly retrieved packages to existing ones if more packages are loaded
|
// append newly retrieved packages to existing ones if more packages are loaded
|
||||||
if (shopPage > state.shopPage) {
|
if (state.shopPage && shopPage > state.shopPage) {
|
||||||
shopPackages = state.loadedShopPackages || [];
|
shopPackages = state.loadedShopPackages || [];
|
||||||
|
|
||||||
// get ignored packages from previous request
|
// get ignored packages from previous request
|
||||||
const oldShopPackagesDiff = state.shopPackagesDiff || [];
|
const oldShopPackagesDiff = state.shopPackagesDiff || [];
|
||||||
// append packages ignored previous time to the beginning
|
// append packages ignored previous time to the beginning
|
||||||
@@ -46,6 +44,7 @@ moduleReducers[RECIEVE_SHOP_PACKAGES] = (state = {}, action) => {
|
|||||||
while (retrievedShopPackages.length > SHOP_PAGE_SIZE) {
|
while (retrievedShopPackages.length > SHOP_PAGE_SIZE) {
|
||||||
shopPackagesDiff.push(retrievedShopPackages.pop());
|
shopPackagesDiff.push(retrievedShopPackages.pop());
|
||||||
}
|
}
|
||||||
|
|
||||||
// append packages from this page to existing ones
|
// append packages from this page to existing ones
|
||||||
shopPackages = shopPackages.concat(retrievedShopPackages);
|
shopPackages = shopPackages.concat(retrievedShopPackages);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user