Compare commits

...

3 Commits

Author SHA1 Message Date
Keyan d6caee5b42
Merge pull request #1510 from stackernews/fix-more-shown-after-delete
Fix more button shown after logs deleted
2024-11-04 07:28:58 -06:00
ekzyis 0901f15249 Fix more button shown after logs deleted by wrapping setLogs 2024-11-04 14:05:41 +01:00
ekzyis 58c37bbd63 Fix more button shown after logs deleted 2024-11-04 13:22:40 +01:00
1 changed files with 9 additions and 1 deletions

View File

@ -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 }