Skip to content

Commit

Permalink
pagination comment fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
restylianos committed Aug 14, 2024
1 parent ec8a7b9 commit 9f3ca64
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
20 changes: 8 additions & 12 deletions src/app/components/AccountHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,17 @@ function DisplayTable() {
}
}, [
openOrders,
orderHistory,
selectedTable,
hideOtherPairs,
filteredRowsForOrderHistory,
combinedOpenOrders,
]);

useEffect(() => {
const tableRefNode = tableContainerRef.current;

function calcPaginationLeftOffset() {
if (tableContainerRef.current !== null) {
if (tableRefNode !== null) {
if (timeoutRef.current !== null) {
clearTimeout(timeoutRef.current);
}
Expand All @@ -288,20 +290,14 @@ function DisplayTable() {
}

calcPaginationLeftOffset();
if (tableContainerRef.current) {
tableContainerRef.current.addEventListener(
"scroll",
calcPaginationLeftOffset
);
if (tableRefNode) {
tableRefNode.addEventListener("scroll", calcPaginationLeftOffset);
}

window.addEventListener("resize", calcPaginationLeftOffset);
return () => {
if (tableContainerRef.current) {
tableContainerRef.current.removeEventListener(
"scroll",
calcPaginationLeftOffset
);
if (tableRefNode) {
tableRefNode.removeEventListener("scroll", calcPaginationLeftOffset);
}

window.removeEventListener("resize", calcPaginationLeftOffset);
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ const Pagination: React.FC<PaginationProps> = ({
onClick={() => setCurrentPage(idx)}
role="button"
className={`${
currentPage === idx ? "bg-dexter-green rounded-full" : ""
} text-white hover:bg-dexter-green p-1 hover:rounded-full h-6 w-6 text-center opacity-90 hover:opacity-100`}
currentPage === idx ? "bg-dexter-green rounded-full text-black" : ""
} hover:bg-dexter-green hover:text-black p-1 hover:rounded-full h-6 w-6 text-center opacity-90 hover:opacity-100`}
>
{idx + 1}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/app/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function usePagination<T>(data: T[], paginationId?: string) {

const paginatedData = useMemo(
() => data.slice(startIndex, endIndex),
[data, currentPage]
[data, startIndex, endIndex]
);

const updatePsize = useCallback(
Expand Down

0 comments on commit 9f3ca64

Please sign in to comment.