Merge pull request #1510 from stackernews/fix-more-shown-after-delete
Fix more button shown after logs deleted
This commit is contained in:
commit
d6caee5b42
|
@ -173,7 +173,7 @@ function tag (walletDef) {
|
|||
}
|
||||
|
||||
export function useWalletLogs (wallet, initialPage = 1, logsPerPage = 10) {
|
||||
const [logs, setLogs] = useState([])
|
||||
const [logs, _setLogs] = useState([])
|
||||
const [page, setPage] = useState(initialPage)
|
||||
const [hasMore, setHasMore] = useState(true)
|
||||
const [total, setTotal] = useState(0)
|
||||
|
@ -183,6 +183,14 @@ export function useWalletLogs (wallet, initialPage = 1, logsPerPage = 10) {
|
|||
const { getPage, error, notSupported } = useWalletLogDB()
|
||||
const [getWalletLogs] = useLazyQuery(WALLET_LOGS, SSR ? {} : { fetchPolicy: 'cache-and-network' })
|
||||
|
||||
const setLogs = useCallback((action) => {
|
||||
_setLogs(action)
|
||||
// action can be a React state dispatch function
|
||||
const newLogs = typeof action === 'function' ? action(logs) : action
|
||||
// make sure 'more' button is removed if logs were deleted
|
||||
if (newLogs.length === 0) setHasMore(false)
|
||||
}, [logs, _setLogs, setHasMore])
|
||||
|
||||
const loadLogsPage = useCallback(async (page, pageSize, walletDef) => {
|
||||
try {
|
||||
let result = { data: [], hasMore: false }
|
||||
|
|
Loading…
Reference in New Issue