@@ -4,7 +4,11 @@ import { useLineListAnalyticsData } from './hooks/use-line-list-analytics-data'
44import type { MetadataInput } from '@components/app-wrapper/metadata-helpers'
55import { LineList } from '@components/line-list'
66import type { LineListAnalyticsData } from '@components/line-list'
7- import type { DataSortFn , DataSortPayload } from '@components/line-list/types'
7+ import type {
8+ DataSortFn ,
9+ DataSortPayload ,
10+ PaginateFn ,
11+ } from '@components/line-list/types'
812import { transformVisualization } from '@modules/visualization'
913import type { CurrentUser , CurrentVisualization , SortDirection } from '@types'
1014
@@ -19,9 +23,6 @@ type LineListPluginProps = {
1923 onResponseReceived ?: ( metadata : MetadataInput ) => void
2024}
2125
22- const FIRST_PAGE : number = 1
23- const PAGE_SIZE : number = 100
24-
2526export const LineListPlugin : FC < LineListPluginProps > = ( {
2627 displayProperty,
2728 visualization : originalVisualization ,
@@ -52,8 +53,8 @@ export const LineListPlugin: FC<LineListPluginProps> = ({
5253 ...newPagination ,
5354 } ) ,
5455 {
55- page : FIRST_PAGE ,
56- pageSize : PAGE_SIZE ,
56+ page : 1 ,
57+ pageSize : 100 ,
5758 }
5859 )
5960
@@ -62,15 +63,11 @@ export const LineListPlugin: FC<LineListPluginProps> = ({
6263 ? visualization . sorting [ 0 ]
6364 : { dimension : undefined , direction : undefined }
6465
65- const onPaginate = useCallback ( ( { page, pageSize } ) => {
66+ const onPaginate = useCallback < PaginateFn > ( ( { page, pageSize } ) => {
6667 if ( pageSize ) {
67- setPagination ( { page : pageSize ? FIRST_PAGE : page , pageSize } )
68- } else if ( page ) {
69- setPagination ( { page } )
68+ setPagination ( { page, pageSize } )
7069 } else {
71- throw new Error (
72- 'onPaginate was called with neither a page nor pageSize. At least one is expected'
73- )
70+ setPagination ( { page } )
7471 }
7572 } , [ ] )
7673
0 commit comments