Merge pull request #1480 from stackernews/fix-wallet-logs-infinite-loop
Fix infinite loop of loading wallet logs + center more button
This commit is contained in:
commit
153f47de7d
@ -12,10 +12,7 @@ import useIndexedDB from './use-indexeddb'
|
|||||||
import { SSR } from '@/lib/constants'
|
import { SSR } from '@/lib/constants'
|
||||||
|
|
||||||
export function WalletLogs ({ wallet, embedded }) {
|
export function WalletLogs ({ wallet, embedded }) {
|
||||||
const { logs, setLogs, hasMore, loadMore, loadLogs, loading } = useWalletLogs(wallet)
|
const { logs, setLogs, hasMore, loadMore, loading } = useWalletLogs(wallet)
|
||||||
useEffect(() => {
|
|
||||||
loadLogs()
|
|
||||||
}, [loadLogs])
|
|
||||||
|
|
||||||
const showModal = useShowModal()
|
const showModal = useShowModal()
|
||||||
|
|
||||||
@ -46,7 +43,7 @@ export function WalletLogs ({ wallet, embedded }) {
|
|||||||
? <div className='w-100 text-center'>loading...</div>
|
? <div className='w-100 text-center'>loading...</div>
|
||||||
: logs.length === 0 && <div className='w-100 text-center'>empty</div>}
|
: logs.length === 0 && <div className='w-100 text-center'>empty</div>}
|
||||||
{hasMore
|
{hasMore
|
||||||
? <Button onClick={loadMore} size='sm' className='mt-3'>Load More</Button>
|
? <div className='w-100 text-center'><Button onClick={loadMore} size='sm' className='mt-3'>more</Button></div>
|
||||||
: <div className='w-100 text-center'>------ start of logs ------</div>}
|
: <div className='w-100 text-center'>------ start of logs ------</div>}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
@ -247,5 +244,9 @@ export function useWalletLogs (wallet, initialPage = 1, logsPerPage = 10) {
|
|||||||
setLoading(false)
|
setLoading(false)
|
||||||
}, [wallet, loadLogsPage])
|
}, [wallet, loadLogsPage])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadLogs()
|
||||||
|
}, [wallet])
|
||||||
|
|
||||||
return { logs, hasMore, total, loadMore, loadLogs, setLogs, loading }
|
return { logs, hasMore, total, loadMore, loadLogs, setLogs, loading }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user