Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
58ec543a
Commit
58ec543a
authored
Dec 21, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix pagination
parent
729dacb3
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
30 additions
and
38 deletions
+30
-38
useQueryWithPages.ts
lib/hooks/useQueryWithPages.ts
+8
-1
AddressBlocksValidated.tsx
ui/address/AddressBlocksValidated.tsx
+1
-3
AddressInternalTxs.tsx
ui/address/AddressInternalTxs.tsx
+2
-4
AddressTxs.tsx
ui/address/AddressTxs.tsx
+1
-7
AddressCoinBalanceHistory.tsx
ui/address/coinBalance/AddressCoinBalanceHistory.tsx
+2
-3
BlocksTabSlot.tsx
ui/blocks/BlocksTabSlot.tsx
+3
-2
Block.tsx
ui/pages/Block.tsx
+1
-2
Blocks.tsx
ui/pages/Blocks.tsx
+1
-1
Transactions.tsx
ui/pages/Transactions.tsx
+1
-1
TokenTransfer.tsx
ui/shared/TokenTransfer/TokenTransfer.tsx
+2
-2
TxInternals.tsx
ui/tx/TxInternals.tsx
+3
-4
TxLogs.tsx
ui/tx/TxLogs.tsx
+2
-3
TxsTabSlot.tsx
ui/txs/TxsTabSlot.tsx
+3
-5
No files found.
lib/hooks/useQueryWithPages.ts
View file @
58ec543a
...
...
@@ -36,6 +36,7 @@ export default function useQueryWithPages<QueryName extends PaginatedQueryKeys>(
const
fetch
=
useFetch
();
const
isMounted
=
React
.
useRef
(
false
);
const
canGoBackwards
=
React
.
useRef
(
!
router
.
query
.
page
);
const
[
hasPagination
,
setHasPagination
]
=
React
.
useState
(
page
>
1
);
const
queryKey
=
[
queryName
,
...(
queryIds
||
[]),
{
page
,
filters
}
];
...
...
@@ -74,6 +75,7 @@ export default function useQueryWithPages<QueryName extends PaginatedQueryKeys>(
const
nextPageQuery
=
{
...
router
.
query
};
Object
.
entries
(
nextPageParams
).
forEach
(([
key
,
val
])
=>
nextPageQuery
[
key
]
=
val
.
toString
());
nextPageQuery
.
page
=
String
(
page
+
1
);
setHasPagination
(
true
);
router
.
push
({
pathname
:
router
.
pathname
,
query
:
nextPageQuery
},
undefined
,
{
shallow
:
true
})
.
then
(()
=>
{
...
...
@@ -101,6 +103,7 @@ export default function useQueryWithPages<QueryName extends PaginatedQueryKeys>(
setPage
(
prev
=>
prev
-
1
);
page
===
2
&&
queryClient
.
removeQueries
({
queryKey
:
[
queryName
]
});
});
setHasPagination
(
true
);
},
[
router
,
page
,
paginationFields
,
pageParams
,
queryClient
,
scrollToTop
,
queryName
]);
const
resetPage
=
useCallback
(()
=>
{
...
...
@@ -118,6 +121,8 @@ export default function useQueryWithPages<QueryName extends PaginatedQueryKeys>(
queryClient
.
removeQueries
({
queryKey
:
[
queryName
],
type
:
'
inactive
'
});
},
100
);
});
setHasPagination
(
true
);
},
[
queryClient
,
queryName
,
router
,
paginationFields
,
scrollToTop
]);
const
onFilterChange
=
useCallback
((
newFilters
:
PaginationFilters
<
QueryName
>
|
undefined
)
=>
{
...
...
@@ -156,6 +161,8 @@ export default function useQueryWithPages<QueryName extends PaginatedQueryKeys>(
canGoBackwards
:
canGoBackwards
.
current
,
};
const
isPaginationVisible
=
hasPagination
||
(
!
queryResult
.
isLoading
&&
!
queryResult
.
isError
&&
pagination
.
hasNextPage
);
React
.
useEffect
(()
=>
{
if
(
page
!==
1
&&
isMounted
.
current
)
{
queryClient
.
cancelQueries
({
queryKey
});
...
...
@@ -171,5 +178,5 @@ export default function useQueryWithPages<QueryName extends PaginatedQueryKeys>(
},
0
);
},
[]);
return
{
...
queryResult
,
pagination
,
onFilterChange
};
return
{
...
queryResult
,
pagination
,
onFilterChange
,
isPaginationVisible
};
}
ui/address/AddressBlocksValidated.tsx
View file @
58ec543a
...
...
@@ -122,11 +122,9 @@ const AddressBlocksValidated = ({ addressQuery }: Props) => {
);
})();
const isPaginatorHidden = !query.isLoading && !query.isError && query.pagination.page === 1 && !query.pagination.hasNextPage;
return (
<Box>
{
!isPaginatorHidden
&& (
{
query.isPaginationVisible
&& (
<ActionBar mt={ -6 }>
<Pagination ml="auto" { ...query.pagination }/>
</ActionBar>
...
...
ui/address/AddressInternalTxs.tsx
View file @
58ec543a
...
...
@@ -35,7 +35,7 @@ const AddressInternalTxs = () => {
const
queryIdArray
=
castArray
(
queryId
);
const
queryIdStr
=
queryIdArray
[
0
];
const
{
data
,
isLoading
,
isError
,
pagination
,
onFilterChange
}
=
useQueryWithPages
({
const
{
data
,
isLoading
,
isError
,
pagination
,
onFilterChange
,
isPaginationVisible
}
=
useQueryWithPages
({
apiPath
:
`/node-api/addresses/
${
queryId
}
/internal-transactions`
,
queryName
:
QueryKeys
.
addressInternalTxs
,
queryIds
:
queryIdArray
,
...
...
@@ -43,8 +43,6 @@ const AddressInternalTxs = () => {
scroll
:
{
elem
:
SCROLL_ELEM
,
offset
:
SCROLL_OFFSET
},
});
const
isPaginatorHidden
=
!
isLoading
&&
!
isError
&&
pagination
.
page
===
1
&&
!
pagination
.
hasNextPage
;
const
handleFilterChange
=
React
.
useCallback
((
val
:
string
|
Array
<
string
>
)
=>
{
const
newVal
=
getFilterValue
(
val
);
...
...
@@ -94,7 +92,7 @@ const AddressInternalTxs = () => {
onFilterChange=
{
handleFilterChange
}
isActive=
{
Boolean
(
filterValue
)
}
/>
{
!
isPaginatorHidden
&&
<
Pagination
ml=
"auto"
{
...
pagination
}
/>
}
{
isPaginationVisible
&&
<
Pagination
ml=
"auto"
{
...
pagination
}
/>
}
</
ActionBar
>
{
content
}
</
Element
>
...
...
ui/address/AddressTxs.tsx
View file @
58ec543a
...
...
@@ -43,12 +43,6 @@ const AddressTxs = () => {
addressTxsQuery
.
onFilterChange
({
filter
:
newVal
});
},
[
addressTxsQuery
]);
const
isPaginatorHidden
=
!
addressTxsQuery
.
isLoading
&&
!
addressTxsQuery
.
isError
&&
addressTxsQuery
.
pagination
.
page
===
1
&&
!
addressTxsQuery
.
pagination
.
hasNextPage
;
const
filter
=
(
<
AddressTxsFilter
defaultFilter=
{
filterValue
}
...
...
@@ -62,7 +56,7 @@ const AddressTxs = () => {
{
!
isMobile
&&
(
<
ActionBar
mt=
{
-
6
}
>
{
filter
}
{
!
isPaginatorHidden
&&
<
Pagination
{
...
addressTxsQuery
.
pagination
}
/>
}
{
addressTxsQuery
.
isPaginationVisible
&&
<
Pagination
{
...
addressTxsQuery
.
pagination
}
/>
}
</
ActionBar
>
)
}
<
TxsContent
...
...
ui/address/coinBalance/AddressCoinBalanceHistory.tsx
View file @
58ec543a
...
...
@@ -19,13 +19,12 @@ import AddressCoinBalanceTableItem from './AddressCoinBalanceTableItem';
interface
Props
{
query
:
UseQueryResult
<
AddressCoinBalanceHistoryResponse
>
&
{
pagination
:
PaginationProps
;
isPaginationVisible
:
boolean
;
};
}
const
AddressCoinBalanceHistory
=
({
query
}:
Props
)
=>
{
const
isPaginatorHidden
=
!
query
.
isLoading
&&
!
query
.
isError
&&
query
.
pagination
.
page
===
1
&&
!
query
.
pagination
.
hasNextPage
;
const
content
=
(()
=>
{
if
(
query
.
isLoading
)
{
return
(
...
...
@@ -75,7 +74,7 @@ const AddressCoinBalanceHistory = ({ query }: Props) => {
return
(
<
Box
mt=
{
8
}
>
{
!
isPaginatorHidden
&&
(
{
query
.
isPaginationVisible
&&
(
<
ActionBar
mt=
{
-
6
}
>
<
Pagination
ml=
"auto"
{
...
query
.
pagination
}
/>
</
ActionBar
>
...
...
ui/blocks/BlocksTabSlot.tsx
View file @
58ec543a
...
...
@@ -13,9 +13,10 @@ import Pagination from 'ui/shared/Pagination';
interface
Props
{
pagination
:
PaginationProps
;
isPaginationVisible
:
boolean
;
}
const
BlocksTabSlot
=
({
pagination
}:
Props
)
=>
{
const
BlocksTabSlot
=
({
pagination
,
isPaginationVisible
}:
Props
)
=>
{
const
isMobile
=
useIsMobile
();
const
fetch
=
useFetch
();
...
...
@@ -41,7 +42,7 @@ const BlocksTabSlot = ({ pagination }: Props) => {
</
Text
>
</
Box
>
)
}
<
Pagination
my=
{
1
}
{
...
pagination
}
/>
{
isPaginationVisible
&&
<
Pagination
my=
{
1
}
{
...
pagination
}
/>
}
</
Flex
>
);
};
...
...
ui/pages/Block.tsx
View file @
58ec543a
...
...
@@ -46,8 +46,7 @@ const BlockPageContent = () => {
{
id
:
'
txs
'
,
title
:
'
Transactions
'
,
component
:
<
TxsContent
query=
{
blockTxsQuery
}
showBlockInfo=
{
false
}
showSocketInfo=
{
false
}
/>
},
];
const
isPaginatorHidden
=
!
blockTxsQuery
.
isLoading
&&
!
blockTxsQuery
.
isError
&&
blockTxsQuery
.
pagination
.
page
===
1
&&
!
blockTxsQuery
.
pagination
.
hasNextPage
;
const
hasPagination
=
!
isMobile
&&
router
.
query
.
tab
===
'
txs
'
&&
!
isPaginatorHidden
;
const
hasPagination
=
!
isMobile
&&
router
.
query
.
tab
===
'
txs
'
&&
blockTxsQuery
.
isPaginationVisible
;
const
referrer
=
isInBrowser
?
window
.
document
.
referrer
:
appProps
.
referrer
;
...
...
ui/pages/Blocks.tsx
View file @
58ec543a
...
...
@@ -55,7 +55,7 @@ const BlocksPageContent = () => {
<
RoutedTabs
tabs=
{
tabs
}
tabListProps=
{
isMobile
?
undefined
:
TAB_LIST_PROPS
}
rightSlot=
{
<
BlocksTabSlot
pagination=
{
blocksQuery
.
pagination
}
/>
}
rightSlot=
{
<
BlocksTabSlot
pagination=
{
blocksQuery
.
pagination
}
isPaginationVisible=
{
blocksQuery
.
isPaginationVisible
}
/>
}
stickyEnabled=
{
!
isMobile
}
/>
</
Page
>
...
...
ui/pages/Transactions.tsx
View file @
58ec543a
...
...
@@ -43,7 +43,7 @@ const Transactions = () => {
<
RoutedTabs
tabs=
{
tabs
}
tabListProps=
{
isMobile
?
undefined
:
TAB_LIST_PROPS
}
rightSlot=
{
<
TxsTabSlot
pagination=
{
txsQuery
.
pagination
}
/>
}
rightSlot=
{
<
TxsTabSlot
pagination=
{
txsQuery
.
pagination
}
isPaginationVisible=
{
txsQuery
.
isPaginationVisible
&&
!
isMobile
}
/>
}
stickyEnabled=
{
!
isMobile
}
/>
</
Box
>
...
...
ui/shared/TokenTransfer/TokenTransfer.tsx
View file @
58ec543a
...
...
@@ -51,7 +51,7 @@ const TokenTransfer = ({ isLoading: isLoadingProp, isDisabled, queryName, queryI
{
type
:
getTokenFilterValue
(
router
.
query
.
type
),
filter
:
getAddressFilterValue
(
router
.
query
.
filter
)
},
);
const
{
isError
,
isLoading
,
data
,
pagination
,
onFilterChange
}
=
useQueryWithPages
({
const
{
isError
,
isLoading
,
data
,
pagination
,
onFilterChange
,
isPaginationVisible
}
=
useQueryWithPages
({
apiPath
:
path
,
queryName
,
queryIds
,
...
...
@@ -128,7 +128,7 @@ const TokenTransfer = ({ isLoading: isLoadingProp, isDisabled, queryName, queryI
onAddressFilterChange=
{
handleAddressFilterChange
}
defaultAddressFilter=
{
filters
.
filter
}
/>
<
Pagination
ml=
"auto"
{
...
pagination
}
/>
{
isPaginationVisible
&&
<
Pagination
ml=
"auto"
{
...
pagination
}
/>
}
</
ActionBar
>
)
}
{
content
}
...
...
ui/tx/TxInternals.tsx
View file @
58ec543a
...
...
@@ -75,7 +75,7 @@ const TxInternals = () => {
// const [ searchTerm, setSearchTerm ] = React.useState<string>('');
const
[
sort
,
setSort
]
=
React
.
useState
<
Sort
>
();
const
txInfo
=
useFetchTxInfo
({
updateDelay
:
5
*
SECOND
});
const
{
data
,
isLoading
,
isError
,
pagination
}
=
useQueryWithPages
({
const
{
data
,
isLoading
,
isError
,
pagination
,
isPaginationVisible
}
=
useQueryWithPages
({
apiPath
:
`/node-api/transactions/
${
txInfo
.
data
?.
hash
}
/internal-transactions`
,
queryName
:
QueryKeys
.
txInternals
,
queryIds
:
txInfo
.
data
?.
hash
?
[
txInfo
.
data
.
hash
]
:
undefined
,
...
...
@@ -83,7 +83,6 @@ const TxInternals = () => {
enabled
:
Boolean
(
txInfo
.
data
?.
hash
)
&&
Boolean
(
txInfo
.
data
?.
status
),
},
});
const
isPaginatorHidden
=
!
isLoading
&&
!
isError
&&
pagination
.
page
===
1
&&
!
pagination
.
hasNextPage
;
const
isMobile
=
useIsMobile
();
...
...
@@ -131,12 +130,12 @@ const TxInternals = () => {
return
isMobile
?
<
TxInternalsList
data=
{
filteredData
}
/>
:
<
TxInternalsTable
data=
{
filteredData
}
sort=
{
sort
}
onSortToggle=
{
handleSortToggle
}
top=
{
isPaginat
orHidden
?
0
:
8
0
}
/>;
<
TxInternalsTable
data=
{
filteredData
}
sort=
{
sort
}
onSortToggle=
{
handleSortToggle
}
top=
{
isPaginat
ionVisible
?
80
:
0
}
/>;
})();
return
(
<
Box
>
{
!
isPaginatorHidden
&&
(
{
isPaginationVisible
&&
(
<
ActionBar
mt=
{
-
6
}
>
<
Pagination
ml=
"auto"
{
...
pagination
}
/>
</
ActionBar
>
...
...
ui/tx/TxLogs.tsx
View file @
58ec543a
...
...
@@ -16,7 +16,7 @@ import useFetchTxInfo from 'ui/tx/useFetchTxInfo';
const
TxLogs
=
()
=>
{
const
txInfo
=
useFetchTxInfo
({
updateDelay
:
5
*
SECOND
});
const
{
data
,
isLoading
,
isError
,
pagination
}
=
useQueryWithPages
({
const
{
data
,
isLoading
,
isError
,
pagination
,
isPaginationVisible
}
=
useQueryWithPages
({
apiPath
:
`/node-api/transactions/
${
txInfo
.
data
?.
hash
}
/logs`
,
queryName
:
QueryKeys
.
txLogs
,
queryIds
:
txInfo
.
data
?.
hash
?
[
txInfo
.
data
.
hash
]
:
undefined
,
...
...
@@ -24,7 +24,6 @@ const TxLogs = () => {
enabled
:
Boolean
(
txInfo
.
data
?.
hash
)
&&
Boolean
(
txInfo
.
data
?.
status
),
},
});
const
isPaginatorHidden
=
!
isLoading
&&
!
isError
&&
pagination
.
page
===
1
&&
!
pagination
.
hasNextPage
;
if
(
!
txInfo
.
isLoading
&&
!
txInfo
.
isError
&&
!
txInfo
.
data
.
status
)
{
return
txInfo
.
socketStatus
?
<
TxSocketAlert
status=
{
txInfo
.
socketStatus
}
/>
:
<
TxPendingAlert
/>;
...
...
@@ -49,7 +48,7 @@ const TxLogs = () => {
return
(
<
Box
>
{
!
isPaginatorHidden
&&
(
{
isPaginationVisible
&&
(
<
ActionBar
mt=
{
-
6
}
>
<
Pagination
ml=
"auto"
{
...
pagination
}
/>
</
ActionBar
>
...
...
ui/txs/TxsTabSlot.tsx
View file @
58ec543a
import
React
from
'
react
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
type
{
Props
as
PaginationProps
}
from
'
ui/shared/Pagination
'
;
import
Pagination
from
'
ui/shared/Pagination
'
;
interface
Props
{
pagination
:
PaginationProps
;
isPaginationVisible
:
boolean
;
}
const
TxsTabSlot
=
({
pagination
}:
Props
)
=>
{
const
isMobile
=
useIsMobile
();
if
(
isMobile
)
{
const
TxsTabSlot
=
({
pagination
,
isPaginationVisible
}:
Props
)
=>
{
if
(
!
isPaginationVisible
)
{
return
null
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment