Skip to content

Commit

Permalink
Use max of route's length and limit to fetch next routes
Browse files Browse the repository at this point in the history
  • Loading branch information
yaodingyd committed Jul 2, 2024
1 parent 396f0d6 commit 1d7f70a
Showing 1 changed file with 5 additions and 4 deletions.
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

0 comments on commit 1d7f70a

Please sign in to comment.