feat(mobile): pull-to-refresh + polling on the dashboard - #587
Conversation
|
@kaylachi is attempting to deploy a commit to the miracle656's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Thanks! This needs a rebase — |
Turn the placeholder home route into a dashboard that stays fresh two ways. `lib/activity.ts` loads the account's native XLM balance and recent payments from Horizon; the pure `mapPayments` turns Horizon records into direction-aware activity rows. `hooks/usePolling.ts` is a ref-backed interval that re-fetches quietly every POLL_INTERVAL_MS without restarting on each render. The screen wraps its ScrollView in a RefreshControl so a pull refreshes balance + feed, and an unfunded account reads as a zero balance with no activity rather than an error. Closes Miracle656#462
3585544 to
53574ec
Compare
|
@kaylachi Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
Hi! I've rebased this branch onto main. The background polling of the activity feed is indeed already handled on main via useInitActivityFeed. I've reconciled this PR by adding background polling for the XLM balance itself and wiring the dashboard gesture to pull-to-refresh (which refreshes both the balance and the activity feed). Ready for another look! |
Summary
Keeps the mobile dashboard fresh both ways (backlog #34 / #462): an explicit pull gesture and quiet background polling of balance + activity.
Added / changed
lib/activity.ts—fetchDashboardData(publicKey)loads the account's native XLM balance and its 20 most recent payments from Horizon. The puremapPaymentsturns Horizonpayment/create_accountrecords into direction-aware activity rows (received-from / sent-to), dropping non-transfer ops. An unfunded account (Horizon 404) reads as a zero balance with no activity, not an error.hooks/usePolling.ts— a ref-backedsetInterval(the native stand-in for the web dashboard's service-worker polling) that re-fires everyPOLL_INTERVAL_MSand never restarts when the callback identity changes; always cleared on unmount / when disabled.app/index.tsx— the placeholder home route is now the dashboard: a balance card + activity feed inside aScrollViewwithRefreshControl(pull-to-refresh) and background polling while a wallet is present. Distinct loading / no-wallet / empty / error states.Testing
tsc --noEmit✅jest lib/__tests__/activity.test.ts✅ (6/6 — direction, counterparty, non-native asset code, create_account, non-transfer filtering, timestamp conversion)Closes #462