Skip to content
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

[Mobile] Allow updating existing transaction's account #3549

Merged
merged 5 commits into from
Oct 8, 2024

Conversation

joel-jeremy
Copy link
Contributor

No description provided.

@actual-github-bot actual-github-bot bot changed the title [Mobile] Allow updating existing transaction's account [WIP] [Mobile] Allow updating existing transaction's account Oct 3, 2024
Copy link
Contributor

coderabbitai bot commented Oct 3, 2024

Walkthrough

The changes made in the TransactionEdit.jsx component involve significant refactoring and performance enhancements. The useCallback hook has been extensively integrated to memoize functions, which helps maintain the same reference across renders and reduces unnecessary re-renders of child components. The onTotalAmountEdit function has been refactored for performance improvements, and the useEffect logic has been updated to utilize a new useInitialMount hook, allowing specific logic to execute only on the component's first render. Several other functions, including getAccount, getPayee, and isBudgetTransfer, have been refactored to enhance efficiency. The onSave and onUpdate functions have been renamed and refactored to improve the clarity of the update logic. Additionally, the Footer component's props have been updated to align with the new transaction editing logic. Overall, the structure of the component has been improved for better readability and maintainability.

Possibly related PRs

Suggested labels

::sparkles: Merged

Suggested reviewers

  • MatissJanis
  • youngcw

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3bc0c1e and ae35c4f.

📒 Files selected for processing (1)
  • packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (14 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Oct 3, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit ae35c4f
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/66fef3e48cd214000864bb2e
😎 Deploy Preview https://deploy-preview-3549.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@joel-jeremy joel-jeremy force-pushed the mobile-allow-updating-transaction-account branch from 8840fd6 to 3bc0c1e Compare October 3, 2024 18:50
@joel-jeremy joel-jeremy changed the title [WIP] [Mobile] Allow updating existing transaction's account [Mobile] Allow updating existing transaction's account Oct 3, 2024
Copy link
Contributor

github-actions bot commented Oct 3, 2024

Bundle Stats — desktop-client

Hey 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

Files count Total bundle size % Changed
9 5.29 MB → 5.3 MB (+1.6 kB) +0.03%
Changeset
File Δ Size
src/components/mobile/transactions/TransactionEdit.jsx 📈 +1.6 kB (+4.91%) 32.5 kB → 34.09 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/index.js 3.32 MB → 3.32 MB (+1.6 kB) +0.05%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/AppliedFilters.js 20.96 kB 0%
static/js/usePreviewTransactions.js 1.64 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/narrow.js 81.98 kB 0%
static/js/wide.js 225.26 kB 0%
static/js/ReportRouter.js 1.5 MB 0%

Copy link
Contributor

github-actions bot commented Oct 3, 2024

Bundle Stats — loot-core

Hey 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

Files count Total bundle size % Changed
1 1.19 MB 0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.js 1.19 MB 0%

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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/mobile/transactions/TransactionEdit.jsx (1)

470-470: Consider renaming hasAccountChanged to a more descriptive name.

The name hasAccountChanged doesn't clearly convey the purpose of this ref. Consider renaming it to something more descriptive like isAccountChanged or didAccountChange to indicate that it's a boolean flag.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d0caf9f and 3bc0c1e.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/3549.md is excluded by !**/*.md
📒 Files selected for processing (1)
  • packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (14 hunks)
🧰 Additional context used
🪛 Biome
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx

[error] 514-514: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (35)
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (35)

8-8: LGTM!

The useCallback hook is imported correctly.


47-47: LGTM!

The useInitialMount hook is imported correctly.


454-454: LGTM!

The navigate function is correctly obtained using the useNavigate hook.


475-480: LGTM!

The onTotalAmountEdit function is correctly memoized using the useCallback hook with appropriate dependencies.


482-482: LGTM!

The useInitialMount hook is used correctly to determine if the component is mounted for the first time.


485-488: LGTM!

The useEffect hook is used correctly to call onTotalAmountEdit when the component mounts for the first time and adding is true.


490-495: LGTM!

The getAccount function is correctly memoized using the useCallback hook with the accountsById dependency.


497-502: LGTM!

The getPayee function is correctly memoized using the useCallback hook with the payeesById dependency.


504-510: LGTM!

The getTransferAcct function is correctly memoized using the useCallback hook with the accountsById and getPayee dependencies.


512-522: LGTM!

The getPrettyPayee function is correctly memoized using the useCallback hook with the getPayee and getTransferAcct dependencies.

🧰 Tools
🪛 Biome

[error] 514-514: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


524-530: LGTM!

The isBudgetTransfer function is correctly memoized using the useCallback hook with the getTransferAcct dependency.


532-541: LGTM!

The getCategory function is correctly memoized using the useCallback hook with the categories and isBudgetTransfer dependencies.


Line range hint 543-584: LGTM!

The onSaveInner function is correctly memoized using the useCallback hook with appropriate dependencies. The logic for handling transaction saves, navigating to the appropriate screen based on the account change, and showing a confirmation modal for reconciled transactions looks good.

🧰 Tools
🪛 Biome

[error] 514-514: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


586-597: LGTM!

The onUpdateInner function is correctly memoized using the useCallback hook with the onClearActiveEdit and onUpdate dependencies. The logic for updating a transaction, clearing the active edit state, and tracking account changes looks good.


599-608: LGTM!

The onTotalAmountUpdate function is correctly memoized using the useCallback hook with the onClearActiveEdit, onUpdateInner, and transaction dependencies. The logic for updating the total amount of the transaction looks good.


610-685: LGTM!

The onEditFieldInner function is correctly memoized using the useCallback hook with appropriate dependencies. The logic for handling different field edits by dispatching the appropriate modal actions looks good.


687-721: LGTM!

The onDeleteInner function is correctly memoized using the useCallback hook with appropriate dependencies. The logic for handling transaction deletion, navigating back, and showing a confirmation modal for reconciled transactions looks good.


723-729: LGTM!

The scrollChildTransactionIntoView function is correctly memoized using the useCallback hook with no dependencies. The logic for scrolling a child transaction element into view looks good.


731-736: LGTM!

The onEmptySplitFound function is correctly memoized using the useCallback hook with the scrollChildTransactionIntoView dependency. The logic for scrolling to the empty split transaction looks good.


784-784: LGTM!

The onSaveInner function is correctly passed as the onAdd prop to the Footer component.


785-785: LGTM!

The onSaveInner function is correctly passed as the onSave prop to the Footer component.


790-790: LGTM!

The onEditFieldInner function is correctly passed as the onEditField prop to the Footer component.


833-833: LGTM!

The onEditFieldInner function is correctly called with the transaction.id and 'payee' arguments when the payee field is clicked.


856-856: LGTM!

The onEditFieldInner function is correctly called with the transaction.id and 'category' arguments when the category field is clicked.


878-878: LGTM!

The onUpdateInner function is correctly passed as the onUpdate prop to the ChildTransactionEdit component.


879-879: LGTM!

The onEditFieldInner function is correctly passed as the onEditField prop to the ChildTransactionEdit component.


880-880: LGTM!

The onDeleteInner function is correctly passed as the onDelete prop to the ChildTransactionEdit component.


921-922: LGTM!

The account field is correctly disabled when an edit is in progress and the field being edited is not the account field.


925-925: LGTM!

The onEditFieldInner function is correctly called with the transaction.id and 'account' arguments when the account field is clicked.


Line range hint 946-950: LGTM!

The onUpdateInner function is correctly called with the transaction, 'date', and formatted date arguments when the date field is updated.


973-975: LGTM!

The onUpdateInner function is correctly called with the transaction, 'cleared', and checked arguments when the cleared field is updated.


997-997: LGTM!

The onUpdateInner function is correctly called with the transaction, 'notes', and value arguments when the notes field is updated.


1004-1004: LGTM!

The onDeleteInner function is correctly called with the transaction.id argument when the delete button is clicked.


514-514: Verify the optional chaining suggestion from the static analysis tool.

The static analysis tool suggests changing the expression to use optional chaining. However, the current code already uses optional chaining (?.) to safely access the transfer_acct property. Therefore, the suggestion can be ignored as a false positive.

🧰 Tools
🪛 Biome

[error] 514-514: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


448-453: Verify the function signature change in the codebase.

The onSave, onUpdate, onDelete, onSplit, and onAddSplit props have been removed from the TransactionEditInner component's signature. Ensure that all the places where this component is used have been updated to match the new signature.

Run the following script to verify the usage of TransactionEditInner:

✅ Verification successful

Adjust the verification script to correctly target .jsx files.


Verification Successful: TransactionEditInner component signatures are correctly updated.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of `TransactionEditInner` match the new signature.

# Test: Search for the component usage. Expect: No occurrences of the removed props.
rg --type jsx -A 5 $'<TransactionEditInner'

Length of output: 72


Script:

#!/bin/bash
# Description: Re-verify all usages of `TransactionEditInner` in `.jsx` files.

# Test: Search for the component usage. Expect: No occurrences of the removed props.
rg '<TransactionEditInner' --glob '*.jsx' -A 5

Length of output: 702

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d0caf9f and 3bc0c1e.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/3549.md is excluded by !**/*.md
📒 Files selected for processing (1)
  • packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (14 hunks)
🧰 Additional context used
🪛 Biome
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx

[error] 514-514: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

joel-jeremy and others added 3 commits October 3, 2024 12:42
…nsactionEdit.jsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…nsactionEdit.jsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…nsactionEdit.jsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants