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

Convert Mobile Transaction component to TransactionListItem + cleanup #3761

Merged
merged 7 commits into from
Nov 18, 2024

Conversation

joel-jeremy
Copy link
Contributor

@joel-jeremy joel-jeremy commented Oct 31, 2024

Removed a bunch of files and replaced it with react-aria-component equivalent components

Did some minor adjustments to the horizontal paddings of transaction list items hence the VRT screenshot changes

@actual-github-bot actual-github-bot bot changed the title Migration mobile Transaction component to TransactionListItem + cleanup [WIP] Migration mobile Transaction component to TransactionListItem + cleanup Oct 31, 2024
Copy link

netlify bot commented Oct 31, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit ab7eee6
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/673ae865dc0e9c00087c0b22
😎 Deploy Preview https://deploy-preview-3761.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.

Copy link
Contributor

github-actions bot commented Oct 31, 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.36 MB → 5.43 MB (+68.98 kB) +1.26%
Changeset
File Δ Size
node_modules/react-aria-components/dist/ListBox.mjs 🆕 +17.48 kB 0 B → 17.48 kB
node_modules/@react-aria/collections/dist/Document.mjs 🆕 +12.83 kB 0 B → 12.83 kB
node_modules/@react-aria/collections/dist/CollectionBuilder.mjs 🆕 +11.07 kB 0 B → 11.07 kB
src/components/mobile/transactions/TransactionListItem.tsx 🆕 +6.54 kB 0 B → 6.54 kB
node_modules/@react-aria/live-announcer/dist/LiveAnnouncer.mjs 🆕 +5.55 kB 0 B → 5.55 kB
node_modules/@react-aria/collections/dist/BaseCollection.mjs 🆕 +5.49 kB 0 B → 5.49 kB
node_modules/react-aria-components/dist/DragAndDrop.mjs 🆕 +4.06 kB 0 B → 4.06 kB
node_modules/react-aria-components/dist/Collection.mjs 🆕 +2.66 kB 0 B → 2.66 kB
node_modules/@react-aria/collections/dist/useCachedChildren.mjs 🆕 +2.45 kB 0 B → 2.45 kB
node_modules/react-aria-components/dist/Header.mjs 🆕 +1.12 kB 0 B → 1.12 kB
node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js 🆕 +1.09 kB 0 B → 1.09 kB
node_modules/react-aria-components/dist/ProgressBar.mjs 🆕 +724 B 0 B → 724 B
node_modules/react-aria-components/dist/Separator.mjs 🆕 +722 B 0 B → 722 B
node_modules/react-aria-components/dist/Text.mjs 🆕 +719 B 0 B → 719 B
node_modules/clsx/dist/clsx.js 🆕 +509 B 0 B → 509 B
node_modules/use-sync-external-store/shim/index.js 🆕 +98 B 0 B → 98 B
node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js?commonjs-exports 🆕 +49 B 0 B → 49 B
node_modules/clsx/dist/clsx.js?commonjs-module 🆕 +27 B 0 B → 27 B
node_modules/use-sync-external-store/shim/index.js?commonjs-module 🆕 +27 B 0 B → 27 B
node_modules/react-aria-components/dist/Button.mjs 📈 +2.2 kB (+81.42%) 2.7 kB → 4.9 kB
node_modules/@react-aria/collections/dist/Hidden.mjs 📈 +1.03 kB (+46.25%) 2.23 kB → 3.26 kB
node_modules/@react-stately/list/dist/useListState.mjs 📈 +1.44 kB (+39.77%) 3.63 kB → 5.07 kB
node_modules/@react-stately/list/dist/ListCollection.mjs 📈 +482 B (+19.01%) 2.48 kB → 2.95 kB
node_modules/@react-aria/utils/dist/useId.mjs 📈 +433 B (+15.53%) 2.72 kB → 3.15 kB
node_modules/@react-stately/collections/dist/CollectionBuilder.mjs 📈 +731 B (+8.78%) 8.13 kB → 8.84 kB
node_modules/react-aria-components/dist/utils.mjs 📈 +699 B (+8.70%) 7.85 kB → 8.53 kB
node_modules/@react-stately/selection/dist/Selection.mjs 📈 +90 B (+8.51%) 1.03 kB → 1.12 kB
node_modules/@react-aria/selection/dist/ListKeyboardDelegate.mjs 📈 +506 B (+6.15%) 8.03 kB → 8.52 kB
node_modules/@react-aria/selection/dist/useSelectableCollection.mjs 📈 +1018 B (+5.88%) 16.9 kB → 17.9 kB
node_modules/@react-stately/selection/dist/SelectionManager.mjs 📈 +638 B (+4.95%) 12.58 kB → 13.2 kB
node_modules/@react-aria/interactions/dist/usePress.mjs 📈 +1.36 kB (+4.18%) 32.63 kB → 33.99 kB
node_modules/@react-aria/utils/dist/openLink.mjs 📈 +114 B (+2.33%) 4.79 kB → 4.9 kB
home/runner/work/actual/actual/packages/loot-core/src/shared/months.ts 📈 +8 B (+0.10%) 7.85 kB → 7.86 kB
node_modules/react-grid-layout/build/ReactGridLayout.js 📉 -1 B (-0.00%) 24.96 kB → 24.96 kB
node_modules/react-grid-layout/build/GridItem.js 📉 -1 B (-0.00%) 21.49 kB → 21.49 kB
node_modules/react-grid-layout/build/components/WidthProvider.js 📉 -1 B (-0.02%) 5.22 kB → 5.22 kB
node_modules/define-data-property/index.js 📉 -9 B (-0.39%) 2.25 kB → 2.24 kB
node_modules/call-bind/index.js 📉 -9 B (-0.84%) 1.05 kB → 1.04 kB
node_modules/@react-aria/button/dist/useButton.mjs 📉 -33 B (-1.05%) 3.06 kB → 3.03 kB
src/components/mobile/accounts/AccountTransactions.tsx 📉 -84 B (-1.10%) 7.48 kB → 7.39 kB
src/components/mobile/transactions/TransactionList.jsx 📉 -216 B (-1.34%) 15.71 kB → 15.5 kB
node_modules/has-property-descriptors/index.js 📉 -9 B (-1.55%) 582 B → 573 B
src/components/mobile/transactions/TransactionListWithBalances.jsx 📉 -192 B (-3.42%) 5.48 kB → 5.29 kB
node_modules/es-define-property/index.js 📉 -210 B (-37.50%) 560 B → 350 B
src/components/mobile/transactions/Transaction.jsx 🔥 -6.14 kB (-100%) 6.14 kB → 0 B
node_modules/@react-stately/collections/dist/Item.mjs 🔥 -2.45 kB (-100%) 2.45 kB → 0 B
node_modules/@react-stately/collections/dist/Section.mjs 🔥 -1.79 kB (-100%) 1.79 kB → 0 B
src/components/mobile/transactions/ListBoxSection.jsx 🔥 -1.47 kB (-100%) 1.47 kB → 0 B
src/components/mobile/transactions/ListBox.jsx 🔥 -1.07 kB (-100%) 1.07 kB → 0 B
src/components/mobile/transactions/Option.jsx 🔥 -764 B (-100%) 764 B → 0 B
node_modules/clsx/dist/clsx.mjs 🔥 -368 B (-100%) 368 B → 0 B
node_modules/clsx/dist/clsx.mjs?commonjs-proxy 🔥 -64 B (-100%) 64 B → 0 B
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/index.js 3.37 MB → 3.44 MB (+69.13 kB) +2.00%

Smaller

Asset File Size % Changed
static/js/narrow.js 82.76 kB → 82.68 kB (-84 B) -0.10%
static/js/ReportRouter.js 1.49 MB → 1.49 MB (-67 B) -0.00%

Unchanged

Asset File Size % Changed
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/workbox-window.prod.es5.js 5.69 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/AppliedFilters.js 21.3 kB 0%
static/js/wide.js 242.81 kB 0%

Copy link
Contributor

github-actions bot commented Oct 31, 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.32 MB 0%
Changeset
File Δ Size
packages/loot-core/src/shared/months.ts 📈 +6 B (+0.05%) 11.71 kB → 11.71 kB
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.32 MB 0%

@joel-jeremy joel-jeremy force-pushed the ts-migrate-mobile-Transaction-component branch from bad17ba to 5c3798c Compare November 3, 2024 22:28
@joel-jeremy joel-jeremy changed the title [WIP] Migration mobile Transaction component to TransactionListItem + cleanup Convert Mobile Transaction component to TransactionListItem + cleanup Nov 4, 2024
Copy link
Contributor

coderabbitai bot commented Nov 4, 2024

Walkthrough

This pull request introduces several changes primarily focused on updating dependencies and modifying components within the @actual-app/web project. The package.json file has been updated to reflect new versions for react-aria and react-aria-components, while react-stately has been downgraded. Additionally, multiple React components related to transaction handling, including ListBox, ListBoxSection, Option, and Transaction, have been removed. A new component, TransactionListItem, has been added to represent individual transaction items, while the TransactionList component has been updated to incorporate new imports and modify its structure for handling transactions. The TransactionListWithBalances component has seen the removal of the isNewTransaction prop, simplifying its state management. Lastly, a minor change in the format function's parameter name in the months.ts file has been made for clarity, without altering its functionality.

Possibly related PRs

  • 🔖 (24.10.0) #3545: Both PRs involve updates to version numbers in package.json files, indicating a direct connection in terms of dependency management.

Suggested labels

sparkles: Merged

Suggested reviewers

  • youngcw
  • MikesGlitch

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-eslint-plugin".

(The package "eslint-plugin-eslint-plugin" was not found when loaded as a Node module from the directory "/packages/eslint-plugin-actual".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-eslint-plugin@latest --save-dev

The plugin "eslint-plugin-eslint-plugin" was referenced from the config file in "packages/eslint-plugin-actual/.eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.


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

🧹 Outside diff range and nitpick comments (3)
packages/desktop-client/src/components/mobile/transactions/TransactionListItem.tsx (2)

110-116: Simplify nested ternary operators for better readability

The nested ternary operators used to determine specialCategory can make the code harder to read and maintain. Refactoring to use if...else statements enhances clarity.

Apply this diff to improve readability:

- const specialCategory = account?.offbudget
-   ? 'Off Budget'
-   : transferAcct && !transferAcct.offbudget
-     ? 'Transfer'
-     : isParent
-       ? 'Split'
-       : null;
+ let specialCategory = null;
+
+ if (account?.offbudget) {
+   specialCategory = 'Off Budget';
+ } else if (transferAcct && !transferAcct.offbudget) {
+   specialCategory = 'Transfer';
+ } else if (isParent) {
+   specialCategory = 'Split';
+ }

135-160: Extract inline styles to improve performance

Inline styling within the Button component creates new style objects on every render, which can impact performance. Consider extracting these styles into a constant or a stylesheet to enhance performance and maintainability.

Apply this diff to extract the styles:

+ const buttonStyle = {
+   userSelect: 'none',
+   height: ROW_HEIGHT,
+   width: '100%',
+   borderRadius: 0,
+   ...(isSelected
+     ? {
+         borderWidth: '0 0 0 4px',
+         borderColor: theme.mobileTransactionSelected,
+         borderStyle: 'solid',
+       }
+     : {
+         borderWidth: '0 0 1px 0',
+         borderColor: theme.tableBorder,
+         borderStyle: 'solid',
+       }),
+   ...(isPreview
+     ? {
+         backgroundColor: theme.tableRowHeaderBackground,
+       }
+     : {
+         backgroundColor: theme.tableBackground,
+       }),
+ };

              <Button
-               style={{
-                 userSelect: 'none',
-                 height: ROW_HEIGHT,
-                 width: '100%',
-                 borderRadius: 0,
-                 ...(isSelected
-                   ? {
-                       borderWidth: '0 0 0 4px',
-                       borderColor: theme.mobileTransactionSelected,
-                       borderStyle: 'solid',
-                     }
-                   : {
-                       borderWidth: '0 0 1px 0',
-                       borderColor: theme.tableBorder,
-                       borderStyle: 'solid',
-                     }),
-                 ...(isPreview
-                   ? {
-                       backgroundColor: theme.tableRowHeaderBackground,
-                     }
-                   : {
-                       backgroundColor: theme.tableBackground,
-                     }),
-               }}
+               style={buttonStyle}
              >
packages/desktop-client/src/components/mobile/transactions/TransactionList.jsx (1)

153-158: Optimize event handlers to prevent unnecessary re-renders

Currently, new arrow functions are being created for each TransactionListItem, which can lead to performance issues due to unnecessary re-renders. Bind the event handlers outside the render method or pass the handlers directly if possible.

Apply this diff to optimize the event handlers:

                   <TransactionListItem
                     key={transaction.id}
                     value={transaction}
-                    onPress={trans => onTransactionPress(trans)}
-                    onLongPress={trans => onTransactionPress(trans, true)}
+                    onPress={onTransactionPress}
+                    onLongPress={event => onTransactionPress(event, true)}
                   />
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e078ed2 and ce3be9f.

⛔ Files ignored due to path filters (17)
  • packages/desktop-client/e2e/accounts.mobile.test.js-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-1-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/accounts.mobile.test.js-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-2-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/accounts.mobile.test.js-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-3-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/accounts.mobile.test.js-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-7-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/accounts.mobile.test.js-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-8-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/accounts.mobile.test.js-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-9-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/budget.mobile.test.js-snapshots/Mobile-Budget-Envelope-checks-that-clicking--c18ad-l-redirects-to-the-category-transactions-page-1-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/budget.mobile.test.js-snapshots/Mobile-Budget-Envelope-checks-that-clicking--e995e-l-redirects-to-the-category-transactions-page-3-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/budget.mobile.test.js-snapshots/Mobile-Budget-Envelope-checks-that-clicking--ff568-l-redirects-to-the-category-transactions-page-2-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/budget.mobile.test.js-snapshots/Mobile-Budget-Tracking-checks-that-clicking--11290-l-redirects-to-the-category-transactions-page-3-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/budget.mobile.test.js-snapshots/Mobile-Budget-Tracking-checks-that-clicking--57d88-l-redirects-to-the-category-transactions-page-2-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/budget.mobile.test.js-snapshots/Mobile-Budget-Tracking-checks-that-clicking--5d90c-l-redirects-to-the-category-transactions-page-1-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-7-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-8-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-9-chromium-linux.png is excluded by !**/*.png
  • upcoming-release-notes/3761.md is excluded by !**/*.md
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (9)
  • packages/desktop-client/package.json (2 hunks)
  • packages/desktop-client/src/components/mobile/transactions/ListBox.jsx (0 hunks)
  • packages/desktop-client/src/components/mobile/transactions/ListBoxSection.jsx (0 hunks)
  • packages/desktop-client/src/components/mobile/transactions/Option.jsx (0 hunks)
  • packages/desktop-client/src/components/mobile/transactions/Transaction.jsx (0 hunks)
  • packages/desktop-client/src/components/mobile/transactions/TransactionList.jsx (4 hunks)
  • packages/desktop-client/src/components/mobile/transactions/TransactionListItem.tsx (1 hunks)
  • packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.jsx (0 hunks)
  • packages/loot-core/src/shared/months.ts (1 hunks)
💤 Files with no reviewable changes (5)
  • packages/desktop-client/src/components/mobile/transactions/ListBox.jsx
  • packages/desktop-client/src/components/mobile/transactions/ListBoxSection.jsx
  • packages/desktop-client/src/components/mobile/transactions/Option.jsx
  • packages/desktop-client/src/components/mobile/transactions/Transaction.jsx
  • packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.jsx
✅ Files skipped from review due to trivial changes (1)
  • packages/loot-core/src/shared/months.ts
🔇 Additional comments (4)
packages/desktop-client/package.json (2)

53-54: LGTM: Minor version updates for react-aria packages.

The minor version bumps for react-aria (^3.35.1) and react-aria-components (^1.4.1) are appropriate for the component conversion work being done.


68-68: Verify react-stately version compatibility.

The significant version change of react-stately from ^3.10.9 to ^3.33.0 could introduce breaking changes. Please ensure this version is compatible with the react-aria-components being used.

✅ Verification successful

The react-stately version update is safe to proceed.

The version change from ^3.10.9 to ^3.33.0 is compatible with the react-aria-components being used. From the yarn.lock analysis:

  1. [email protected] explicitly lists react-stately@^3.33.0 as a dependency
  2. All individual @react-stately/* packages are properly aligned with this version
  3. No conflicting peer dependency requirements were found
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential compatibility issues between react-stately and react-aria-components

# Test: Search for react-stately imports and usages to assess impact
rg -A 5 'from.*react-stately'

# Test: Check package.json in node_modules for peer dependency requirements
cat node_modules/react-aria-components/package.json | jq '.peerDependencies["react-stately"]'

Length of output: 207


Script:

#!/bin/bash
# Let's try a different approach to verify react-stately usage and compatibility

# Check direct imports of react-stately in the codebase
rg -l 'from.*react-stately'

# Look for specific react-stately hooks or components being used
rg -l 'use.*State|useSelectState|useComboBoxState|useListState'

# Check if there's a yarn.lock or package-lock.json to see resolved versions
fd -e lock

# If found, let's examine the resolved versions in the lockfile
if [ -f "yarn.lock" ]; then
    rg -A 5 'react-stately|react-aria-components' yarn.lock
elif [ -f "package-lock.json" ]; then
    rg -A 5 'react-stately|react-aria-components' package-lock.json
fi

Length of output: 35078

packages/desktop-client/src/components/mobile/transactions/TransactionListItem.tsx (1)

64-79: Potential conflict when merging usePress and useLongPress props

Merging pressProps and longPressProps might lead to unintended behavior or event handling conflicts. Consider using the Pressable component from @react-aria/interactions, which natively supports both onPress and onLongPress events. This can simplify the code and ensure consistent behavior across devices.

packages/desktop-client/src/components/mobile/transactions/TransactionList.jsx (1)

8-8: Confirm imports from 'react-aria-components'

Ensure that all imported components (ListBox, Section, Header, Collection) are correctly exported from react-aria-components. Incorrect imports can lead to runtime errors if the components are not available.

Run the following script to confirm the availability of these components:

✅ Verification successful

Components from react-aria-components are properly used and imported

The verification confirms that:

  1. react-aria-components is correctly listed as a dependency in package.json with version "^1.4.1"
  2. The components (ListBox, Section, Header, Collection) are actively used in the TransactionList component with proper implementation
  3. Multiple other files in the codebase also use these components successfully
  4. The code shows proper integration of these components in a working list implementation with sections and headers

The import statement is correct and the components are being used as intended.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that 'react-aria-components' exports the required components.

# Test: List exported members from 'react-aria-components' package.
# Expect: 'ListBox', 'Section', 'Header', and 'Collection' should be listed.

grep -E 'export.*(ListBox|Section|Header|Collection)' node_modules/react-aria-components/dist/index.esm.js

Length of output: 194


Script:

#!/bin/bash
# Let's first check if the package exists in node_modules and its structure
fd -t d "react-aria-components" node_modules

# Then let's check the actual usage of these components in the codebase
ast-grep --pattern 'import { $$$ListBox$$$, $$$Section$$$, $$$Header$$$, $$$Collection$$$ } from "react-aria-components"'

# Also search for actual usage of these components
rg "<(ListBox|Section|Header|Collection)" -l

Length of output: 1147


Script:

#!/bin/bash
# Let's check the package.json to verify the dependency
rg '"react-aria-components"' packages/desktop-client/package.json

# Let's also check how these components are actually used in TransactionList.jsx
cat packages/desktop-client/src/components/mobile/transactions/TransactionList.jsx

Length of output: 16271

@joel-jeremy joel-jeremy force-pushed the ts-migrate-mobile-Transaction-component branch from ce3be9f to 162a0b9 Compare November 12, 2024 17:05
@joel-jeremy joel-jeremy force-pushed the ts-migrate-mobile-Transaction-component branch from 162a0b9 to 3756d76 Compare November 17, 2024 22:01
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 (3)
packages/desktop-client/src/components/mobile/transactions/TransactionList.jsx (3)

73-83: Consider optimizing transaction press handler

The current implementation could be more efficient by:

  1. Moving the isPreview check before the callback creation
  2. Separating long press and normal press into different handlers
+ const isPreviewTransaction = useCallback(
+   (transaction) => isPreviewId(transaction.id),
+   []
+ );
+
+ const onTransactionLongPress = useCallback(
+   (transaction) => {
+     if (!isPreviewTransaction(transaction)) {
+       dispatchSelected({ type: 'select', id: transaction.id });
+     }
+   },
+   [dispatchSelected, isPreviewTransaction]
+ );
+
- const onTransactionPress = useCallback(
-   (transaction, isLongPress = false) => {
-     const isPreview = isPreviewId(transaction.id);
-     if (!isPreview && (isLongPress || selectedTransactions.size > 0)) {
-       dispatchSelected({ type: 'select', id: transaction.id });
-     } else {
-       onOpenTransaction(transaction);
-     }
-   },
-   [dispatchSelected, onOpenTransaction, selectedTransactions.size],
- );
+ const onTransactionPress = useCallback(
+   (transaction) => {
+     if (!isPreviewTransaction(transaction) && selectedTransactions.size > 0) {
+       dispatchSelected({ type: 'select', id: transaction.id });
+     } else {
+       onOpenTransaction(transaction);
+     }
+   },
+   [dispatchSelected, onOpenTransaction, selectedTransactions.size, isPreviewTransaction]
+ );

131-144: Consider extracting header styles to a separate constant

The inline styles in the Header component could be moved to a constant or styled-component for better maintainability and reusability.

+ const headerStyles = {
+   ...styles.smallText,
+   backgroundColor: theme.pageBackground,
+   color: theme.tableHeaderText,
+   display: 'flex',
+   justifyContent: 'center',
+   paddingBottom: 4,
+   paddingTop: 4,
+   position: 'sticky',
+   top: '0',
+   width: '100%',
+   zIndex: 10,
+ };

  <Header
-   style={{
-     ...styles.smallText,
-     backgroundColor: theme.pageBackground,
-     color: theme.tableHeaderText,
-     display: 'flex',
-     justifyContent: 'center',
-     paddingBottom: 4,
-     paddingTop: 4,
-     position: 'sticky',
-     top: '0',
-     width: '100%',
-     zIndex: 10,
-   }}
+   style={headerStyles}
  >

148-153: Consider memoizing the filter callback for better performance

The filter callback in the Collection component could be memoized to prevent unnecessary re-renders.

+ const filterTransactions = useCallback(
+   (t) => !isPreviewId(t.id) || !t.is_child,
+   []
+ );

  <Collection
    items={section.transactions.filter(
-     t => !isPreviewId(t.id) || !t.is_child,
+     filterTransactions
    )}
    addIdAndValue
  >
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 162a0b9 and 3756d76.

⛔ Files ignored due to path filters (17)
  • packages/desktop-client/e2e/accounts.mobile.test.js-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-1-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/accounts.mobile.test.js-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-2-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/accounts.mobile.test.js-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-3-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/accounts.mobile.test.js-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-7-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/accounts.mobile.test.js-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-8-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/accounts.mobile.test.js-snapshots/Mobile-Accounts-opens-individual-account-page-and-checks-that-filtering-is-working-9-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/budget.mobile.test.js-snapshots/Mobile-Budget-Envelope-checks-that-clicking--c18ad-l-redirects-to-the-category-transactions-page-1-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/budget.mobile.test.js-snapshots/Mobile-Budget-Envelope-checks-that-clicking--e995e-l-redirects-to-the-category-transactions-page-3-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/budget.mobile.test.js-snapshots/Mobile-Budget-Envelope-checks-that-clicking--ff568-l-redirects-to-the-category-transactions-page-2-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/budget.mobile.test.js-snapshots/Mobile-Budget-Tracking-checks-that-clicking--11290-l-redirects-to-the-category-transactions-page-3-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/budget.mobile.test.js-snapshots/Mobile-Budget-Tracking-checks-that-clicking--57d88-l-redirects-to-the-category-transactions-page-2-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/budget.mobile.test.js-snapshots/Mobile-Budget-Tracking-checks-that-clicking--5d90c-l-redirects-to-the-category-transactions-page-1-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-7-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-8-chromium-linux.png is excluded by !**/*.png
  • packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-9-chromium-linux.png is excluded by !**/*.png
  • upcoming-release-notes/3761.md is excluded by !**/*.md
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (9)
  • packages/desktop-client/package.json (2 hunks)
  • packages/desktop-client/src/components/mobile/transactions/ListBox.jsx (0 hunks)
  • packages/desktop-client/src/components/mobile/transactions/ListBoxSection.jsx (0 hunks)
  • packages/desktop-client/src/components/mobile/transactions/Option.jsx (0 hunks)
  • packages/desktop-client/src/components/mobile/transactions/Transaction.jsx (0 hunks)
  • packages/desktop-client/src/components/mobile/transactions/TransactionList.jsx (4 hunks)
  • packages/desktop-client/src/components/mobile/transactions/TransactionListItem.tsx (1 hunks)
  • packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.jsx (0 hunks)
  • packages/loot-core/src/shared/months.ts (1 hunks)
💤 Files with no reviewable changes (5)
  • packages/desktop-client/src/components/mobile/transactions/ListBox.jsx
  • packages/desktop-client/src/components/mobile/transactions/ListBoxSection.jsx
  • packages/desktop-client/src/components/mobile/transactions/Option.jsx
  • packages/desktop-client/src/components/mobile/transactions/Transaction.jsx
  • packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.jsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/desktop-client/package.json
  • packages/desktop-client/src/components/mobile/transactions/TransactionListItem.tsx
  • packages/loot-core/src/shared/months.ts
🔇 Additional comments (2)
packages/desktop-client/src/components/mobile/transactions/TransactionList.jsx (2)

8-8: LGTM: Clean transition to react-aria-components

The import changes align well with the PR's objective of converting to react-aria-components, providing better accessibility and maintainability.

Also applies to: 40-40


85-93: Reiterating previous review comment about scroll state tracking

The previous review comment about updating prevScrolledToBottom.current is still valid and should be addressed.

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/TransactionList.jsx (1)

Line range hint 367-371: Address TODO comment regarding schedule functionality

There's a pending TODO about updating the undo notification message with messageActions when schedule becomes available in mobile.

Would you like me to help create a GitHub issue to track this enhancement for when schedule functionality becomes available in mobile?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3756d76 and 05d3430.

📒 Files selected for processing (1)
  • packages/desktop-client/src/components/mobile/transactions/TransactionList.jsx (4 hunks)
🔇 Additional comments (3)
packages/desktop-client/src/components/mobile/transactions/TransactionList.jsx (3)

8-8: LGTM: Import changes align with component modernization

The new imports from react-aria-components and the addition of TransactionListItem align well with the PR's objective of modernizing the component structure.

Also applies to: 37-37, 40-40


Line range hint 44-67: LGTM: Clean component structure with improved prop handling

The component signature is now more explicit, and the section data structure is well-organized for transaction grouping.


144-158: LGTM: Improved list rendering with Collection component

The use of Collection component with proper filtering and item handling improves both accessibility and performance. The filtering of preview transactions is handled correctly.

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/accounts/AccountTransactions.tsx (1)

320-320: LGTM: Simplified loading state props.

The change to use only the main isLoading prop simplifies the component's loading state management and improves maintainability.

Consider adding TypeScript prop validation to ensure type safety:

+type TransactionListWithBalancesProps = {
+  isLoading: boolean;
+  transactions: TransactionEntity[];
+  balance: Query;
+  balanceCleared?: Query;
+  balanceUncleared?: Query;
+  onLoadMore?: () => void;
+  searchPlaceholder: string;
+  onSearch: (query: string) => void;
+  onOpenTransaction: (transaction: TransactionEntity) => void;
+  onRefresh?: () => void;
+};
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 05d3430 and ab7eee6.

📒 Files selected for processing (1)
  • packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsx (2 hunks)
🧰 Additional context used
📓 Learnings (1)
packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsx (3)
Learnt from: jfdoming
PR: actualbudget/actual#3402
File: packages/desktop-client/src/components/accounts/Account.tsx:8-8
Timestamp: 2024-11-10T16:45:25.627Z
Learning: In the `AllTransactions` component of `Account.tsx`, the `useLayoutEffect` hook is appropriately used to dispatch an action that closes splits for parent transactions when `prependTransactions` changes, ensuring this occurs synchronously before the component is painted.
Learnt from: jfdoming
PR: actualbudget/actual#3402
File: packages/desktop-client/src/components/accounts/Account.tsx:8-8
Timestamp: 2024-11-10T16:45:31.225Z
Learning: In the `AllTransactions` component of `Account.tsx`, the `useLayoutEffect` hook is appropriately used to dispatch an action that closes splits for parent transactions when `prependTransactions` changes, ensuring this occurs synchronously before the component is painted.
Learnt from: joel-jeremy
PR: actualbudget/actual#3685
File: packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsx:261-277
Timestamp: 2024-11-10T16:45:25.627Z
Learning: In React components (TypeScript), avoid using hooks like `useCallback` inside callbacks or nested functions. Hooks must be called at the top level of functional components.
🔇 Additional comments (1)
packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsx (1)

242-242: LGTM: Simplified preview transactions loading state.

The change to only destructure data from usePreviewTransactions hook aligns with the cleanup objectives and simplifies the loading state management.

Let's verify that the removal of isLoading from preview transactions doesn't affect other components:

✅ Verification successful

Removal of isLoading from usePreviewTransactions is safe

The verification confirms that no other components in the codebase are using the isLoading property from usePreviewTransactions, making this change safe and non-breaking.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining usage of isLoading from usePreviewTransactions
rg -l "usePreviewTransactions.*isLoading" || echo "No components depend on isLoading from usePreviewTransactions"

Length of output: 176

Copy link
Contributor

@MikesGlitch MikesGlitch left a comment

Choose a reason for hiding this comment

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

LGTM

@joel-jeremy joel-jeremy merged commit 18f538c into master Nov 18, 2024
20 checks passed
@joel-jeremy joel-jeremy deleted the ts-migrate-mobile-Transaction-component branch November 18, 2024 14:38
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