A local-first personal finance app
Add virtualizer to mobile transactions (#5921)
Matiss Janis Aboltins6826ca0e4bd5
diff --git a/packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx b/packages/desktop-client/src/components/mobile/transactions/TransactionList.tsxindex 2689f27b26..ff4b3ff0be 100644--- a/packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx+++ b/packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx@@ -11,6 +11,8 @@ import {ListBoxSection,Header,Collection,+ Virtualizer,+ ListLayout,} from 'react-aria-components';import { Trans, useTranslation } from 'react-i18next';@@ -158,64 +160,76 @@ export function TransactionList({aria-label={t('Loading transactions...')}/>)}- <ListBox- aria-label={t('Transaction list')}- selectionMode={selectedTransactions.size > 0 ? 'multiple' : 'single'}- selectedKeys={selectedTransactions}- dependencies={[selectedTransactions]}- renderEmptyState={() =>- !isLoading && (- <View- style={{- alignItems: 'center',- justifyContent: 'center',- backgroundColor: theme.mobilePageBackground,- }}- >- <Text style={{ fontSize: 15 }}>- <Trans>No transactions</Trans>- </Text>- </View>- )- }- items={sections}- >- {section => (- <ListBoxSection>- <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,- }}- >- {monthUtils.format(section.date, 'MMMM dd, yyyy', locale)}- </Header>- <Collection- items={section.transactions.filter(- t => !isPreviewId(t.id) || !t.is_child,- )}- >- {transaction => (- <TransactionListItem- key={transaction.id}- value={transaction}- onPress={trans => onTransactionPress(trans)}- onLongPress={trans => onTransactionPress(trans, true)}- />- )}- </Collection>- </ListBoxSection>- )}- </ListBox>+ <View style={{ flex: 1, overflow: 'auto' }}>+ <Virtualizer+ layout={ListLayout}+ layoutOptions={{+ estimatedRowHeight: ROW_HEIGHT,+ padding: 0,+ }}+ >+ <ListBox+ aria-label={t('Transaction list')}+ selectionMode={+ selectedTransactions.size > 0 ? 'multiple' : 'single'+ }+ selectedKeys={selectedTransactions}+ dependencies={[selectedTransactions]}+ renderEmptyState={() =>+ !isLoading && (+ <View+ style={{+ alignItems: 'center',+ justifyContent: 'center',+ backgroundColor: theme.mobilePageBackground,+ }}+ >+ <Text style={{ fontSize: 15 }}>+ <Trans>No transactions</Trans>+ </Text>+ </View>+ )+ }+ items={sections}+ >+ {section => (+ <ListBoxSection>+ <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,+ }}+ >+ {monthUtils.format(section.date, 'MMMM dd, yyyy', locale)}+ </Header>+ <Collection+ items={section.transactions.filter(+ t => !isPreviewId(t.id) || !t.is_child,+ )}+ >+ {transaction => (+ <TransactionListItem+ key={transaction.id}+ value={transaction}+ onPress={trans => onTransactionPress(trans)}+ onLongPress={trans => onTransactionPress(trans, true)}+ />+ )}+ </Collection>+ </ListBoxSection>+ )}+ </ListBox>+ </Virtualizer>+ </View>{isLoadingMore && (<Loadingdiff --git a/upcoming-release-notes/5921.md b/upcoming-release-notes/5921.mdnew file mode 100644index 0000000000..3026fce6d2--- /dev/null+++ b/upcoming-release-notes/5921.md@@ -0,0 +1,6 @@+---+category: Enhancements+authors: [MatissJanis]+---++Mobile transactions: add virtualizer to the list for improved performance