-
Notifications
You must be signed in to change notification settings - Fork 23
Paginate card and receipts #273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements pagination for card transactions and receipts by replacing ScrollView components with FlatList components and integrating the useTransactions hook to handle infinite scrolling.
Key Changes:
- Added pagination support to the
useTransactionshook with a configurable prefix parameter - Converted card and receipts pages from ScrollView to FlatList for better performance with large datasets
- Introduced infinite scroll functionality with loading indicators
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/organization/useTransactions.ts | Enhanced hook to support pagination with configurable prefixes and added dedicated hook for missing receipt transactions |
| src/pages/cards/card.tsx | Refactored card page to use FlatList with pagination support and restructured rendering logic |
| src/pages/Receipts.tsx | Converted receipts page to use FlatList for better performance |
| src/pages/organization/index.tsx | Updated to pass "organizations" prefix to useTransactions hook |
| src/pages/RenameTransaction.tsx | Updated cache mutation call to include prefix parameter |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| item, | ||
| }: { | ||
| item: { type: string; data: unknown }; | ||
| index: number; |
Copilot
AI
Oct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The renderItem function destructures an 'index' parameter from its argument but never uses it. Remove the unused 'index' parameter from the type annotation.
| index: number; |
src/pages/RenameTransaction.tsx
Outdated
| populateCache: true, | ||
| onSuccess() { | ||
| mutate(unstable_serialize(getKey(orgId))); | ||
| mutate(getKey(orgId, "organizations")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: mutate() is called with a key generator function instead of a serialized key, preventing cache invalidation.
Severity: CRITICAL | Confidence: 1.00
🔍 Detailed Analysis
The mutate() function is called with getKey(orgId, "organizations"), which returns a key generator function. However, mutate() interprets a function argument as a filter function. For useSWRInfinite keys, unstable_serialize must be used to correctly serialize the key generator. This mismatch prevents proper cache invalidation, leading to stale data persisting in the SWR cache after a transaction memo is renamed.
💡 Suggested Fix
Wrap the getKey() call with unstable_serialize before passing it to mutate() to ensure correct key serialization for useSWRInfinite.
🤖 Prompt for AI Agent
Fix this bug. In src/pages/RenameTransaction.tsx at line 60: The `mutate()` function is
called with `getKey(orgId, "organizations")`, which returns a key generator function.
However, `mutate()` interprets a function argument as a filter function. For
`useSWRInfinite` keys, `unstable_serialize` must be used to correctly serialize the key
generator. This mismatch prevents proper cache invalidation, leading to stale data
persisting in the SWR cache after a transaction memo is renamed.
Did we get this right? 👍 / 👎 to inform future reviews.
| switch (item.type) { | ||
| case "error": | ||
| return ( | ||
| <View |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Transaction error message is not displayed because the list filter removes the "transactions" item when transactionError is true.
Severity: HIGH | Confidence: 1.00
🔍 Detailed Analysis
When transactionsError is truthy, the listData filter at src/pages/cards/card.tsx:975 evaluates !transactionError && !transactionsLoading to false, causing the "transactions" item to be excluded. Consequently, the error rendering logic for transactionError within the renderItem function (lines 1523-1547) is never reached, preventing the display of transaction loading errors to the user.
💡 Suggested Fix
Modify the filter condition for "transactions" items to return !transactionsLoading; to ensure the item is not removed when transactionError is present.
🤖 Prompt for AI Agent
Fix this bug. In src/pages/cards/card.tsx at line 975: When `transactionsError` is
truthy, the `listData` filter at `src/pages/cards/card.tsx:975` evaluates
`!transactionError && !transactionsLoading` to `false`, causing the `"transactions"`
item to be excluded. Consequently, the error rendering logic for `transactionError`
within the `renderItem` function (lines 1523-1547) is never reached, preventing the
display of transaction loading errors to the user.
Did we get this right? 👍 / 👎 to inform future reviews.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.