diff --git a/.cursor/rules/typescript.mdc b/.cursor/rules/typescript.mdc index 661f3e46c0..d304044e7f 100644 --- a/.cursor/rules/typescript.mdc +++ b/.cursor/rules/typescript.mdc @@ -1,5 +1,5 @@ --- -description: +description: globs: *.ts,*.tsx alwaysApply: false --- @@ -21,7 +21,7 @@ Naming Conventions TypeScript Usage -- Use TypeScript for all code; prefer interfaces over types. +- Use TypeScript for all code; prefer types over interfaces. - Avoid enums; use objects or maps instead. - Avoid using `any` or `unknown` unless absolutely necessary. Look for type definitions in the codebase instead. - Avoid type assertions with `as` or `!`; prefer using `satisfies`. diff --git a/packages/component-library/src/styles.ts b/packages/component-library/src/styles.ts index 0e5d0eeead..1e9613b583 100644 --- a/packages/component-library/src/styles.ts +++ b/packages/component-library/src/styles.ts @@ -154,4 +154,10 @@ export const styles: Record = { borderRadius: 4, padding: '3px 5px', }, + mobileListItem: { + borderBottom: `1px solid ${theme.tableBorder}`, + backgroundColor: theme.tableBackground, + padding: 16, + cursor: 'pointer', + }, }; diff --git a/packages/desktop-client/src/components/mobile/payees/PayeesList.tsx b/packages/desktop-client/src/components/mobile/payees/PayeesList.tsx index 4564ccf600..4ec4bd2a47 100644 --- a/packages/desktop-client/src/components/mobile/payees/PayeesList.tsx +++ b/packages/desktop-client/src/components/mobile/payees/PayeesList.tsx @@ -1,4 +1,5 @@ -import { Trans } from 'react-i18next'; +import { GridList } from 'react-aria-components'; +import { Trans, useTranslation } from 'react-i18next'; import { AnimatedLoading } from '@actual-app/components/icons/AnimatedLoading'; import { Text } from '@actual-app/components/text'; @@ -24,6 +25,8 @@ export function PayeesList({ isLoading = false, onPayeePress, }: PayeesListProps) { + const { t } = useTranslation(); + if (isLoading && payees.length === 0) { return ( - {payees.map(payee => ( - onPayeePress(payee)} - /> - ))} + + + {payee => ( + onPayeePress(payee)} + /> + )} + {isLoading && ( diff --git a/packages/desktop-client/src/components/mobile/payees/PayeesListItem.tsx b/packages/desktop-client/src/components/mobile/payees/PayeesListItem.tsx index 8113af4dba..2012e22b50 100644 --- a/packages/desktop-client/src/components/mobile/payees/PayeesListItem.tsx +++ b/packages/desktop-client/src/components/mobile/payees/PayeesListItem.tsx @@ -1,9 +1,10 @@ -import React from 'react'; +import React, { memo } from 'react'; +import { GridListItem, type GridListItemProps } from 'react-aria-components'; import { useTranslation } from 'react-i18next'; -import { Button } from '@actual-app/components/button'; import { SvgBookmark } from '@actual-app/components/icons/v1'; import { SpaceBetween } from '@actual-app/components/space-between'; +import { styles } from '@actual-app/components/styles'; import { theme } from '@actual-app/components/theme'; import { type PayeeEntity } from 'loot-core/types/models'; @@ -11,84 +12,82 @@ import { type PayeeEntity } from 'loot-core/types/models'; import { PayeeRuleCountLabel } from '@desktop-client/components/payees/PayeeRuleCountLabel'; type PayeesListItemProps = { - payee: PayeeEntity; + value: PayeeEntity; ruleCount: number; - onPress: () => void; -}; +} & Omit, 'value'>; -export function PayeesListItem({ - payee, +export const PayeesListItem = memo(function PayeeListItem({ + value: payee, ruleCount, - onPress, + ...props }: PayeesListItemProps) { const { t } = useTranslation(); - return ( - + ); -} +}); diff --git a/upcoming-release-notes/5802.md b/upcoming-release-notes/5802.md new file mode 100644 index 0000000000..0016de46f3 --- /dev/null +++ b/upcoming-release-notes/5802.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [MatissJanis] +--- + +Mobile payee list - moved to react-aria GridList to improve performance