loadItemsNext, loadItemsPrev refactoring

staking
Victor Baranov 4 years ago
parent 65cf6d6b28
commit 372a646ad9
  1. 14
      apps/block_scout_web/assets/js/lib/async_listing_load.js

@ -304,21 +304,11 @@ function loadPage (store, path) {
function firstPageLoad (store) {
const $element = $('[data-async-listing]')
function loadItemsNext () {
const path = store.getState().nextPagePath
store.dispatch({ type: 'START_REQUEST' })
$.getJSON(path, { type: 'JSON' })
.done(response => store.dispatch(Object.assign({ type: 'ITEMS_FETCHED' }, humps.camelizeKeys(response))))
.fail(() => store.dispatch({ type: 'REQUEST_ERROR' }))
.always(() => store.dispatch({ type: 'FINISH_REQUEST' }))
loadPage(store, store.getState().nextPagePath)
}
function loadItemsPrev () {
const path = store.getState().prevPagePath
store.dispatch({ type: 'START_REQUEST' })
$.getJSON(path, { type: 'JSON' })
.done(response => store.dispatch(Object.assign({ type: 'ITEMS_FETCHED' }, humps.camelizeKeys(response))))
.fail(() => store.dispatch({ type: 'REQUEST_ERROR' }))
.always(() => store.dispatch({ type: 'FINISH_REQUEST' }))
loadPage(store, store.getState().prevPagePath)
}
loadItemsNext()

Loading…
Cancel
Save