Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use max of route's length and limit to fetch next routes #538

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,16 @@ export function checkRoutesData() {

export function checkLastRoutesData() {
return (dispatch, getState) => {
const limit = getState().limit
const routes = getState().routes
const routes = getState().routes || []
const limit = Math.max(getState().limit, routes.length)


// if current routes are fewer than limit, that means the last fetch already fetched all the routes
if (routes && routes.length < limit) {
if (routes.length < limit) {
return
}

console.log(`fetching ${limit +LIMIT_INCREMENT } routes`)
console.debug(`fetching ${limit +LIMIT_INCREMENT } routes`)
dispatch({
type: Types.ACTION_UPDATE_ROUTE_LIMIT,
limit: limit + LIMIT_INCREMENT,
Expand Down