Skip to content

Commit

Permalink
chore: slightly improve connection storage setting
Browse files Browse the repository at this point in the history
  • Loading branch information
kareemmahlees committed Sep 16, 2024
1 parent bbd6a47 commit f99c3cf
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,11 @@ export function DataTablePagination<TData>({
table,
connectionId
}: DataTablePaginationProps<TData>) {
const { tableName } = useTableState()
const [, setConnectionStorage] = useLocalStorage<TableLocalStorage>(
`@tablex/${connectionId}`,
{
tableName,
const [connectionStorage, setConnectionStorage] =
useLocalStorage<TableLocalStorage>(`@tablex/${connectionId}`, {
tableName: "",
pageIndex: 0
}
)
})

return (
<div className="flex items-center justify-between px-2">
Expand All @@ -107,7 +104,7 @@ export function DataTablePagination<TData>({
className="hidden h-8 w-8 p-0 lg:flex"
onClick={() => {
table.setPageIndex(0)
setConnectionStorage({ tableName, pageIndex: 0 })
setConnectionStorage({ ...connectionStorage, pageIndex: 0 })
}}
disabled={!table.getCanPreviousPage()}
>
Expand All @@ -119,7 +116,7 @@ export function DataTablePagination<TData>({
className="h-8 w-8 p-0"
onClick={() => {
setConnectionStorage({
tableName,
...connectionStorage,
pageIndex: table.getState().pagination.pageIndex - 1
})
table.previousPage()
Expand All @@ -134,7 +131,7 @@ export function DataTablePagination<TData>({
className="h-8 w-8 p-0"
onClick={() => {
setConnectionStorage({
tableName,
...connectionStorage,
pageIndex: table.getState().pagination.pageIndex + 1
})
table.nextPage()
Expand All @@ -150,7 +147,7 @@ export function DataTablePagination<TData>({
onClick={() => {
table.setPageIndex(table.getPageCount() - 1)
setConnectionStorage({
tableName,
...connectionStorage,
pageIndex: table.getPageCount() - 1
})
}}
Expand Down

0 comments on commit f99c3cf

Please sign in to comment.