A local-first personal finance app
[AI] Add "hide reconciled" toggle to all accounts view (#9257)
Ilia Novikov3d6a849b0279
diff --git a/packages/desktop-client/src/components/Modals.tsx b/packages/desktop-client/src/components/Modals.tsxindex be84286048..f7e846d5ca 100644--- a/packages/desktop-client/src/components/Modals.tsx+++ b/packages/desktop-client/src/components/Modals.tsx@@ -17,6 +17,7 @@ import { AccountGroupsModal } from './modals/AccountGroupsModal';import { AccountMenuModal } from './modals/AccountMenuModal';import { AccountReconcileModal } from './modals/AccountReconcileModal';import { AkahuInitialiseModal } from './modals/AkahuInitialiseModal';+import { AllAccountsMenuModal } from './modals/AllAccountsMenuModal';import { BudgetAutomationsModal } from './modals/BudgetAutomationsModal';import { BudgetPageMenuModal } from './modals/BudgetPageMenuModal';import { CategoryAutocompleteModal } from './modals/CategoryAutocompleteModal';@@ -285,6 +286,9 @@ export function Modals() {case 'account-menu':return <AccountMenuModal key={key} {...modal.options} />;+ case 'all-accounts-menu':+ return <AllAccountsMenuModal key={key} {...modal.options} />;+case 'account-reconcile':return <AccountReconcileModal key={key} {...modal.options} />;diff --git a/packages/desktop-client/src/components/accounts/Account.tsx b/packages/desktop-client/src/components/accounts/Account.tsxindex 8cc8dcb875..856c995703 100644--- a/packages/desktop-client/src/components/accounts/Account.tsx+++ b/packages/desktop-client/src/components/accounts/Account.tsx@@ -2059,7 +2059,7 @@ export function Account() {`show-account-${params.id}-net-worth-chart`,);const [hideReconciled, setHideReconciled] = useSyncedPref(- `hide-reconciled-${params.id}`,+ `hide-reconciled-${params.id || 'all'}`, // "All accounts" view provides no ID);const [showExtraBalances, setShowExtraBalances] = useSyncedPref(`show-extra-balances-${params.id || 'all-accounts'}`,diff --git a/packages/desktop-client/src/components/accounts/Header.tsx b/packages/desktop-client/src/components/accounts/Header.tsxindex 3b9468d6a7..12a9b39393 100644--- a/packages/desktop-client/src/components/accounts/Header.tsx+++ b/packages/desktop-client/src/components/accounts/Header.tsx@@ -544,6 +544,12 @@ export function AccountHeader({? t('Hide balance chart'): t('Show balance chart'),},+ {+ name: 'toggle-reconciled',+ text: showReconciled+ ? t('Hide reconciled transactions')+ : t('Show reconciled transactions'),+ },{name: 'manage-columns',text: t('Manage table columns'),diff --git a/packages/desktop-client/src/components/mobile/accounts/AccountPage.tsx b/packages/desktop-client/src/components/mobile/accounts/AccountPage.tsxindex 2c4f5591c0..30a61b89a8 100644--- a/packages/desktop-client/src/components/mobile/accounts/AccountPage.tsx+++ b/packages/desktop-client/src/components/mobile/accounts/AccountPage.tsx@@ -65,6 +65,8 @@ export function AccountPage() {title={account ? (<AccountHeader account={account} />+ ) : accountIdParam === 'all' ? (+ <AllAccountsHeader />) : (<NameOnlyHeader name={nameFromId(accountIdParam)} />)@@ -233,6 +235,39 @@ function AccountHeader({ account }: { readonly account: AccountEntity }) {);}+function AllAccountsHeader() {+ const { t } = useTranslation();+ const dispatch = useDispatch();++ const onClick = useCallback(() => {+ dispatch(+ pushModal({+ modal: {+ name: 'all-accounts-menu',+ options: {},+ },+ }),+ );+ }, [dispatch]);++ return (+ <View style={{ flexDirection: 'row' }}>+ <Button variant="bare" onPress={onClick}>+ <Text+ size="extra-large"+ style={{+ fontWeight: 500,+ ...styles.underlinedText,+ ...(styles.lineClamp(2) as CSSProperties),+ }}+ >+ {t('All Accounts')}+ </Text>+ </Button>+ </View>+ );+}+function NameOnlyHeader({ name }: { readonly name: string }) {return (<Viewdiff --git a/packages/desktop-client/src/components/mobile/accounts/AllAccountTransactions.tsx b/packages/desktop-client/src/components/mobile/accounts/AllAccountTransactions.tsxindex e5f26798d3..f69b6d9ca7 100644--- a/packages/desktop-client/src/components/mobile/accounts/AllAccountTransactions.tsx+++ b/packages/desktop-client/src/components/mobile/accounts/AllAccountTransactions.tsx@@ -16,6 +16,7 @@ import { useDateFormat } from '#hooks/useDateFormat';import { useNavigate } from '#hooks/useNavigate';import { usePreviewTransactions } from '#hooks/usePreviewTransactions';import { getSchedulesQuery } from '#hooks/useSchedules';+import { useSyncedPref } from '#hooks/useSyncedPref';import { useTransactions } from '#hooks/useTransactions';import { useTransactionsSearch } from '#hooks/useTransactionsSearch';import { collapseModals, pushModal } from '#modals/modalsSlice';@@ -40,10 +41,16 @@ function TransactionListWithPreviews() {const filterConditions = location?.state?.filterConditions || [];const isFiltered = filterConditions.length > 0;- const makeRootTransactionsQuery = useCallback(- () => queries.transactions().options({ splits: 'all' }).select('*'),- [],- );+ const [hideReconciled] = useSyncedPref('hide-reconciled-all');+ const dateFormat = useDateFormat() || 'MM/dd/yyyy';++ const makeRootTransactionsQuery = useCallback(() => {+ let query = queries.transactions().options({ splits: 'all' }).select('*');+ if (hideReconciled === 'true') {+ query = query.filter({ reconciled: { $eq: false } });+ }+ return query;+ }, [hideReconciled]);const [currentQuery, setCurrentQuery] = useState<Query | undefined>(() =>isFiltered ? undefined : makeRootTransactionsQuery(),@@ -52,6 +59,36 @@ function TransactionListWithPreviews() {currentQuery,);+ const { isSearching, search } = useTransactionsSearch({+ updateQuery: updateFn =>+ setTransactionsQuery(query => (query ? updateFn(query) : query)),+ resetQuery: () => setTransactionsQuery(currentQuery),+ dateFormat,+ });++ const [searchText, setSearchText] = useState('');+ const onSearch = useCallback(+ (text: string) => {+ setSearchText(text);+ search(text);+ },+ [search],+ );++ const [prevHideReconciled, setPrevHideReconciled] = useState(hideReconciled);+ if (hideReconciled !== prevHideReconciled) {+ setPrevHideReconciled(hideReconciled);+ if (!isFiltered) {+ const query = makeRootTransactionsQuery();+ setCurrentQuery(query);+ setTransactionsQuery(+ searchText !== ''+ ? queries.transactionsSearch(query, searchText, dateFormat)+ : query,+ );+ }+ }+useEffect(() => {let isStale = false;@@ -89,17 +126,9 @@ function TransactionListWithPreviews() {const { previewTransactions, isLoading: isPreviewTransactionsLoading } =usePreviewTransactions();- const dateFormat = useDateFormat() || 'MM/dd/yyyy';const dispatch = useDispatch();const navigate = useNavigate();- const { isSearching, search: onSearch } = useTransactionsSearch({- updateQuery: updateFn =>- setTransactionsQuery(query => (query ? updateFn(query) : query)),- resetQuery: () => setTransactionsQuery(currentQuery),- dateFormat,- });-const onOpenTransaction = useCallback((transaction: TransactionEntity) => {if (!isPreviewId(transaction.id)) {diff --git a/packages/desktop-client/src/components/modals/AllAccountsMenuModal.tsx b/packages/desktop-client/src/components/modals/AllAccountsMenuModal.tsxnew file mode 100644index 0000000000..cb11ff98ca--- /dev/null+++ b/packages/desktop-client/src/components/modals/AllAccountsMenuModal.tsx@@ -0,0 +1,42 @@+import { useTranslation } from 'react-i18next';++import { MobileSheet } from '#components/mobile/MobileSheet';+import { MobileSheetRow } from '#components/mobile/MobileSheetRow';+import { MobileSheetSection } from '#components/mobile/MobileSheetSection';+import { useSyncedPref } from '#hooks/useSyncedPref';+import type { Modal as ModalType } from '#modals/modalsSlice';++type AllAccountsMenuModalProps = Extract<+ ModalType,+ { name: 'all-accounts-menu' }+>['options'];++export function AllAccountsMenuModal({ onClose }: AllAccountsMenuModalProps) {+ const { t } = useTranslation();+ const [hideReconciled, setHideReconciled] = useSyncedPref(+ 'hide-reconciled-all',+ );++ return (+ <MobileSheet+ name="all-accounts-menu"+ title={t('All Accounts')}+ onClose={onClose}+ >+ {() => (+ <MobileSheetSection>+ <MobileSheetRow+ label={+ hideReconciled !== 'true'+ ? t('Hide reconciled transactions')+ : t('Show reconciled transactions')+ }+ onPress={() => {+ setHideReconciled(hideReconciled === 'true' ? 'false' : 'true');+ }}+ />+ </MobileSheetSection>+ )}+ </MobileSheet>+ );+}diff --git a/packages/desktop-client/src/modals/modalsSlice.ts b/packages/desktop-client/src/modals/modalsSlice.tsindex 26321aee7c..d84b7b698a 100644--- a/packages/desktop-client/src/modals/modalsSlice.ts+++ b/packages/desktop-client/src/modals/modalsSlice.ts@@ -366,6 +366,12 @@ export type Modal =onReconcile?: () => void;};}+ | {+ name: 'all-accounts-menu';+ options: {+ onClose?: () => void;+ };+ }| {name: 'account-reconcile';options: {diff --git a/upcoming-release-notes/all-accounts-toggle-reconciled.md b/upcoming-release-notes/all-accounts-toggle-reconciled.mdnew file mode 100644index 0000000000..046433e0cf--- /dev/null+++ b/upcoming-release-notes/all-accounts-toggle-reconciled.md@@ -0,0 +1,6 @@+---+category: Enhancements+authors: [ilia-novikov]+---++Allow hiding reconciled transactions from "All Accounts" view (desktop & mobile)