|
|
@ -51,8 +51,6 @@ export const asyncInitialState = { |
|
|
|
requestError: false, |
|
|
|
requestError: false, |
|
|
|
/* if response has no items */ |
|
|
|
/* if response has no items */ |
|
|
|
emptyResponse: false, |
|
|
|
emptyResponse: false, |
|
|
|
/* if it is loading the first page */ |
|
|
|
|
|
|
|
loadingFirstPage: true, |
|
|
|
|
|
|
|
/* link to the next page */ |
|
|
|
/* link to the next page */ |
|
|
|
nextPagePath: null, |
|
|
|
nextPagePath: null, |
|
|
|
/* link to the previous page */ |
|
|
|
/* link to the previous page */ |
|
|
@ -72,7 +70,6 @@ export function asyncReducer (state = asyncInitialState, action) { |
|
|
|
case 'START_REQUEST': { |
|
|
|
case 'START_REQUEST': { |
|
|
|
return Object.assign({}, state, { |
|
|
|
return Object.assign({}, state, { |
|
|
|
loading: true, |
|
|
|
loading: true, |
|
|
|
loadingFirstPage: true, |
|
|
|
|
|
|
|
requestError: false |
|
|
|
requestError: false |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -81,8 +78,7 @@ export function asyncReducer (state = asyncInitialState, action) { |
|
|
|
} |
|
|
|
} |
|
|
|
case 'FINISH_REQUEST': { |
|
|
|
case 'FINISH_REQUEST': { |
|
|
|
return Object.assign({}, state, { |
|
|
|
return Object.assign({}, state, { |
|
|
|
loading: false, |
|
|
|
loading: false |
|
|
|
loadingFirstPage: false |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
case 'ITEMS_FETCHED': { |
|
|
|
case 'ITEMS_FETCHED': { |
|
|
@ -135,7 +131,7 @@ export const elements = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
'[data-async-listing] [data-loading-message]': { |
|
|
|
'[data-async-listing] [data-loading-message]': { |
|
|
|
render ($el, state) { |
|
|
|
render ($el, state) { |
|
|
|
if (state.loadingFirstPage) return $el.show() |
|
|
|
if (state.loading) return $el.show() |
|
|
|
|
|
|
|
|
|
|
|
$el.hide() |
|
|
|
$el.hide() |
|
|
|
} |
|
|
|
} |
|
|
@ -144,7 +140,7 @@ export const elements = { |
|
|
|
render ($el, state) { |
|
|
|
render ($el, state) { |
|
|
|
if ( |
|
|
|
if ( |
|
|
|
!state.requestError && |
|
|
|
!state.requestError && |
|
|
|
(!state.loading || !state.loadingFirstPage) && |
|
|
|
(!state.loading) && |
|
|
|
state.items.length === 0 |
|
|
|
state.items.length === 0 |
|
|
|
) { |
|
|
|
) { |
|
|
|
return $el.show() |
|
|
|
return $el.show() |
|
|
@ -217,7 +213,7 @@ export const elements = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
'[data-async-listing] [data-loading-button]': { |
|
|
|
'[data-async-listing] [data-loading-button]': { |
|
|
|
render ($el, state) { |
|
|
|
render ($el, state) { |
|
|
|
if (!state.loadingFirstPage && state.loading) return $el.show() |
|
|
|
if (state.loading) return $el.show() |
|
|
|
|
|
|
|
|
|
|
|
$el.hide() |
|
|
|
$el.hide() |
|
|
|
} |
|
|
|
} |
|
|
|