Skip to content

Commit

Permalink
Merge pull request #571 from invariant-labs/fix-pagination
Browse files Browse the repository at this point in the history
fix position list pagination bugs
  • Loading branch information
wojciech-cichocki authored Jan 31, 2024
2 parents 2ce8ee8 + 2aa1b95 commit 5c27528
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/components/PositionsList/PositionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export const PositionsList: React.FC<IProp> = ({
setPage(initialPage)
}, [])

useEffect(() => {
handleChangePagination(initialPage)
}, [initialPage])

return (
<Grid container direction='column' className={classes.root}>
<Grid
Expand Down
12 changes: 11 additions & 1 deletion src/containers/WrappedPositionsList/WrappedPositionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@selectors/positions'
import { status } from '@selectors/solanaWallet'
import { openWalletSelectorModal } from '@web3/selector'
import React, { useState } from 'react'
import React, { useEffect, useState } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { useHistory } from 'react-router-dom'

Expand All @@ -34,6 +34,16 @@ export const WrappedPositionsList: React.FC = () => {
dispatch(actions.setLastPage(page))
}

useEffect(() => {
if (list.length === 0) {
setLastPage(1)
}

if (lastPage > Math.ceil(list.length / 5)) {
setLastPage(lastPage - 1)
}
}, [list])

return (
<PositionsList
initialPage={lastPage}
Expand Down

0 comments on commit 5c27528

Please sign in to comment.