A local-first personal finance app
[Mobile] Fix preview transactions not loading in multi-account views and uncategorized splits not loading (#5072)
Joel Jeremy Marquez1067e3202807
diff --git a/packages/desktop-client/e2e/transactions.mobile.test.ts b/packages/desktop-client/e2e/transactions.mobile.test.tsindex 3b485cdd7a..376eea5644 100644--- a/packages/desktop-client/e2e/transactions.mobile.test.ts+++ b/packages/desktop-client/e2e/transactions.mobile.test.ts@@ -81,7 +81,7 @@ test.describe('Mobile Transactions', () => {);});- test('creates an uncategorized transaction from `/accounts/uncategorized` page', async () => {+ test('creates an uncategorized transaction from `/categories/uncategorized` page', async () => {// Create uncategorized transactionlet transactionEntryPage = await navigation.goToTransactionEntryPage();await transactionEntryPage.amountField.fill('12.35');@@ -114,7 +114,7 @@ test.describe('Mobile Transactions', () => {await expect(page).toMatchThemeScreenshots();});- test('creates a categorized transaction from `/accounts/uncategorized` page', async () => {+ test('creates a categorized transaction from `/categories/uncategorized` page', async () => {// Create uncategorized transactionlet transactionEntryPage = await navigation.goToTransactionEntryPage();await transactionEntryPage.amountField.fill('12.35');diff --git a/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-accounts-uncategorized-page-1-chromium-linux.png b/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-accounts-uncategorized-page-1-chromium-linux.pngdeleted file mode 100644index 2d45fd4a6f..0000000000Binary files a/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-accounts-uncategorized-page-1-chromium-linux.png and /dev/null differdiff --git a/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-accounts-uncategorized-page-2-chromium-linux.png b/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-accounts-uncategorized-page-2-chromium-linux.pngdeleted file mode 100644index 1651fbb2c3..0000000000Binary files a/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-accounts-uncategorized-page-2-chromium-linux.png and /dev/null differdiff --git a/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-accounts-uncategorized-page-3-chromium-linux.png b/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-accounts-uncategorized-page-3-chromium-linux.pngdeleted file mode 100644index 7ea54998a7..0000000000Binary files a/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-accounts-uncategorized-page-3-chromium-linux.png and /dev/null differdiff --git a/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-categories-uncategorized-page-1-chromium-linux.png b/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-categories-uncategorized-page-1-chromium-linux.pngnew file mode 100644index 0000000000..004a4b1776Binary files /dev/null and b/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-categories-uncategorized-page-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-categories-uncategorized-page-2-chromium-linux.png b/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-categories-uncategorized-page-2-chromium-linux.pngnew file mode 100644index 0000000000..12efc963afBinary files /dev/null and b/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-categories-uncategorized-page-2-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-categories-uncategorized-page-3-chromium-linux.png b/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-categories-uncategorized-page-3-chromium-linux.pngnew file mode 100644index 0000000000..5e3789717fBinary files /dev/null and b/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-categorized-transaction-from-categories-uncategorized-page-3-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-an-uncategorized-transaction-from-categories-uncategorized-page-1-chromium-linux.png b/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-an-uncategorized-transaction-from-categories-uncategorized-page-1-chromium-linux.pngnew file mode 100644index 0000000000..4fc380aa54Binary files /dev/null and b/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-an-uncategorized-transaction-from-categories-uncategorized-page-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-an-uncategorized-transaction-from-categories-uncategorized-page-2-chromium-linux.png b/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-an-uncategorized-transaction-from-categories-uncategorized-page-2-chromium-linux.pngnew file mode 100644index 0000000000..8c595d1458Binary files /dev/null and b/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-an-uncategorized-transaction-from-categories-uncategorized-page-2-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-an-uncategorized-transaction-from-categories-uncategorized-page-3-chromium-linux.png b/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-an-uncategorized-transaction-from-categories-uncategorized-page-3-chromium-linux.pngnew file mode 100644index 0000000000..1963cd4649Binary files /dev/null and b/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-an-uncategorized-transaction-from-categories-uncategorized-page-3-chromium-linux.png differdiff --git a/packages/desktop-client/src/components/FinancesApp.tsx b/packages/desktop-client/src/components/FinancesApp.tsxindex 5e50c10e31..2d47a5c4cf 100644--- a/packages/desktop-client/src/components/FinancesApp.tsx+++ b/packages/desktop-client/src/components/FinancesApp.tsx@@ -14,7 +14,6 @@ import { BankSync } from './banksync';import { BankSyncStatus } from './BankSyncStatus';import { CommandBar } from './CommandBar';import { GlobalKeys } from './GlobalKeys';-import { Category } from './mobile/budget/Category';import { MobileNavTabs } from './mobile/MobileNavTabs';import { TransactionEdit } from './mobile/transactions/TransactionEdit';import { Notifications } from './Notifications';@@ -294,11 +293,7 @@ export function FinancesApp() {<Routepath="/categories/:id"- element={- <WideNotSupported>- <Category />- </WideNotSupported>- }+ element={<NarrowAlternate name="Category" />}/>{multiuserEnabled && (<Routediff --git a/packages/desktop-client/src/components/Titlebar.tsx b/packages/desktop-client/src/components/Titlebar.tsxindex 5751abaae3..cb64f2e084 100644--- a/packages/desktop-client/src/components/Titlebar.tsx+++ b/packages/desktop-client/src/components/Titlebar.tsx@@ -55,7 +55,7 @@ function UncategorizedButton() {<Linkvariant="button"buttonVariant="bare"- to="/accounts/uncategorized"+ to="/categories/uncategorized"style={{color: theme.errorText,}}diff --git a/packages/desktop-client/src/components/accounts/Account.tsx b/packages/desktop-client/src/components/accounts/Account.tsxindex 8e579e524e..d0f27f235e 100644--- a/packages/desktop-client/src/components/accounts/Account.tsx+++ b/packages/desktop-client/src/components/accounts/Account.tsx@@ -55,7 +55,7 @@ import { useDateFormat } from '@desktop-client/hooks/useDateFormat';import { useFailedAccounts } from '@desktop-client/hooks/useFailedAccounts';import { useLocalPref } from '@desktop-client/hooks/useLocalPref';import { usePayees } from '@desktop-client/hooks/usePayees';-import { accountSchedulesQuery } from '@desktop-client/hooks/useSchedules';+import { getSchedulesQuery } from '@desktop-client/hooks/useSchedules';import {SelectedProviderWithItems,type Actions,@@ -1962,7 +1962,7 @@ export function Account() {const savedFiters = useTransactionFilters();const schedulesQuery = useMemo(- () => accountSchedulesQuery(params.id),+ () => getSchedulesQuery(params.id),[params.id],);diff --git a/packages/desktop-client/src/components/mobile/accounts/Account.tsx b/packages/desktop-client/src/components/mobile/accounts/Account.tsxdeleted file mode 100644index dd09a5364d..0000000000--- a/packages/desktop-client/src/components/mobile/accounts/Account.tsx+++ /dev/null@@ -1,45 +0,0 @@-import React from 'react';-import { useTranslation } from 'react-i18next';-import { useParams } from 'react-router';--import { AccountTransactions } from './AccountTransactions';--import { useAccount } from '@desktop-client/hooks/useAccount';-import { useSyncedPref } from '@desktop-client/hooks/useSyncedPref';--export function Account() {- const { t } = useTranslation();- const [_numberFormat] = useSyncedPref('numberFormat');- const numberFormat = _numberFormat || 'comma-dot';- const [hideFraction] = useSyncedPref('hideFraction');-- const { id: accountId } = useParams();-- const account = useAccount(accountId!);-- function accountNameFromId(id: string | undefined) {- switch (id) {- case 'onbudget':- return t('On Budget Accounts');- case 'offbudget':- return t('Off Budget Accounts');- case 'uncategorized':- return t('Uncategorized');- case 'closed':- return t('Closed Accounts');- default:- return t('All Accounts');- }- }-- return (- <AccountTransactions- // This key forces the whole table rerender when the number- // format changes- key={numberFormat + hideFraction}- account={account}- accountId={accountId}- accountName={account ? account.name : accountNameFromId(accountId)}- />- );-}diff --git a/packages/desktop-client/src/components/mobile/accounts/AccountPage.tsx b/packages/desktop-client/src/components/mobile/accounts/AccountPage.tsxnew file mode 100644index 0000000000..d55d248da1--- /dev/null+++ b/packages/desktop-client/src/components/mobile/accounts/AccountPage.tsx@@ -0,0 +1,224 @@+import React, { Fragment, useCallback, useMemo } from 'react';+import { useTranslation } from 'react-i18next';+import { useParams } from 'react-router';++import { Button } from '@actual-app/components/button';+import { type CSSProperties, styles } from '@actual-app/components/styles';+import { Text } from '@actual-app/components/text';+import { theme } from '@actual-app/components/theme';+import { View } from '@actual-app/components/view';++import { send } from 'loot-core/platform/client/fetch';+import { type AccountEntity } from 'loot-core/types/models';++import { AccountTransactions } from './AccountTransactions';+import { AllAccountTransactions } from './AllAccountTransactions';+import { OffBudgetAccountTransactions } from './OffBudgetAccountTransactions';+import { OnBudgetAccountTransactions } from './OnBudgetAccountTransactions';++import { MobileBackButton } from '@desktop-client/components/mobile/MobileBackButton';+import { AddTransactionButton } from '@desktop-client/components/mobile/transactions/AddTransactionButton';+import { MobilePageHeader, Page } from '@desktop-client/components/Page';+import { useAccount } from '@desktop-client/hooks/useAccount';+import { useFailedAccounts } from '@desktop-client/hooks/useFailedAccounts';+import { useSyncedPref } from '@desktop-client/hooks/useSyncedPref';+import {+ openAccountCloseModal,+ pushModal,+} from '@desktop-client/modals/modalsSlice';+import {+ reopenAccount,+ updateAccount,+} from '@desktop-client/queries/queriesSlice';+import { useDispatch, useSelector } from '@desktop-client/redux';++export function AccountPage() {+ const { t } = useTranslation();+ const [_numberFormat] = useSyncedPref('numberFormat');+ const numberFormat = _numberFormat || 'comma-dot';+ const [hideFraction] = useSyncedPref('hideFraction');++ const { id: accountIdParam } = useParams();++ const account = useAccount(accountIdParam || '');++ const nameFromId = useCallback(+ (id: string | undefined) => {+ switch (id) {+ case 'onbudget':+ return t('On Budget Accounts');+ case 'offbudget':+ return t('Off Budget Accounts');+ case 'uncategorized':+ return t('Uncategorized');+ case 'closed':+ return t('Closed Accounts');+ default:+ return t('All Accounts');+ }+ },+ [t],+ );++ return (+ <Page+ header={+ <MobilePageHeader+ title={+ account ? (+ <AccountHeader account={account} />+ ) : (+ <NameOnlyHeader name={nameFromId(accountIdParam)} />+ )+ }+ leftContent={<MobileBackButton />}+ rightContent={<AddTransactionButton accountId={account?.id} />}+ />+ }+ padding={0}+ >+ {/* This key forces the whole table rerender when the number format changes */}+ <Fragment key={numberFormat + hideFraction}>+ {account ? (+ <AccountTransactions account={account} />+ ) : accountIdParam === 'onbudget' ? (+ <OnBudgetAccountTransactions />+ ) : accountIdParam === 'offbudget' ? (+ <OffBudgetAccountTransactions />+ ) : (+ <AllAccountTransactions />+ )}+ </Fragment>+ </Page>+ );+}++function AccountHeader({ account }: { readonly account: AccountEntity }) {+ const failedAccounts = useFailedAccounts();+ const { t } = useTranslation();+ const syncingAccountIds = useSelector(state => state.account.accountsSyncing);+ const pending = useMemo(+ () => syncingAccountIds.includes(account.id),+ [syncingAccountIds, account.id],+ );+ const failed = useMemo(+ () => failedAccounts.has(account.id),+ [failedAccounts, account.id],+ );++ const dispatch = useDispatch();++ const onSave = useCallback(+ (account: AccountEntity) => {+ dispatch(updateAccount({ account }));+ },+ [dispatch],+ );++ const onSaveNotes = useCallback(async (id: string, notes: string) => {+ await send('notes-save', { id, note: notes });+ }, []);++ const onEditNotes = useCallback(+ (id: string) => {+ dispatch(+ pushModal({+ modal: {+ name: 'notes',+ options: {+ id: `account-${id}`,+ name: account.name,+ onSave: onSaveNotes,+ },+ },+ }),+ );+ },+ [account.name, dispatch, onSaveNotes],+ );++ const onCloseAccount = useCallback(() => {+ dispatch(openAccountCloseModal({ accountId: account.id }));+ }, [account.id, dispatch]);++ const onReopenAccount = useCallback(() => {+ dispatch(reopenAccount({ id: account.id }));+ }, [account.id, dispatch]);++ const onClick = useCallback(() => {+ dispatch(+ pushModal({+ modal: {+ name: 'account-menu',+ options: {+ accountId: account.id,+ onSave,+ onEditNotes,+ onCloseAccount,+ onReopenAccount,+ },+ },+ }),+ );+ }, [+ account.id,+ dispatch,+ onCloseAccount,+ onEditNotes,+ onReopenAccount,+ onSave,+ ]);++ return (+ <View+ style={{+ flexDirection: 'row',+ }}+ >+ {account.bank && (+ <View+ style={{+ margin: 'auto',+ marginRight: 5,+ width: 8,+ height: 8,+ borderRadius: 8,+ flexShrink: 0,+ backgroundColor: pending+ ? theme.sidebarItemBackgroundPending+ : failed+ ? theme.sidebarItemBackgroundFailed+ : theme.sidebarItemBackgroundPositive,+ transition: 'transform .3s',+ }}+ />+ )}+ <Button variant="bare" onPress={onClick}>+ <Text+ style={{+ fontSize: 17,+ fontWeight: 500,+ ...styles.underlinedText,+ ...(styles.lineClamp(2) as CSSProperties),+ }}+ >+ {account.closed+ ? t('Closed: {{accountName}}', { accountName: account.name })+ : account.name}+ </Text>+ </Button>+ </View>+ );+}++function NameOnlyHeader({ name }: { readonly name: string }) {+ return (+ <View+ style={{+ flexDirection: 'row',+ }}+ >+ <Text style={{ ...(styles.lineClamp(2) as CSSProperties) }}>{name}</Text>+ </View>+ );+}diff --git a/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsx b/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsxindex 613bf5d563..36d7e5796a 100644--- a/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsx+++ b/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsx@@ -1,18 +1,6 @@-import React, {- type CSSProperties,- useCallback,- useEffect,- useMemo,- useState,-} from 'react';+import React, { useCallback, useEffect, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';-import { Button } from '@actual-app/components/button';-import { styles } from '@actual-app/components/styles';-import { Text } from '@actual-app/components/text';-import { theme } from '@actual-app/components/theme';-import { View } from '@actual-app/components/view';-import { listen, send } from 'loot-core/platform/client/fetch';import { type Query } from 'loot-core/shared/query';import { isPreviewId } from 'loot-core/shared/transactions';@@ -22,235 +10,48 @@ import {} from 'loot-core/types/models';import { syncAndDownload } from '@desktop-client/app/appSlice';-import { MobileBackButton } from '@desktop-client/components/mobile/MobileBackButton';-import { AddTransactionButton } from '@desktop-client/components/mobile/transactions/AddTransactionButton';import { TransactionListWithBalances } from '@desktop-client/components/mobile/transactions/TransactionListWithBalances';-import { MobilePageHeader, Page } from '@desktop-client/components/Page';import { useAccountPreviewTransactions } from '@desktop-client/hooks/useAccountPreviewTransactions';import { SchedulesProvider } from '@desktop-client/hooks/useCachedSchedules';import { useDateFormat } from '@desktop-client/hooks/useDateFormat';-import { useFailedAccounts } from '@desktop-client/hooks/useFailedAccounts';import { useNavigate } from '@desktop-client/hooks/useNavigate';-import { accountSchedulesQuery } from '@desktop-client/hooks/useSchedules';+import { getSchedulesQuery } from '@desktop-client/hooks/useSchedules';import { useTransactions } from '@desktop-client/hooks/useTransactions';import { useTransactionsSearch } from '@desktop-client/hooks/useTransactionsSearch';-import {- collapseModals,- openAccountCloseModal,- pushModal,-} from '@desktop-client/modals/modalsSlice';+import { collapseModals, pushModal } from '@desktop-client/modals/modalsSlice';import * as queries from '@desktop-client/queries';-import {- markAccountRead,- reopenAccount,- updateAccount,-} from '@desktop-client/queries/queriesSlice';-import { useSelector, useDispatch } from '@desktop-client/redux';+import { markAccountRead } from '@desktop-client/queries/queriesSlice';+import { useDispatch } from '@desktop-client/redux';import * as bindings from '@desktop-client/spreadsheet/bindings';export function AccountTransactions({account,- accountId,- accountName,}: {- readonly account?: AccountEntity;- readonly accountId?:- | AccountEntity['id']- | 'onbudget'- | 'offbudget'- | 'closed'- | 'uncategorized';- readonly accountName: string;+ readonly account: AccountEntity;}) {const schedulesQuery = useMemo(- () => accountSchedulesQuery(accountId),- [accountId],- );-- return (- <Page- header={- <MobilePageHeader- title={- account ? (- <AccountHeader account={account} />- ) : (- <NameOnlyHeader accountName={accountName} />- )- }- leftContent={<MobileBackButton />}- rightContent={- <AddTransactionButton accountId={account ? accountId : undefined} />- }- />- }- padding={0}- >- <SchedulesProvider query={schedulesQuery}>- <TransactionListWithPreviews- account={account}- accountName={accountName}- accountId={accountId}- />- </SchedulesProvider>- </Page>- );-}--function AccountHeader({ account }: { readonly account: AccountEntity }) {- const failedAccounts = useFailedAccounts();- const syncingAccountIds = useSelector(state => state.account.accountsSyncing);- const pending = useMemo(- () => syncingAccountIds.includes(account.id),- [syncingAccountIds, account.id],- );- const failed = useMemo(- () => failedAccounts.has(account.id),- [failedAccounts, account.id],- );-- const dispatch = useDispatch();-- const onSave = useCallback(- (account: AccountEntity) => {- dispatch(updateAccount({ account }));- },- [dispatch],- );-- const onSaveNotes = useCallback(async (id: string, notes: string) => {- await send('notes-save', { id, note: notes });- }, []);-- const onEditNotes = useCallback(- (id: string) => {- dispatch(- pushModal({- modal: {- name: 'notes',- options: {- id: `account-${id}`,- name: account.name,- onSave: onSaveNotes,- },- },- }),- );- },- [account.name, dispatch, onSaveNotes],+ () => getSchedulesQuery(account.id),+ [account.id],);- const onCloseAccount = useCallback(() => {- dispatch(openAccountCloseModal({ accountId: account.id }));- }, [account.id, dispatch]);-- const onReopenAccount = useCallback(() => {- dispatch(reopenAccount({ id: account.id }));- }, [account.id, dispatch]);-- const onClick = useCallback(() => {- dispatch(- pushModal({- modal: {- name: 'account-menu',- options: {- accountId: account.id,- onSave,- onEditNotes,- onCloseAccount,- onReopenAccount,- },- },- }),- );- }, [- account.id,- dispatch,- onCloseAccount,- onEditNotes,- onReopenAccount,- onSave,- ]);-return (- <View- style={{- flexDirection: 'row',- }}- >- {account.bank && (- <div- style={{- margin: 'auto',- marginRight: 5,- width: 8,- height: 8,- borderRadius: 8,- flexShrink: 0,- backgroundColor: pending- ? theme.sidebarItemBackgroundPending- : failed- ? theme.sidebarItemBackgroundFailed- : theme.sidebarItemBackgroundPositive,- transition: 'transform .3s',- }}- />- )}- <Button variant="bare" onPress={onClick}>- <Text- style={{- fontSize: 17,- fontWeight: 500,- ...styles.underlinedText,- ...(styles.lineClamp(2) as CSSProperties),- }}- >- {`${account.closed ? 'Closed: ' : ''}${account.name}`}- </Text>- </Button>- </View>- );-}--function NameOnlyHeader({ accountName }: { readonly accountName: string }) {- return (- <View- style={{- flexDirection: 'row',- }}- >- <Text style={{ ...(styles.lineClamp(2) as CSSProperties) }}>- {accountName}- </Text>- </View>+ <SchedulesProvider query={schedulesQuery}>+ <TransactionListWithPreviews account={account} />+ </SchedulesProvider>);}function TransactionListWithPreviews({account,- accountId,- accountName,}: {- readonly account?: AccountEntity;- readonly accountId?:- | AccountEntity['id']- | 'onbudget'- | 'offbudget'- | 'closed'- | 'uncategorized';- readonly accountName: AccountEntity['name'] | string;+ readonly account: AccountEntity;}) {const { t } = useTranslation();- const balanceQueries = useMemo(- () => queriesFromAccountId(accountId, account),- [accountId, account],- );-const baseTransactionsQuery = useCallback(() =>- queries.transactions(accountId).options({ splits: 'all' }).select('*'),- [accountId],+ queries.transactions(account.id).options({ splits: 'all' }).select('*'),+ [account.id],);const [transactionsQuery, setTransactionsQuery] = useState<Query>(@@ -276,16 +77,16 @@ function TransactionListWithPreviews({const navigate = useNavigate();const onRefresh = useCallback(() => {- if (accountId) {- dispatch(syncAndDownload({ accountId }));+ if (account.id) {+ dispatch(syncAndDownload({ accountId: account.id }));}- }, [accountId, dispatch]);+ }, [account.id, dispatch]);useEffect(() => {- if (accountId) {- dispatch(markAccountRead({ id: accountId }));+ if (account.id) {+ dispatch(markAccountRead({ id: account.id }));}- }, [accountId, dispatch]);+ }, [account.id, dispatch]);useEffect(() => {return listen('sync-event', event => {@@ -360,6 +161,15 @@ function TransactionListWithPreviews({[dispatch, navigate],);+ const balanceBindings = useMemo(+ () => ({+ balance: bindings.accountBalance(account.id),+ cleared: bindings.accountBalanceCleared(account.id),+ uncleared: bindings.accountBalanceUncleared(account.id),+ }),+ [account],+ );+const transactionsToDisplay = !isSearching? // Do not render child transactions in the list, unless searchingpreviewTransactions.concat(transactions.filter(t => !t.is_child))@@ -371,48 +181,17 @@ function TransactionListWithPreviews({isSearching ? isTransactionsLoading : isPreviewTransactionsLoading}transactions={transactionsToDisplay}- balance={balanceQueries.balance}- balanceCleared={balanceQueries.cleared}- balanceUncleared={balanceQueries.uncleared}+ balance={balanceBindings.balance}+ balanceCleared={balanceBindings.cleared}+ balanceUncleared={balanceBindings.uncleared}isLoadingMore={isLoadingMore}onLoadMore={loadMoreTransactions}- searchPlaceholder={t('Search {{accountName}}', { accountName })}+ searchPlaceholder={t('Search {{accountName}}', {+ accountName: account.name,+ })}onSearch={onSearch}onOpenTransaction={onOpenTransaction}onRefresh={onRefresh}- account={account}/>);}--function queriesFromAccountId(- id: string | undefined,- entity: AccountEntity | undefined,-) {- switch (id) {- case 'onbudget':- return {- balance: bindings.onBudgetAccountBalance(),- };- case 'offbudget':- return {- balance: bindings.offBudgetAccountBalance(),- };- case 'closed':- return {- balance: bindings.closedAccountBalance(),- };- case 'uncategorized':- return {- balance: bindings.uncategorizedBalance(),- };- default:- return entity- ? {- balance: bindings.accountBalance(entity.id),- cleared: bindings.accountBalanceCleared(entity.id),- uncleared: bindings.accountBalanceUncleared(entity.id),- }- : { balance: bindings.allAccountBalance() };- }-}diff --git a/packages/desktop-client/src/components/mobile/accounts/Accounts.tsx b/packages/desktop-client/src/components/mobile/accounts/AccountsPage.tsxsimilarity index 99%rename from packages/desktop-client/src/components/mobile/accounts/Accounts.tsxrename to packages/desktop-client/src/components/mobile/accounts/AccountsPage.tsxindex 2af0ddf57c..1b3fd1216d 100644--- a/packages/desktop-client/src/components/mobile/accounts/Accounts.tsx+++ b/packages/desktop-client/src/components/mobile/accounts/AccountsPage.tsx@@ -494,7 +494,7 @@ const AccountList = forwardRef<HTMLDivElement, AccountListProps>(AccountList.displayName = 'AccountList';-export function Accounts() {+export function AccountsPage() {const dispatch = useDispatch();const accounts = useAccounts();const [_numberFormat] = useSyncedPref('numberFormat');diff --git a/packages/desktop-client/src/components/mobile/accounts/AllAccountTransactions.tsx b/packages/desktop-client/src/components/mobile/accounts/AllAccountTransactions.tsxnew file mode 100644index 0000000000..f931dd78cc--- /dev/null+++ b/packages/desktop-client/src/components/mobile/accounts/AllAccountTransactions.tsx@@ -0,0 +1,155 @@+import React, { useCallback, useEffect, useMemo, useState } from 'react';+import { useTranslation } from 'react-i18next';++import { listen, send } from 'loot-core/platform/client/fetch';+import { type Query } from 'loot-core/shared/query';+import { isPreviewId } from 'loot-core/shared/transactions';+import { type TransactionEntity } from 'loot-core/types/models';++import { TransactionListWithBalances } from '@desktop-client/components/mobile/transactions/TransactionListWithBalances';+import { SchedulesProvider } from '@desktop-client/hooks/useCachedSchedules';+import { useDateFormat } from '@desktop-client/hooks/useDateFormat';+import { useNavigate } from '@desktop-client/hooks/useNavigate';+import { usePreviewTransactions } from '@desktop-client/hooks/usePreviewTransactions';+import { getSchedulesQuery } from '@desktop-client/hooks/useSchedules';+import { useTransactions } from '@desktop-client/hooks/useTransactions';+import { useTransactionsSearch } from '@desktop-client/hooks/useTransactionsSearch';+import { collapseModals, pushModal } from '@desktop-client/modals/modalsSlice';+import * as queries from '@desktop-client/queries';+import { useDispatch } from '@desktop-client/redux';+import * as bindings from '@desktop-client/spreadsheet/bindings';++export function AllAccountTransactions() {+ const schedulesQuery = useMemo(() => getSchedulesQuery(), []);++ return (+ <SchedulesProvider query={schedulesQuery}>+ <TransactionListWithPreviews />+ </SchedulesProvider>+ );+}++function TransactionListWithPreviews() {+ const { t } = useTranslation();+ const baseTransactionsQuery = useCallback(+ () => queries.transactions().options({ splits: 'all' }).select('*'),+ [],+ );++ const [transactionsQuery, setTransactionsQuery] = useState<Query>(+ baseTransactionsQuery(),+ );+ const {+ transactions,+ isLoading: isTransactionsLoading,+ reload: reloadTransactions,+ isLoadingMore,+ loadMore: loadMoreTransactions,+ } = useTransactions({+ query: transactionsQuery,+ });+ const { previewTransactions, isLoading: isPreviewTransactionsLoading } =+ usePreviewTransactions();++ const dateFormat = useDateFormat() || 'MM/dd/yyyy';+ const dispatch = useDispatch();+ const navigate = useNavigate();++ useEffect(() => {+ return listen('sync-event', event => {+ if (event.type === 'applied') {+ const tables = event.tables;+ if (+ tables.includes('transactions') ||+ tables.includes('category_mapping') ||+ tables.includes('payee_mapping')+ ) {+ reloadTransactions();+ }+ }+ });+ }, [reloadTransactions]);++ const { isSearching, search: onSearch } = useTransactionsSearch({+ updateQuery: setTransactionsQuery,+ resetQuery: () => setTransactionsQuery(baseTransactionsQuery()),+ dateFormat,+ });++ const onOpenTransaction = useCallback(+ (transaction: TransactionEntity) => {+ if (!isPreviewId(transaction.id)) {+ navigate(`/transactions/${transaction.id}`);+ } else {+ dispatch(+ pushModal({+ modal: {+ name: 'scheduled-transaction-menu',+ options: {+ transactionId: transaction.id,+ onPost: async transactionId => {+ const parts = transactionId.split('/');+ await send('schedule/post-transaction', { id: parts[1] });+ dispatch(+ collapseModals({+ rootModalName: 'scheduled-transaction-menu',+ }),+ );+ },+ onSkip: async transactionId => {+ const parts = transactionId.split('/');+ await send('schedule/skip-next-date', { id: parts[1] });+ dispatch(+ collapseModals({+ rootModalName: 'scheduled-transaction-menu',+ }),+ );+ },+ onComplete: async transactionId => {+ const parts = transactionId.split('/');+ await send('schedule/update', {+ schedule: { id: parts[1], completed: true },+ });+ dispatch(+ collapseModals({+ rootModalName: 'scheduled-transaction-menu',+ }),+ );+ },+ },+ },+ }),+ );+ }+ },+ [dispatch, navigate],+ );++ const balanceBindings = useMemo(+ () => ({+ balance: bindings.allAccountBalance(),+ }),+ [],+ );++ const transactionsToDisplay = !isSearching+ ? // Do not render child transactions in the list, unless searching+ previewTransactions.concat(transactions.filter(t => !t.is_child))+ : transactions;++ return (+ <TransactionListWithBalances+ isLoading={+ isSearching ? isTransactionsLoading : isPreviewTransactionsLoading+ }+ transactions={transactionsToDisplay}+ balance={balanceBindings.balance}+ isLoadingMore={isLoadingMore}+ onLoadMore={loadMoreTransactions}+ searchPlaceholder={t('Search All Accounts')}+ onSearch={onSearch}+ onOpenTransaction={onOpenTransaction}+ showMakeTransfer={true}+ />+ );+}diff --git a/packages/desktop-client/src/components/mobile/accounts/OffBudgetAccountTransactions.tsx b/packages/desktop-client/src/components/mobile/accounts/OffBudgetAccountTransactions.tsxnew file mode 100644index 0000000000..9d1c2f3ba0--- /dev/null+++ b/packages/desktop-client/src/components/mobile/accounts/OffBudgetAccountTransactions.tsx@@ -0,0 +1,169 @@+import React, { useCallback, useEffect, useMemo, useState } from 'react';+import { useTranslation } from 'react-i18next';++import { listen, send } from 'loot-core/platform/client/fetch';+import { type Query } from 'loot-core/shared/query';+import { isPreviewId } from 'loot-core/shared/transactions';+import {+ type ScheduleEntity,+ type TransactionEntity,+} from 'loot-core/types/models';++import { TransactionListWithBalances } from '@desktop-client/components/mobile/transactions/TransactionListWithBalances';+import { SchedulesProvider } from '@desktop-client/hooks/useCachedSchedules';+import { useDateFormat } from '@desktop-client/hooks/useDateFormat';+import { useNavigate } from '@desktop-client/hooks/useNavigate';+import { useOffBudgetAccounts } from '@desktop-client/hooks/useOffBudgetAccounts';+import { usePreviewTransactions } from '@desktop-client/hooks/usePreviewTransactions';+import { getSchedulesQuery } from '@desktop-client/hooks/useSchedules';+import { useTransactions } from '@desktop-client/hooks/useTransactions';+import { useTransactionsSearch } from '@desktop-client/hooks/useTransactionsSearch';+import { collapseModals, pushModal } from '@desktop-client/modals/modalsSlice';+import * as queries from '@desktop-client/queries';+import { useDispatch } from '@desktop-client/redux';+import * as bindings from '@desktop-client/spreadsheet/bindings';++export function OffBudgetAccountTransactions() {+ const schedulesQuery = useMemo(() => getSchedulesQuery('offbudget'), []);++ return (+ <SchedulesProvider query={schedulesQuery}>+ <TransactionListWithPreviews />+ </SchedulesProvider>+ );+}++function TransactionListWithPreviews() {+ const { t } = useTranslation();+ const baseTransactionsQuery = useCallback(+ () =>+ queries.transactions('offbudget').options({ splits: 'all' }).select('*'),+ [],+ );++ const [transactionsQuery, setTransactionsQuery] = useState<Query>(+ baseTransactionsQuery(),+ );+ const {+ transactions,+ isLoading: isTransactionsLoading,+ reload: reloadTransactions,+ isLoadingMore,+ loadMore: loadMoreTransactions,+ } = useTransactions({+ query: transactionsQuery,+ });+ const offBudgetAccounts = useOffBudgetAccounts();+ const offBudgetAccountsFilter = useCallback(+ (schedule: ScheduleEntity) =>+ offBudgetAccounts.some(a => a.id === schedule._account),+ [offBudgetAccounts],+ );++ const { previewTransactions, isLoading: isPreviewTransactionsLoading } =+ usePreviewTransactions({+ filter: offBudgetAccountsFilter,+ });++ const dateFormat = useDateFormat() || 'MM/dd/yyyy';+ const dispatch = useDispatch();+ const navigate = useNavigate();++ useEffect(() => {+ return listen('sync-event', event => {+ if (event.type === 'applied') {+ const tables = event.tables;+ if (+ tables.includes('transactions') ||+ tables.includes('category_mapping') ||+ tables.includes('payee_mapping')+ ) {+ reloadTransactions();+ }+ }+ });+ }, [reloadTransactions]);++ const { isSearching, search: onSearch } = useTransactionsSearch({+ updateQuery: setTransactionsQuery,+ resetQuery: () => setTransactionsQuery(baseTransactionsQuery()),+ dateFormat,+ });++ const onOpenTransaction = useCallback(+ (transaction: TransactionEntity) => {+ if (!isPreviewId(transaction.id)) {+ navigate(`/transactions/${transaction.id}`);+ } else {+ dispatch(+ pushModal({+ modal: {+ name: 'scheduled-transaction-menu',+ options: {+ transactionId: transaction.id,+ onPost: async transactionId => {+ const parts = transactionId.split('/');+ await send('schedule/post-transaction', { id: parts[1] });+ dispatch(+ collapseModals({+ rootModalName: 'scheduled-transaction-menu',+ }),+ );+ },+ onSkip: async transactionId => {+ const parts = transactionId.split('/');+ await send('schedule/skip-next-date', { id: parts[1] });+ dispatch(+ collapseModals({+ rootModalName: 'scheduled-transaction-menu',+ }),+ );+ },+ onComplete: async transactionId => {+ const parts = transactionId.split('/');+ await send('schedule/update', {+ schedule: { id: parts[1], completed: true },+ });+ dispatch(+ collapseModals({+ rootModalName: 'scheduled-transaction-menu',+ }),+ );+ },+ },+ },+ }),+ );+ }+ },+ [dispatch, navigate],+ );++ const balanceBindings = useMemo(+ () => ({+ balance: bindings.offBudgetAccountBalance(),+ }),+ [],+ );++ const transactionsToDisplay = !isSearching+ ? // Do not render child transactions in the list, unless searching+ previewTransactions.concat(transactions.filter(t => !t.is_child))+ : transactions;++ return (+ <TransactionListWithBalances+ isLoading={+ isSearching ? isTransactionsLoading : isPreviewTransactionsLoading+ }+ transactions={transactionsToDisplay}+ balance={balanceBindings.balance}+ isLoadingMore={isLoadingMore}+ onLoadMore={loadMoreTransactions}+ searchPlaceholder={t('Search Off Budget Accounts')}+ onSearch={onSearch}+ onOpenTransaction={onOpenTransaction}+ showMakeTransfer={true}+ />+ );+}diff --git a/packages/desktop-client/src/components/mobile/accounts/OnBudgetAccountTransactions.tsx b/packages/desktop-client/src/components/mobile/accounts/OnBudgetAccountTransactions.tsxnew file mode 100644index 0000000000..66007e2e61--- /dev/null+++ b/packages/desktop-client/src/components/mobile/accounts/OnBudgetAccountTransactions.tsx@@ -0,0 +1,169 @@+import React, { useCallback, useEffect, useMemo, useState } from 'react';+import { useTranslation } from 'react-i18next';++import { listen, send } from 'loot-core/platform/client/fetch';+import { type Query } from 'loot-core/shared/query';+import { isPreviewId } from 'loot-core/shared/transactions';+import {+ type ScheduleEntity,+ type TransactionEntity,+} from 'loot-core/types/models';++import { TransactionListWithBalances } from '@desktop-client/components/mobile/transactions/TransactionListWithBalances';+import { SchedulesProvider } from '@desktop-client/hooks/useCachedSchedules';+import { useDateFormat } from '@desktop-client/hooks/useDateFormat';+import { useNavigate } from '@desktop-client/hooks/useNavigate';+import { useOnBudgetAccounts } from '@desktop-client/hooks/useOnBudgetAccounts';+import { usePreviewTransactions } from '@desktop-client/hooks/usePreviewTransactions';+import { getSchedulesQuery } from '@desktop-client/hooks/useSchedules';+import { useTransactions } from '@desktop-client/hooks/useTransactions';+import { useTransactionsSearch } from '@desktop-client/hooks/useTransactionsSearch';+import { collapseModals, pushModal } from '@desktop-client/modals/modalsSlice';+import * as queries from '@desktop-client/queries';+import { useDispatch } from '@desktop-client/redux';+import * as bindings from '@desktop-client/spreadsheet/bindings';++export function OnBudgetAccountTransactions() {+ const schedulesQuery = useMemo(() => getSchedulesQuery('onbudget'), []);++ return (+ <SchedulesProvider query={schedulesQuery}>+ <TransactionListWithPreviews />+ </SchedulesProvider>+ );+}++function TransactionListWithPreviews() {+ const { t } = useTranslation();+ const baseTransactionsQuery = useCallback(+ () =>+ queries.transactions('onbudget').options({ splits: 'all' }).select('*'),+ [],+ );++ const [transactionsQuery, setTransactionsQuery] = useState<Query>(+ baseTransactionsQuery(),+ );+ const {+ transactions,+ isLoading: isTransactionsLoading,+ reload: reloadTransactions,+ isLoadingMore,+ loadMore: loadMoreTransactions,+ } = useTransactions({+ query: transactionsQuery,+ });+ const onBudgetAccounts = useOnBudgetAccounts();+ const onBudgetAccountsFilter = useCallback(+ (schedule: ScheduleEntity) =>+ onBudgetAccounts.some(a => a.id === schedule._account),+ [onBudgetAccounts],+ );++ const { previewTransactions, isLoading: isPreviewTransactionsLoading } =+ usePreviewTransactions({+ filter: onBudgetAccountsFilter,+ });++ const dateFormat = useDateFormat() || 'MM/dd/yyyy';+ const dispatch = useDispatch();+ const navigate = useNavigate();++ useEffect(() => {+ return listen('sync-event', event => {+ if (event.type === 'applied') {+ const tables = event.tables;+ if (+ tables.includes('transactions') ||+ tables.includes('category_mapping') ||+ tables.includes('payee_mapping')+ ) {+ reloadTransactions();+ }+ }+ });+ }, [reloadTransactions]);++ const { isSearching, search: onSearch } = useTransactionsSearch({+ updateQuery: setTransactionsQuery,+ resetQuery: () => setTransactionsQuery(baseTransactionsQuery()),+ dateFormat,+ });++ const onOpenTransaction = useCallback(+ (transaction: TransactionEntity) => {+ if (!isPreviewId(transaction.id)) {+ navigate(`/transactions/${transaction.id}`);+ } else {+ dispatch(+ pushModal({+ modal: {+ name: 'scheduled-transaction-menu',+ options: {+ transactionId: transaction.id,+ onPost: async transactionId => {+ const parts = transactionId.split('/');+ await send('schedule/post-transaction', { id: parts[1] });+ dispatch(+ collapseModals({+ rootModalName: 'scheduled-transaction-menu',+ }),+ );+ },+ onSkip: async transactionId => {+ const parts = transactionId.split('/');+ await send('schedule/skip-next-date', { id: parts[1] });+ dispatch(+ collapseModals({+ rootModalName: 'scheduled-transaction-menu',+ }),+ );+ },+ onComplete: async transactionId => {+ const parts = transactionId.split('/');+ await send('schedule/update', {+ schedule: { id: parts[1], completed: true },+ });+ dispatch(+ collapseModals({+ rootModalName: 'scheduled-transaction-menu',+ }),+ );+ },+ },+ },+ }),+ );+ }+ },+ [dispatch, navigate],+ );++ const balanceBindings = useMemo(+ () => ({+ balance: bindings.onBudgetAccountBalance(),+ }),+ [],+ );++ const transactionsToDisplay = !isSearching+ ? // Do not render child transactions in the list, unless searching+ previewTransactions.concat(transactions.filter(t => !t.is_child))+ : transactions;++ return (+ <TransactionListWithBalances+ isLoading={+ isSearching ? isTransactionsLoading : isPreviewTransactionsLoading+ }+ transactions={transactionsToDisplay}+ balance={balanceBindings.balance}+ isLoadingMore={isLoadingMore}+ onLoadMore={loadMoreTransactions}+ searchPlaceholder={t('Search On Budget Accounts')}+ onSearch={onSearch}+ onOpenTransaction={onOpenTransaction}+ showMakeTransfer={true}+ />+ );+}diff --git a/packages/desktop-client/src/components/mobile/budget/index.tsx b/packages/desktop-client/src/components/mobile/budget/BudgetPage.tsxsimilarity index 51%rename from packages/desktop-client/src/components/mobile/budget/index.tsxrename to packages/desktop-client/src/components/mobile/budget/BudgetPage.tsxindex 28e914750b..819be64cab 100644--- a/packages/desktop-client/src/components/mobile/budget/index.tsx+++ b/packages/desktop-client/src/components/mobile/budget/BudgetPage.tsx@@ -1,24 +1,46 @@// @ts-strict-ignore-import React, { useCallback, useEffect, useState } from 'react';+import React, { useCallback, useEffect, useMemo, useState } from 'react';+import { GridList, GridListItem } from 'react-aria-components';+import { Trans, useTranslation } from 'react-i18next';+import { Button } from '@actual-app/components/button';+import { Card } from '@actual-app/components/card';import { AnimatedLoading } from '@actual-app/components/icons/AnimatedLoading';+import { SvgLogo } from '@actual-app/components/icons/logo';+import {+ SvgArrowThinLeft,+ SvgArrowThinRight,+ SvgCheveronRight,+} from '@actual-app/components/icons/v1';+import {+ SvgArrowButtonDown1,+ SvgCalendar,+} from '@actual-app/components/icons/v2';+import { styles } from '@actual-app/components/styles';+import { Text } from '@actual-app/components/text';import { theme } from '@actual-app/components/theme';import { View } from '@actual-app/components/view';import { send } from 'loot-core/platform/client/fetch';import * as monthUtils from 'loot-core/shared/months';+import { groupById } from 'loot-core/shared/util';-import { BudgetTable } from './BudgetTable';+import { BudgetTable, PILL_STYLE } from './BudgetTable';import { sync } from '@desktop-client/app/appSlice';import { prewarmMonth } from '@desktop-client/components/budget/util';+import { MobilePageHeader, Page } from '@desktop-client/components/Page';import { SyncRefresh } from '@desktop-client/components/SyncRefresh';import { useCategories } from '@desktop-client/hooks/useCategories';import { useLocale } from '@desktop-client/hooks/useLocale';import { useLocalPref } from '@desktop-client/hooks/useLocalPref';+import { useNavigate } from '@desktop-client/hooks/useNavigate';+import { useOverspentCategories } from '@desktop-client/hooks/useOverspentCategories';import { SheetNameProvider } from '@desktop-client/hooks/useSheetName';+import { useSheetValue } from '@desktop-client/hooks/useSheetValue';import { useSpreadsheet } from '@desktop-client/hooks/useSpreadsheet';import { useSyncedPref } from '@desktop-client/hooks/useSyncedPref';+import { useUndo } from '@desktop-client/hooks/useUndo';import { collapseModals, pushModal } from '@desktop-client/modals/modalsSlice';import {applyBudgetAction,@@ -30,12 +52,17 @@ import {updateGroup,} from '@desktop-client/queries/queriesSlice';import { useDispatch } from '@desktop-client/redux';+import {+ envelopeBudget,+ uncategorizedCount,+} from '@desktop-client/spreadsheet/bindings';function isBudgetType(input?: string): input is 'envelope' | 'tracking' {return ['envelope', 'tracking'].includes(input);}-export function Budget() {+export function BudgetPage() {+ const { t } = useTranslation();const locale = useLocale();const { list: categories, grouped: categoryGroups } = useCategories();const [budgetTypePref] = useSyncedPref('budgetType');@@ -45,7 +72,7 @@ export function Budget() {const currMonth = monthUtils.currentMonth();const [startMonth = currMonth, setStartMonthPref] =useLocalPref('budget.startMonth');- const [bounds, setBounds] = useState({+ const [monthBounds, setMonthBounds] = useState({start: startMonth,end: startMonth,});@@ -59,7 +86,7 @@ export function Budget() {useEffect(() => {async function init() {const { start, end } = await send('get-budget-bounds');- setBounds({ start, end });+ setMonthBounds({ start, end });await prewarmMonth(budgetType, spreadsheet, startMonth);@@ -525,33 +552,443 @@ export function Budget() {}return (- <SheetNameProvider name={monthUtils.sheetForMonth(startMonth)}>- <SyncRefresh- onSync={async () => {- dispatch(sync());+ <Page+ padding={0}+ header={+ <MobilePageHeader+ title={+ <MonthSelector+ month={startMonth}+ monthBounds={monthBounds}+ onOpenMonthMenu={onOpenBudgetMonthMenu}+ onPrevMonth={onPrevMonth}+ onNextMonth={onNextMonth}+ />+ }+ leftContent={+ <Button+ variant="bare"+ style={{ margin: 10 }}+ onPress={onOpenBudgetPageMenu}+ aria-label={t('Budget page menu')}+ >+ <SvgLogo+ style={{ color: theme.mobileHeaderText }}+ width="20"+ height="20"+ />+ <SvgCheveronRight+ style={{ flexShrink: 0, color: theme.mobileHeaderTextSubdued }}+ width="14"+ height="14"+ />+ </Button>+ }+ rightContent={+ !monthUtils.isCurrentMonth(startMonth) && (+ <Button+ variant="bare"+ onPress={onCurrentMonth}+ aria-label={t('Today')}+ style={{ margin: 10 }}+ >+ <SvgCalendar width={20} height={20} />+ </Button>+ )+ }+ />+ }+ >+ <SheetNameProvider name={monthUtils.sheetForMonth(startMonth)}>+ <SyncRefresh+ onSync={async () => {+ dispatch(sync());+ }}+ >+ {({ onRefresh }) => (+ <>+ <Banners month={startMonth} onBudgetAction={onBudgetAction} />+ <BudgetTable+ // This key forces the whole table rerender when the number+ // format changes+ key={`${numberFormat}${hideFraction}`}+ categoryGroups={categoryGroups}+ month={startMonth}+ onShowBudgetSummary={onShowBudgetSummary}+ onBudgetAction={onBudgetAction}+ onRefresh={onRefresh}+ onEditCategoryGroup={onOpenCategoryGroupMenuModal}+ onEditCategory={onOpenCategoryMenuModal}+ />+ </>+ )}+ </SyncRefresh>+ </SheetNameProvider>+ </Page>+ );+}++function Banners({ month, onBudgetAction }) {+ const { t } = useTranslation();+ const [budgetType = 'envelope'] = useSyncedPref('budgetType');++ return (+ <GridList+ aria-label={t('Banners')}+ style={{ backgroundColor: theme.mobilePageBackground }}+ >+ <UncategorizedTransactionsBanner />+ <OverspendingBanner+ month={month}+ onBudgetAction={onBudgetAction}+ budgetType={budgetType}+ />+ {budgetType === 'envelope' && (+ <OverbudgetedBanner month={month} onBudgetAction={onBudgetAction} />+ )}+ </GridList>+ );+}++function Banner({ type = 'info', children }) {+ return (+ <Card+ style={{+ height: 50,+ marginTop: 10,+ marginBottom: 10,+ padding: 10,+ justifyContent: 'center',+ backgroundColor:+ type === 'critical'+ ? theme.errorBackground+ : type === 'warning'+ ? theme.warningBackground+ : theme.noticeBackground,+ }}+ >+ {children}+ </Card>+ );+}++function UncategorizedTransactionsBanner(props) {+ const count = useSheetValue(uncategorizedCount());+ const navigate = useNavigate();++ if (count === null || count <= 0) {+ return null;+ }++ return (+ <GridListItem textValue="Uncategorized transactions banner" {...props}>+ <Banner type="warning">+ <View+ style={{+ flex: 1,+ flexDirection: 'row',+ alignItems: 'center',+ justifyContent: 'space-between',+ }}+ >+ <Trans count={count}>+ You have {{ count }} uncategorized transactions+ </Trans>+ <Button+ onPress={() => navigate('/categories/uncategorized')}+ style={PILL_STYLE}+ >+ <Text>+ <Trans>Categorize</Trans>+ </Text>+ </Button>+ </View>+ </Banner>+ </GridListItem>+ );+}++function OverbudgetedBanner({ month, onBudgetAction, ...props }) {+ const { t } = useTranslation();+ const toBudgetAmount = useSheetValue<+ 'envelope-budget',+ typeof envelopeBudget.toBudget+ >(envelopeBudget.toBudget);+ const dispatch = useDispatch();+ const { showUndoNotification } = useUndo();+ const { list: categories } = useCategories();+ const categoriesById = useMemo(() => groupById(categories), [categories]);++ const openCoverOverbudgetedModal = useCallback(() => {+ dispatch(+ pushModal({+ modal: {+ name: 'cover',+ options: {+ title: t('Cover overbudgeted'),+ month,+ showToBeBudgeted: false,+ onSubmit: categoryId => {+ onBudgetAction(month, 'cover-overbudgeted', {+ category: categoryId,+ });+ showUndoNotification({+ message: t('Covered overbudgeted from {{categoryName}}', {+ categoryName: categoriesById[categoryId].name,+ }),+ });+ },+ },+ },+ }),+ );+ }, [+ categoriesById,+ dispatch,+ month,+ onBudgetAction,+ showUndoNotification,+ t,+ ]);++ if (!toBudgetAmount || toBudgetAmount >= 0) {+ return null;+ }++ return (+ <GridListItem textValue="Overbudgeted banner" {...props}>+ <Banner type="critical">+ <View+ style={{+ flexDirection: 'row',+ alignItems: 'center',+ justifyContent: 'space-between',+ }}+ >+ <View+ style={{+ flexDirection: 'row',+ alignItems: 'center',+ gap: 10,+ }}+ >+ <View+ style={{+ flexDirection: 'row',+ alignItems: 'center',+ gap: 10,+ }}+ >+ <SvgArrowButtonDown1 style={{ width: 15, height: 15 }} />+ <Text>+ <Trans>You have budgeted more than your available funds</Trans>+ </Text>+ </View>+ </View>+ <Button onPress={openCoverOverbudgetedModal} style={PILL_STYLE}>+ <Trans>Cover</Trans>+ </Button>+ </View>+ </Banner>+ </GridListItem>+ );+}++function OverspendingBanner({ month, onBudgetAction, budgetType, ...props }) {+ const { t } = useTranslation();++ const { list: categories, grouped: categoryGroups } = useCategories();+ const categoriesById = useMemo(() => groupById(categories), [categories]);+ const groupsById = useMemo(() => groupById(categoryGroups), [categoryGroups]);++ const dispatch = useDispatch();++ const overspentCategories = useOverspentCategories({ month }).filter(c => {+ if (budgetType === 'tracking') {+ return !c.hidden && !groupsById[c.group].hidden;+ }+ return true;+ });++ const categoryGroupsToShow = useMemo(+ () =>+ categoryGroups+ .filter(g => overspentCategories.some(c => c.group === g.id))+ .map(g => ({+ ...g,+ categories: overspentCategories.filter(c => c.group === g.id),+ })),+ [categoryGroups, overspentCategories],+ );++ const { showUndoNotification } = useUndo();++ const onOpenCoverCategoryModal = useCallback(+ categoryId => {+ const category = categoriesById[categoryId];+ dispatch(+ pushModal({+ modal: {+ name: 'cover',+ options: {+ title: category.name,+ month,+ categoryId: category.id,+ onSubmit: fromCategoryId => {+ onBudgetAction(month, 'cover-overspending', {+ to: category.id,+ from: fromCategoryId,+ });+ showUndoNotification({+ message: t(+ `Covered {{toCategoryName}} overspending from {{fromCategoryName}}.`,+ {+ toCategoryName: category.name,+ fromCategoryName:+ fromCategoryId === 'to-budget'+ ? t('To Budget')+ : categoriesById[fromCategoryId].name,+ },+ ),+ });+ },+ },+ },+ }),+ );+ },+ [categoriesById, dispatch, month, onBudgetAction, showUndoNotification, t],+ );++ const onOpenCategorySelectionModal = useCallback(() => {+ dispatch(+ pushModal({+ modal: {+ name: 'category-autocomplete',+ options: {+ title:+ budgetType === 'envelope'+ ? t('Cover overspending')+ : t('Overspent categories'),+ month,+ categoryGroups: categoryGroupsToShow,+ showHiddenCategories: true,+ onSelect:+ budgetType === 'envelope' ? onOpenCoverCategoryModal : null,+ clearOnSelect: true,+ closeOnSelect: false,+ },+ },+ }),+ );+ }, [+ categoryGroupsToShow,+ dispatch,+ month,+ onOpenCoverCategoryModal,+ t,+ budgetType,+ ]);++ const numberOfOverspentCategories = overspentCategories.length;+ if (numberOfOverspentCategories === 0) {+ return null;+ }++ return (+ <GridListItem textValue="Overspent banner" {...props}>+ <Banner type="critical">+ <View+ style={{+ flexDirection: 'row',+ alignItems: 'center',+ justifyContent: 'space-between',+ }}+ >+ <View+ style={{+ flexDirection: 'row',+ alignItems: 'center',+ gap: 10,+ }}+ >+ <Text>+ <Trans count={numberOfOverspentCategories}>+ You have {{ count: numberOfOverspentCategories }} overspent+ categories+ </Trans>+ </Text>+ </View>+ <Button onPress={onOpenCategorySelectionModal} style={PILL_STYLE}>+ {budgetType === 'envelope' && <Trans>Cover</Trans>}+ {budgetType === 'tracking' && <Trans>View</Trans>}+ </Button>+ </View>+ </Banner>+ </GridListItem>+ );+}++function MonthSelector({+ month,+ monthBounds,+ onOpenMonthMenu,+ onPrevMonth,+ onNextMonth,+}) {+ const locale = useLocale();+ const { t } = useTranslation();+ const prevEnabled = month > monthBounds.start;+ const nextEnabled = month < monthUtils.subMonths(monthBounds.end, 1);++ const arrowButtonStyle = {+ padding: 10,+ margin: 2,+ };++ return (+ <View+ style={{+ flex: 1,+ justifyContent: 'center',+ alignItems: 'center',+ flexDirection: 'row',+ }}+ >+ <Button+ aria-label={t('Previous month')}+ variant="bare"+ isDisabled={!prevEnabled}+ onPress={onPrevMonth}+ style={{ ...arrowButtonStyle, opacity: prevEnabled ? 1 : 0.6 }}+ >+ <SvgArrowThinLeft width="15" height="15" />+ </Button>+ <Button+ variant="bare"+ style={{+ textAlign: 'center',+ fontSize: 16,+ fontWeight: 500,+ }}+ onPress={() => {+ onOpenMonthMenu?.(month);}}+ data-month={month}+ >+ <Text style={styles.underlinedText}>+ {monthUtils.format(month, 'MMMM ‘yy', locale)}+ </Text>+ </Button>+ <Button+ aria-label={t('Next month')}+ variant="bare"+ isDisabled={!nextEnabled}+ onPress={onNextMonth}+ style={{ ...arrowButtonStyle, opacity: nextEnabled ? 1 : 0.6 }}>- {({ onRefresh }) => (- <BudgetTable- // This key forces the whole table rerender when the number- // format changes- key={`${numberFormat}${hideFraction}`}- categoryGroups={categoryGroups}- month={startMonth}- monthBounds={bounds}- onShowBudgetSummary={onShowBudgetSummary}- onPrevMonth={onPrevMonth}- onNextMonth={onNextMonth}- onCurrentMonth={onCurrentMonth}- onBudgetAction={onBudgetAction}- onRefresh={onRefresh}- onEditCategoryGroup={onOpenCategoryGroupMenuModal}- onEditCategory={onOpenCategoryMenuModal}- onOpenBudgetPageMenu={onOpenBudgetPageMenu}- onOpenBudgetMonthMenu={onOpenBudgetMonthMenu}- />- )}- </SyncRefresh>- </SheetNameProvider>+ <SvgArrowThinRight width="15" height="15" />+ </Button>+ </View>);}diff --git a/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx b/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsxindex 242c122e91..9b2ec864d2 100644--- a/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx+++ b/packages/desktop-client/src/components/mobile/budget/BudgetTable.jsx@@ -1,21 +1,10 @@import React, { useCallback, useMemo } from 'react';-import { GridList, GridListItem } from 'react-aria-components';-import { Trans, useTranslation } from 'react-i18next';+import { useTranslation } from 'react-i18next';import { Button } from '@actual-app/components/button';-import { Card } from '@actual-app/components/card';import { useResponsive } from '@actual-app/components/hooks/useResponsive';-import { SvgLogo } from '@actual-app/components/icons/logo';-import {- SvgArrowThinLeft,- SvgArrowThinRight,- SvgCheveronRight,-} from '@actual-app/components/icons/v1';-import {- SvgArrowButtonDown1,- SvgCalendar,- SvgViewShow,-} from '@actual-app/components/icons/v2';+import { SvgCheveronRight } from '@actual-app/components/icons/v1';+import { SvgViewShow } from '@actual-app/components/icons/v2';import { Label } from '@actual-app/components/label';import { styles } from '@actual-app/components/styles';import { Text } from '@actual-app/components/text';@@ -25,32 +14,22 @@ import { AutoTextSize } from 'auto-text-size';import * as monthUtils from 'loot-core/shared/months';import { q } from 'loot-core/shared/query';-import { groupById } from 'loot-core/shared/util';import { ExpenseGroupList } from './ExpenseGroupList';import { IncomeGroup } from './IncomeGroup';import { MOBILE_NAV_HEIGHT } from '@desktop-client/components/mobile/MobileNavTabs';import { PullToRefresh } from '@desktop-client/components/mobile/PullToRefresh';-import { MobilePageHeader, Page } from '@desktop-client/components/Page';import { PrivacyFilter } from '@desktop-client/components/PrivacyFilter';import { CellValue } from '@desktop-client/components/spreadsheet/CellValue';import { SchedulesProvider } from '@desktop-client/hooks/useCachedSchedules';-import { useCategories } from '@desktop-client/hooks/useCategories';import { useFormat } from '@desktop-client/hooks/useFormat';-import { useLocale } from '@desktop-client/hooks/useLocale';import { useLocalPref } from '@desktop-client/hooks/useLocalPref';-import { useNavigate } from '@desktop-client/hooks/useNavigate';-import { useOverspentCategories } from '@desktop-client/hooks/useOverspentCategories';import { useSheetValue } from '@desktop-client/hooks/useSheetValue';import { useSyncedPref } from '@desktop-client/hooks/useSyncedPref';-import { useUndo } from '@desktop-client/hooks/useUndo';-import { pushModal } from '@desktop-client/modals/modalsSlice';-import { useDispatch } from '@desktop-client/redux';import {envelopeBudget,trackingBudget,- uncategorizedCount,} from '@desktop-client/spreadsheet/bindings';export const ROW_HEIGHT = 50;@@ -313,19 +292,12 @@ function BudgetGroups({export function BudgetTable({categoryGroups,month,- monthBounds,- onPrevMonth,- onNextMonth,- onCurrentMonth,onShowBudgetSummary,onBudgetAction,onRefresh,onEditCategoryGroup,onEditCategory,- onOpenBudgetPageMenu,- onOpenBudgetMonthMenu,}) {- const { t } = useTranslation();const { width } = useResponsive();const show3Columns = width >= 300;@@ -348,54 +320,7 @@ export function BudgetTable({const schedulesQuery = useMemo(() => q('schedules').select('*'), []);return (- <Page- padding={0}- header={- <MobilePageHeader- title={- <MonthSelector- month={month}- monthBounds={monthBounds}- onOpenMonthMenu={onOpenBudgetMonthMenu}- onPrevMonth={onPrevMonth}- onNextMonth={onNextMonth}- />- }- leftContent={- <Button- variant="bare"- style={{ margin: 10 }}- onPress={onOpenBudgetPageMenu}- aria-label={t('Budget page menu')}- >- <SvgLogo- style={{ color: theme.mobileHeaderText }}- width="20"- height="20"- />- <SvgCheveronRight- style={{ flexShrink: 0, color: theme.mobileHeaderTextSubdued }}- width="14"- height="14"- />- </Button>- }- rightContent={- <Button- variant="bare"- onPress={onCurrentMonth}- aria-label={t('Today')}- style={{ margin: 10 }}- >- {!monthUtils.isCurrentMonth(month) && (- <SvgCalendar width={20} height={20} />- )}- </Button>- }- />- }- >- <Banners month={month} onBudgetAction={onBudgetAction} />+ <><BudgetTableHeadermonth={month}show3Columns={show3Columns}@@ -426,305 +351,7 @@ export function BudgetTable({</SchedulesProvider></View></PullToRefresh>- </Page>- );-}--function Banner({ type = 'info', children }) {- return (- <Card- style={{- height: 50,- marginTop: 10,- marginBottom: 10,- padding: 10,- justifyContent: 'center',- backgroundColor:- type === 'critical'- ? theme.errorBackground- : type === 'warning'- ? theme.warningBackground- : theme.noticeBackground,- }}- >- {children}- </Card>- );-}--function UncategorizedTransactionsBanner(props) {- const count = useSheetValue(uncategorizedCount());- const navigate = useNavigate();-- if (count === null || count <= 0) {- return null;- }-- return (- <GridListItem textValue="Uncategorized transactions banner" {...props}>- <Banner type="warning">- <View- style={{- flex: 1,- flexDirection: 'row',- alignItems: 'center',- justifyContent: 'space-between',- }}- >- <Trans count={count}>- You have {{ count }} uncategorized transactions- </Trans>- <Button- onPress={() => navigate('/accounts/uncategorized')}- style={PILL_STYLE}- >- <Text>- <Trans>Categorize</Trans>- </Text>- </Button>- </View>- </Banner>- </GridListItem>- );-}--function OverbudgetedBanner({ month, onBudgetAction, ...props }) {- const { t } = useTranslation();- const toBudgetAmount = useSheetValue(envelopeBudget.toBudget);- const dispatch = useDispatch();- const { showUndoNotification } = useUndo();- const { list: categories } = useCategories();- const categoriesById = groupById(categories);-- const openCoverOverbudgetedModal = useCallback(() => {- dispatch(- pushModal({- modal: {- name: 'cover',- options: {- title: t('Cover overbudgeted'),- month,- showToBeBudgeted: false,- onSubmit: categoryId => {- onBudgetAction(month, 'cover-overbudgeted', {- category: categoryId,- });- showUndoNotification({- message: t('Covered overbudgeted from {{categoryName}}', {- categoryName: categoriesById[categoryId].name,- }),- });- },- },- },- }),- );- }, [- categoriesById,- dispatch,- month,- onBudgetAction,- showUndoNotification,- t,- ]);-- if (!toBudgetAmount || toBudgetAmount >= 0) {- return null;- }-- return (- <GridListItem textValue="Overbudgeted banner" {...props}>- <Banner type="critical">- <View- style={{- flexDirection: 'row',- alignItems: 'center',- justifyContent: 'space-between',- }}- >- <View- style={{- flexDirection: 'row',- alignItems: 'center',- gap: 10,- }}- >- <View- style={{- flexDirection: 'row',- alignItems: 'center',- gap: 10,- }}- >- <SvgArrowButtonDown1 style={{ width: 15, height: 15 }} />- <Text>- <Trans>You have budgeted more than your available funds</Trans>- </Text>- </View>- </View>- <Button onPress={openCoverOverbudgetedModal} style={PILL_STYLE}>- <Trans>Cover</Trans>- </Button>- </View>- </Banner>- </GridListItem>- );-}--function OverspendingBanner({ month, onBudgetAction, budgetType, ...props }) {- const { t } = useTranslation();-- const { list: categories, grouped: categoryGroups } = useCategories();- const categoriesById = groupById(categories);- const groupsById = groupById(categoryGroups);-- const dispatch = useDispatch();-- const overspentCategories = useOverspentCategories({ month }).filter(c => {- if (budgetType === 'tracking') {- return !c.hidden && !groupsById[c.group].hidden;- }- return true;- });-- const categoryGroupsToShow = useMemo(- () =>- categoryGroups- .filter(g => overspentCategories.some(c => c.group === g.id))- .map(g => ({- ...g,- categories: overspentCategories.filter(c => c.group === g.id),- })),- [categoryGroups, overspentCategories],- );-- const { showUndoNotification } = useUndo();-- const onOpenCoverCategoryModal = useCallback(- categoryId => {- const category = categoriesById[categoryId];- dispatch(- pushModal({- modal: {- name: 'cover',- options: {- title: category.name,- month,- categoryId: category.id,- onSubmit: fromCategoryId => {- onBudgetAction(month, 'cover-overspending', {- to: category.id,- from: fromCategoryId,- });- showUndoNotification({- message: t(- `Covered {{toCategoryName}} overspending from {{fromCategoryName}}.`,- {- toCategoryName: category.name,- fromCategoryName:- fromCategoryId === 'to-budget'- ? 'To Budget'- : categoriesById[fromCategoryId].name,- },- ),- });- },- },- },- }),- );- },- [categoriesById, dispatch, month, onBudgetAction, showUndoNotification, t],- );-- const onOpenCategorySelectionModal = useCallback(() => {- dispatch(- pushModal({- modal: {- name: 'category-autocomplete',- options: {- title:- budgetType === 'envelope'- ? t('Cover overspending')- : t('Overspent categories'),- month,- categoryGroups: categoryGroupsToShow,- showHiddenCategories: true,- onSelect:- budgetType === 'envelope' ? onOpenCoverCategoryModal : null,- clearOnSelect: true,- closeOnSelect: false,- },- },- }),- );- }, [- categoryGroupsToShow,- dispatch,- month,- onOpenCoverCategoryModal,- t,- budgetType,- ]);-- const numberOfOverspentCategories = overspentCategories.length;- if (numberOfOverspentCategories === 0) {- return null;- }-- return (- <GridListItem textValue="Overspent banner" {...props}>- <Banner type="critical">- <View- style={{- flexDirection: 'row',- alignItems: 'center',- justifyContent: 'space-between',- }}- >- <View- style={{- flexDirection: 'row',- alignItems: 'center',- gap: 10,- }}- >- <Text>- <Trans count={numberOfOverspentCategories}>- You have {{ count: numberOfOverspentCategories }} overspent- categories- </Trans>- </Text>- </View>- <Button onPress={onOpenCategorySelectionModal} style={PILL_STYLE}>- {budgetType === 'envelope' && <Trans>Cover</Trans>}- {budgetType === 'tracking' && <Trans>View</Trans>}- </Button>- </View>- </Banner>- </GridListItem>- );-}--function Banners({ month, onBudgetAction }) {- const { t } = useTranslation();- const [budgetType = 'envelope'] = useSyncedPref('budgetType');-- return (- <GridList- aria-label={t('Banners')}- style={{ backgroundColor: theme.mobilePageBackground }}- >- <UncategorizedTransactionsBanner />- <OverspendingBanner- month={month}- onBudgetAction={onBudgetAction}- budgetType={budgetType}- />- {budgetType === 'envelope' && (- <OverbudgetedBanner month={month} onBudgetAction={onBudgetAction} />- )}- </GridList>+ </>);}@@ -971,73 +598,3 @@ function BudgetTableHeader({</View>);}--function MonthSelector({- month,- monthBounds,- onOpenMonthMenu,- onPrevMonth,- onNextMonth,-}) {- const locale = useLocale();- const { t } = useTranslation();- const prevEnabled = month > monthBounds.start;- const nextEnabled = month < monthUtils.subMonths(monthBounds.end, 1);-- const arrowButtonStyle = {- padding: 10,- margin: 2,- };-- return (- <View- style={{- flex: 1,- justifyContent: 'center',- alignItems: 'center',- flexDirection: 'row',- }}- >- <Button- aria-label={t('Previous month')}- variant="bare"- onPress={() => {- if (prevEnabled) {- onPrevMonth();- }- }}- style={{ ...arrowButtonStyle, opacity: prevEnabled ? 1 : 0.6 }}- >- <SvgArrowThinLeft width="15" height="15" />- </Button>- <Button- variant="bare"- style={{- textAlign: 'center',- fontSize: 16,- fontWeight: 500,- }}- onPress={() => {- onOpenMonthMenu?.(month);- }}- data-month={month}- >- <Text style={styles.underlinedText}>- {monthUtils.format(month, 'MMMM ‘yy', locale)}- </Text>- </Button>- <Button- aria-label={t('Next month')}- variant="bare"- onPress={() => {- if (nextEnabled) {- onNextMonth();- }- }}- style={{ ...arrowButtonStyle, opacity: nextEnabled ? 1 : 0.6 }}- >- <SvgArrowThinRight width="15" height="15" />- </Button>- </View>- );-}diff --git a/packages/desktop-client/src/components/mobile/budget/Category.tsx b/packages/desktop-client/src/components/mobile/budget/Category.tsxdeleted file mode 100644index 44646a7ab5..0000000000--- a/packages/desktop-client/src/components/mobile/budget/Category.tsx+++ /dev/null@@ -1,35 +0,0 @@-import React from 'react';-import { useParams, useSearchParams } from 'react-router';--import * as monthUtils from 'loot-core/shared/months';--import { CategoryTransactions } from './CategoryTransactions';--import { useCategories } from '@desktop-client/hooks/useCategories';-import { useSyncedPref } from '@desktop-client/hooks/useSyncedPref';--export function Category() {- const [_numberFormat] = useSyncedPref('numberFormat');- const numberFormat = _numberFormat || 'comma-dot';- const [hideFraction] = useSyncedPref('hideFraction');-- const { id: categoryId } = useParams();- const [searchParams] = useSearchParams();- const month = searchParams.get('month') || monthUtils.currentMonth();- const { list: categories } = useCategories();- const category = categories.find(c => c.id === categoryId);-- if (category == null) {- return null;- }-- return (- <CategoryTransactions- // This key forces the whole table rerender when the number- // format changes- key={numberFormat + hideFraction}- category={category}- month={month}- />- );-}diff --git a/packages/desktop-client/src/components/mobile/budget/CategoryPage.tsx b/packages/desktop-client/src/components/mobile/budget/CategoryPage.tsxnew file mode 100644index 0000000000..f0af510bb2--- /dev/null+++ b/packages/desktop-client/src/components/mobile/budget/CategoryPage.tsx@@ -0,0 +1,66 @@+import React, { Fragment } from 'react';+import { Trans } from 'react-i18next';+import { useParams, useSearchParams } from 'react-router';++import { TextOneLine } from '@actual-app/components/text-one-line';+import { View } from '@actual-app/components/view';++import * as monthUtils from 'loot-core/shared/months';++import { CategoryTransactions } from './CategoryTransactions';+import { UncategorizedTransactions } from './UncategorizedTransactions';++import { MobileBackButton } from '@desktop-client/components/mobile/MobileBackButton';+import { AddTransactionButton } from '@desktop-client/components/mobile/transactions/AddTransactionButton';+import { MobilePageHeader, Page } from '@desktop-client/components/Page';+import { useCategories } from '@desktop-client/hooks/useCategories';+import { useLocale } from '@desktop-client/hooks/useLocale';+import { useSyncedPref } from '@desktop-client/hooks/useSyncedPref';++export function CategoryPage() {+ const locale = useLocale();+ const [_numberFormat] = useSyncedPref('numberFormat');+ const numberFormat = _numberFormat || 'comma-dot';+ const [hideFraction] = useSyncedPref('hideFraction');++ const { id: categoryIdParam } = useParams();+ const [searchParams] = useSearchParams();+ const month = searchParams.get('month') || monthUtils.currentMonth();+ const { list: categories } = useCategories();+ const category = categories.find(c => c.id === categoryIdParam);++ return (+ <Page+ header={+ <MobilePageHeader+ title={+ category ? (+ <View>+ <TextOneLine>{category.name}</TextOneLine>+ <TextOneLine>+ ({monthUtils.format(month, 'MMMM ‘yy', locale)})+ </TextOneLine>+ </View>+ ) : (+ <TextOneLine>+ <Trans>Uncategorized</Trans>+ </TextOneLine>+ )+ }+ leftContent={<MobileBackButton />}+ rightContent={<AddTransactionButton categoryId={category?.id} />}+ />+ }+ padding={0}+ >+ {/* This key forces the whole table rerender when the number format changes */}+ <Fragment key={numberFormat + hideFraction}>+ {category ? (+ <CategoryTransactions category={category} month={month} />+ ) : (+ <UncategorizedTransactions />+ )}+ </Fragment>+ </Page>+ );+}diff --git a/packages/desktop-client/src/components/mobile/budget/CategoryTransactions.tsx b/packages/desktop-client/src/components/mobile/budget/CategoryTransactions.tsxindex 41bafe0e16..493cea185e 100644--- a/packages/desktop-client/src/components/mobile/budget/CategoryTransactions.tsx+++ b/packages/desktop-client/src/components/mobile/budget/CategoryTransactions.tsx@@ -1,10 +1,6 @@import React, { useCallback, useEffect, useMemo, useState } from 'react';-import { TextOneLine } from '@actual-app/components/text-one-line';-import { View } from '@actual-app/components/view';-import { listen } from 'loot-core/platform/client/fetch';-import * as monthUtils from 'loot-core/shared/months';import { q } from 'loot-core/shared/query';import { isPreviewId } from 'loot-core/shared/transactions';import {@@ -12,14 +8,10 @@ import {type TransactionEntity,} from 'loot-core/types/models';-import { MobileBackButton } from '@desktop-client/components/mobile/MobileBackButton';-import { AddTransactionButton } from '@desktop-client/components/mobile/transactions/AddTransactionButton';import { TransactionListWithBalances } from '@desktop-client/components/mobile/transactions/TransactionListWithBalances';-import { MobilePageHeader, Page } from '@desktop-client/components/Page';import { SchedulesProvider } from '@desktop-client/hooks/useCachedSchedules';import { useCategoryPreviewTransactions } from '@desktop-client/hooks/useCategoryPreviewTransactions';import { useDateFormat } from '@desktop-client/hooks/useDateFormat';-import { useLocale } from '@desktop-client/hooks/useLocale';import { useNavigate } from '@desktop-client/hooks/useNavigate';import { useTransactions } from '@desktop-client/hooks/useTransactions';import { useTransactionsSearch } from '@desktop-client/hooks/useTransactionsSearch';@@ -35,32 +27,12 @@ export function CategoryTransactions({category,month,}: CategoryTransactionsProps) {- const locale = useLocale();-const schedulesQuery = useMemo(() => q('schedules').select('*'), []);return (- <Page- header={- <MobilePageHeader- title={- <View>- <TextOneLine>{category.name}</TextOneLine>- <TextOneLine>- ({monthUtils.format(month, 'MMMM ‘yy', locale)})- </TextOneLine>- </View>- }- leftContent={<MobileBackButton />}- rightContent={<AddTransactionButton categoryId={category.id} />}- />- }- padding={0}- >- <SchedulesProvider query={schedulesQuery}>- <TransactionListWithPreviews category={category} month={month} />- </SchedulesProvider>- </Page>+ <SchedulesProvider query={schedulesQuery}>+ <TransactionListWithPreviews category={category} month={month} />+ </SchedulesProvider>);}diff --git a/packages/desktop-client/src/components/mobile/budget/UncategorizedTransactions.tsx b/packages/desktop-client/src/components/mobile/budget/UncategorizedTransactions.tsxnew file mode 100644index 0000000000..a477385aad--- /dev/null+++ b/packages/desktop-client/src/components/mobile/budget/UncategorizedTransactions.tsx@@ -0,0 +1,92 @@+import React, { useCallback, useEffect, useState } from 'react';++import { listen } from 'loot-core/platform/client/fetch';+import { q } from 'loot-core/shared/query';+import { isPreviewId } from 'loot-core/shared/transactions';+import { type TransactionEntity } from 'loot-core/types/models';++import { TransactionListWithBalances } from '@desktop-client/components/mobile/transactions/TransactionListWithBalances';+import { SchedulesProvider } from '@desktop-client/hooks/useCachedSchedules';+import { useDateFormat } from '@desktop-client/hooks/useDateFormat';+import { useNavigate } from '@desktop-client/hooks/useNavigate';+import { useTransactions } from '@desktop-client/hooks/useTransactions';+import { useTransactionsSearch } from '@desktop-client/hooks/useTransactionsSearch';+import { useDispatch } from '@desktop-client/redux';+import * as bindings from '@desktop-client/spreadsheet/bindings';++export function UncategorizedTransactions() {+ const dispatch = useDispatch();+ const navigate = useNavigate();++ const baseTransactionsQuery = useCallback(+ () =>+ q('transactions')+ .options({ splits: 'inline' })+ .filter({ $and: [{ category: null }, { 'account.offbudget': false }] })+ .select('*'),+ [],+ );++ const [transactionsQuery, setTransactionsQuery] = useState(+ baseTransactionsQuery(),+ );+ const {+ transactions,+ isLoading,+ isLoadingMore,+ loadMore: loadMoreTransactions,+ reload: reloadTransactions,+ } = useTransactions({+ query: transactionsQuery,+ });++ const dateFormat = useDateFormat() || 'MM/dd/yyyy';++ useEffect(() => {+ return listen('sync-event', event => {+ if (event.type === 'applied') {+ const tables = event.tables;+ if (+ tables.includes('transactions') ||+ tables.includes('category_mapping') ||+ tables.includes('payee_mapping')+ ) {+ reloadTransactions();+ }+ }+ });+ }, [dispatch, reloadTransactions]);++ const { search: onSearch } = useTransactionsSearch({+ updateQuery: setTransactionsQuery,+ resetQuery: () => setTransactionsQuery(baseTransactionsQuery()),+ dateFormat,+ });++ const onOpenTransaction = useCallback(+ (transaction: TransactionEntity) => {+ // details of how the native app used to handle preview transactions here can be found at commit 05e58279+ if (!isPreviewId(transaction.id)) {+ navigate(`/transactions/${transaction.id}`);+ }+ },+ [navigate],+ );++ const balance = bindings.uncategorizedBalance();++ return (+ <SchedulesProvider>+ <TransactionListWithBalances+ isLoading={isLoading}+ transactions={transactions}+ balance={balance}+ searchPlaceholder="Search uncategorized transactions"+ onSearch={onSearch}+ isLoadingMore={isLoadingMore}+ onLoadMore={loadMoreTransactions}+ onOpenTransaction={onOpenTransaction}+ />+ </SchedulesProvider>+ );+}diff --git a/packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx b/packages/desktop-client/src/components/mobile/transactions/TransactionList.tsxindex e9866dc12f..557728f827 100644--- a/packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx+++ b/packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx@@ -33,10 +33,7 @@ import * as monthUtils from 'loot-core/shared/months';import { isPreviewId } from 'loot-core/shared/transactions';import { validForTransfer } from 'loot-core/shared/transfer';import { groupById, integerToCurrency } from 'loot-core/shared/util';-import {- type AccountEntity,- type TransactionEntity,-} from 'loot-core/types/models';+import { type TransactionEntity } from 'loot-core/types/models';import { ROW_HEIGHT, TransactionListItem } from './TransactionListItem';@@ -87,7 +84,7 @@ type TransactionListProps = {onOpenTransaction?: (transaction: TransactionEntity) => void;isLoadingMore: boolean;onLoadMore: () => void;- account?: AccountEntity;+ showMakeTransfer?: boolean;};export function TransactionList({@@ -96,7 +93,7 @@ export function TransactionList({onOpenTransaction,isLoadingMore,onLoadMore,- account,+ showMakeTransfer = false,}: TransactionListProps) {const locale = useLocale();const { t } = useTranslation();@@ -229,7 +226,7 @@ export function TransactionList({{selectedTransactions.size > 0 && (<SelectedTransactionsFloatingActionBartransactions={transactions}- showMakeTransfer={!account}+ showMakeTransfer={showMakeTransfer}/>)}</>diff --git a/packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.tsx b/packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.tsxindex 988818e110..7921ba3cf0 100644--- a/packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.tsx+++ b/packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.tsx@@ -6,10 +6,7 @@ import { styles } from '@actual-app/components/styles';import { theme } from '@actual-app/components/theme';import { View } from '@actual-app/components/view';-import {- type AccountEntity,- type TransactionEntity,-} from 'loot-core/types/models';+import { type TransactionEntity } from 'loot-core/types/models';import { TransactionList } from './TransactionList';@@ -92,7 +89,7 @@ type TransactionListWithBalancesProps = {onLoadMore: () => void;onOpenTransaction: (transaction: TransactionEntity) => void;onRefresh?: () => void;- account?: AccountEntity;+ showMakeTransfer?: boolean;};export function TransactionListWithBalances({@@ -107,7 +104,7 @@ export function TransactionListWithBalances({onLoadMore,onOpenTransaction,onRefresh,- account,+ showMakeTransfer = false,}: TransactionListWithBalancesProps) {const selectedInst = useSelected('transactions', [...transactions], []);@@ -151,7 +148,7 @@ export function TransactionListWithBalances({isLoadingMore={isLoadingMore}onLoadMore={onLoadMore}onOpenTransaction={onOpenTransaction}- account={account}+ showMakeTransfer={showMakeTransfer}/></PullToRefresh></>diff --git a/packages/desktop-client/src/components/reports/reports/Calendar.tsx b/packages/desktop-client/src/components/reports/reports/Calendar.tsxindex aa6bee80d5..a23d932dac 100644--- a/packages/desktop-client/src/components/reports/reports/Calendar.tsx+++ b/packages/desktop-client/src/components/reports/reports/Calendar.tsx@@ -712,7 +712,6 @@ function CalendarInner({ widget, parameters }: CalendarInnerProps) {transactions={allTransactions}onOpenTransaction={onOpenTransaction}isLoadingMore={false}- account={undefined}/></View></animated.div>diff --git a/packages/desktop-client/src/components/responsive/narrow.ts b/packages/desktop-client/src/components/responsive/narrow.tsindex fbae63012e..2f63ad277d 100644--- a/packages/desktop-client/src/components/responsive/narrow.ts+++ b/packages/desktop-client/src/components/responsive/narrow.ts@@ -1,6 +1,8 @@-export { Budget } from '../mobile/budget';+export { BudgetPage as Budget } from '../mobile/budget/BudgetPage';-export { Accounts } from '../mobile/accounts/Accounts';-export { Account } from '../mobile/accounts/Account';+export { AccountsPage as Accounts } from '../mobile/accounts/AccountsPage';+export { AccountPage as Account } from '../mobile/accounts/AccountPage';export { MobileRulesPage as Rules } from '../mobile/rules/MobileRulesPage';++export { CategoryPage as Category } from '../mobile/budget/CategoryPage';diff --git a/packages/desktop-client/src/components/responsive/wide.ts b/packages/desktop-client/src/components/responsive/wide.tsindex 1e1df84e0d..e0869334f5 100644--- a/packages/desktop-client/src/components/responsive/wide.ts+++ b/packages/desktop-client/src/components/responsive/wide.ts@@ -10,3 +10,7 @@ export { Account } from '../accounts/Account';export { ManageRulesPage as Rules } from '../ManageRulesPage';export { UserDirectoryPage } from '../admin/UserDirectory/UserDirectoryPage';++// Account component is currently used for uncategorized transactions view.+// Need to separate this to it's own component in the future.+export { Account as Category } from '../accounts/Account';diff --git a/packages/desktop-client/src/hooks/useAccountPreviewTransactions.ts b/packages/desktop-client/src/hooks/useAccountPreviewTransactions.tsindex 6fdef9c7dd..ececdf83f5 100644--- a/packages/desktop-client/src/hooks/useAccountPreviewTransactions.ts+++ b/packages/desktop-client/src/hooks/useAccountPreviewTransactions.ts@@ -15,7 +15,7 @@ import { useSheetValue } from './useSheetValue';import { useSyncedPref } from './useSyncedPref';import { calculateRunningBalancesBottomUp } from './useTransactions';-import { accountBalance } from '@desktop-client/spreadsheet/bindings';+import * as bindings from '@desktop-client/spreadsheet/bindings';type UseAccountPreviewTransactionsProps = {accountId?: AccountEntity['id'] | undefined;@@ -26,8 +26,9 @@ type UseAccountPreviewTransactionsResult = ReturnType<>;/**- * Preview transactions for a given account. This will invert the payees, accounts,- * and amounts depending on which account the preview transactions are being viewed from.+ * Preview transactions for a given account or all accounts if no `accountId` is provided.+ * This will invert the payees, accounts, and amounts accordingly depending on which account+ * the preview transactions are being viewed from.*/export function useAccountPreviewTransactions({accountId,@@ -66,8 +67,13 @@ export function useAccountPreviewTransactions({[accountId, getTransferAccountByPayee],);- const accountBalanceValue = useSheetValue<'account', 'balance'>(- accountBalance(accountId || ''),+ const accountBalanceValue = useSheetValue<+ 'account',+ 'balance' | 'accounts-balance'+ >(+ accountId+ ? bindings.accountBalance(accountId)+ : bindings.allAccountBalance(),);const [showBalances] = useSyncedPref(`show-balances-${accountId}`);diff --git a/packages/desktop-client/src/hooks/useSchedules.ts b/packages/desktop-client/src/hooks/useSchedules.tsindex f42228f649..e2fd2310c0 100644--- a/packages/desktop-client/src/hooks/useSchedules.ts+++ b/packages/desktop-client/src/hooks/useSchedules.ts@@ -143,11 +143,12 @@ export function useSchedules({...data,};}-export function accountSchedulesQuery(- accountId?: AccountEntity['id'] | 'onbudget' | 'offbudget' | 'uncategorized',++export function getSchedulesQuery(+ view?: AccountEntity['id'] | 'onbudget' | 'offbudget' | 'uncategorized',) {- const filterByAccount = accountFilter(accountId, '_account');- const filterByPayee = accountFilter(accountId, '_payee.transfer_acct');+ const filterByAccount = accountFilter(view, '_account');+ const filterByPayee = accountFilter(view, '_payee.transfer_acct');let query = q('schedules').select('*')@@ -155,8 +156,8 @@ export function accountSchedulesQuery($and: [{ '_account.closed': false }],});- if (accountId) {- if (accountId === 'uncategorized') {+ if (view) {+ if (view === 'uncategorized') {query = query.filter({ next_date: null });} else {query = query.filter({diff --git a/upcoming-release-notes/5072.md b/upcoming-release-notes/5072.mdnew file mode 100644index 0000000000..7940e007f6--- /dev/null+++ b/upcoming-release-notes/5072.md@@ -0,0 +1,6 @@+---+category: Bugfix+authors: [joel-jeremy]+---++[Mobile] Fix preview transactions not loading in multi-account views and uncategorized splits not loading.