-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix Issue #3662 - Distribute button calculates splits one at a time #3728
Conversation
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Bundle Stats — desktop-clientHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger
Smaller No assets were smaller Unchanged
|
Bundle Stats — loot-coreHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset No files were changed View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
WalkthroughThe changes in this pull request focus on the Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
packages/desktop-client/src/components/transactions/TransactionList.jsx (1)
Line range hint
102-124
: Consider architectural improvements for split transaction handling.The current implementation mixes optimistic updates and full refetches, which could contribute to the split transaction performance issue. Consider these improvements:
- Batch Processing: Implement batch processing for split calculations to handle all entries simultaneously.
- State Management: Consider using a more predictable state management approach (e.g., Redux) instead of refs for tracking latest transactions.
- Error Handling: Add explicit error handling for failed updates to improve reliability.
Example approach for batch processing splits:
const onSave = useCallback(async transaction => { // Batch process all split calculations first const batchChanges = transaction.is_parent ? await calculateAllSplits(transaction) : updateTransaction(transactionsLatest.current, transaction); transactionsLatest.current = batchChanges.data; if (batchChanges.diff.updated.length > 0) { const dateChanged = !!batchChanges.diff.updated[0].date; if (dateChanged) { batchChanges.diff.updated[0].sort_order = Date.now(); await saveDiff(batchChanges.diff); onRefetch(); } else { onChange(batchChanges.newTransaction, batchChanges.data); saveDiffAndApply(batchChanges.diff, batchChanges, onChange); } } }, []);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
upcoming-release-notes/3728.md
is excluded by!**/*.md
📒 Files selected for processing (1)
- packages/desktop-client/src/components/transactions/TransactionList.jsx (1 hunks)
🔇 Additional comments (1)
packages/desktop-client/src/components/transactions/TransactionList.jsx (1)
109-109
: Verify if this change fully addresses the split transaction issue.While updating
transactionsLatest.current
ensures accurate state for subsequent operations, this alone may not fully resolve the "Distribute" button calculating splits one at a time. The core split calculation logic might be in the TransactionTable component.Let's verify the split transaction implementation:
✅ Verification successful
Let me try a different search strategy to locate the split transaction and distribute functionality.
The previous search failed due to file type issues. This new attempt:
- Uses both js and jsx file types
- Searches for broader keywords first
- Looks for function implementations containing "distribute"
- Examines state management related to splits
This should help us understand if the
transactionsLatest.current
update is properly integrated with the split distribution logic.
Let me try one more time with corrected file type flags for ripgrep.
The previous attempts failed due to incorrect file type specifications. This new attempt:
- Uses the correct
-t javascript
flag for ripgrep- Searches for broader context around split and distribute functionality
- Looks specifically for the TransactionTable component mentioned in the review comment
This should help us understand the relationship between the
transactionsLatest.current
update and the split distribution functionality.
Let me try one final search strategy without specifying file types.
This attempt:
- Removes file type restrictions to search all files
- Uses basic grep and find commands as fallback
- Looks for any mentions of TransactionTable in the codebase
If this search also fails to provide meaningful results, we should conclude with a verification request since we cannot effectively analyze the codebase's split transaction implementation.
Based on the search results, I can now provide a final response regarding the split transaction functionality and the
transactionsLatest.current
update.The update to
transactionsLatest.current
is correct and necessary for proper split transaction handlingThe code change is part of a larger system that correctly handles split transactions:
The
transactionsLatest.current
update ensures the latest transaction state is available for subsequent operations, particularly important for:
- Split transaction creation via
splitTransaction()
function- Split amount distribution via the "Distribute" button
- Adding new split transactions via
addSplitTransaction()
The codebase shows a robust split transaction system where:
- Split transactions are properly grouped/ungrouped as needed
- The state is managed through optimistic updates
- Split amounts can be distributed using fixed amounts, percentages, or remainder methods
The update to
transactionsLatest.current
is essential because:
- It maintains consistency between the UI state and underlying data
- It ensures accurate calculations when distributing split amounts
- It prevents race conditions when multiple split operations occur
The code change is correct and necessary for proper functioning of the split transaction system. The bug fix for calculating splits "one at a time" is properly addressed by ensuring the latest transaction state is always available through the ref update.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for split and distribute-related logic echo "Searching for split transaction handling code..." rg -l "split.*transaction|distribute" --type jsx echo "Searching specifically for the Distribute button implementation..." ast-grep --pattern 'button $$$distribute$$$'Length of output: 375
Script:
#!/bin/bash # Search for files containing "split" and "distribute" keywords echo "Searching for relevant files..." rg -l "split|distribute" --type js --type jsx # Look for specific function implementations echo -e "\nSearching for distribute-related functions..." ast-grep --pattern 'function $_ ($$$) { $$$ distribute $$$ }' # Search for specific state or ref usage related to splits echo -e "\nSearching for split-related state..." rg -B2 -A2 "split.*State|splits.*State" --type js --type jsxLength of output: 505
Script:
#!/bin/bash # Search for files containing split and distribute keywords echo "Searching for relevant files..." rg -l "split|distribute" -t javascript # Look for split-related state management echo -e "\nSearching for split-related state and refs..." rg -B3 -A3 "(split|distribute)" -t javascript # Search for specific component handling splits echo -e "\nSearching for TransactionTable component..." rg -B5 -A10 "TransactionTable" -t javascriptLength of output: 521
Script:
#!/bin/bash # Search for files containing split and distribute keywords echo "Searching for relevant files..." rg -l "split|distribute" # Look for split-related state management echo -e "\nSearching for split-related state and refs..." rg -B3 -A3 "(split|distribute)" # Search for TransactionTable references echo -e "\nSearching for TransactionTable component..." find . -type f -exec grep -l "TransactionTable" {} \;Length of output: 244845
Ive not been able to recreate the original issue on edge. Were you able to? |
Yes. If you try on a new transaction, it works. it only fails when you distribute a created transaction |
Fix #3662