Skip to content
Snippets Groups Projects
Unverified Commit f5023a7c authored by Robert Dyer's avatar Robert Dyer Committed by GitHub
Browse files

feature: Show account sync indicators when viewing accounts on mobile (#2476)

* cleanup: Move account sync indicators to the left on mobile

* cleanup: account sync indicators on mobile should show pending/failed syncs

* feature: show account sync indicator when viewing account on mobile

* fix lint issues

* add release note
parent bc6a0f8e
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,7 @@ import { ...@@ -21,6 +21,7 @@ import {
import { useAccounts } from '../../../hooks/useAccounts'; import { useAccounts } from '../../../hooks/useAccounts';
import { useCategories } from '../../../hooks/useCategories'; import { useCategories } from '../../../hooks/useCategories';
import { useDateFormat } from '../../../hooks/useDateFormat'; import { useDateFormat } from '../../../hooks/useDateFormat';
import { useFailedAccounts } from '../../../hooks/useFailedAccounts';
import { useLocalPref } from '../../../hooks/useLocalPref'; import { useLocalPref } from '../../../hooks/useLocalPref';
import { useLocalPrefs } from '../../../hooks/useLocalPrefs'; import { useLocalPrefs } from '../../../hooks/useLocalPrefs';
import { useNavigate } from '../../../hooks/useNavigate'; import { useNavigate } from '../../../hooks/useNavigate';
...@@ -77,6 +78,9 @@ export function Account(props) { ...@@ -77,6 +78,9 @@ export function Account(props) {
const accounts = useAccounts(); const accounts = useAccounts();
const payees = usePayees(); const payees = usePayees();
const failedAccounts = useFailedAccounts();
const syncingAccountIds = useSelector(state => state.account.accountsSyncing);
const navigate = useNavigate(); const navigate = useNavigate();
const [transactions, setTransactions] = useState([]); const [transactions, setTransactions] = useState([]);
const [isSearching, setIsSearching] = useState(false); const [isSearching, setIsSearching] = useState(false);
...@@ -238,6 +242,8 @@ export function Account(props) { ...@@ -238,6 +242,8 @@ export function Account(props) {
{...state} {...state}
key={numberFormat + hideFraction} key={numberFormat + hideFraction}
account={account} account={account}
pending={syncingAccountIds.includes(account.id)}
failed={failedAccounts && failedAccounts.has(account.id)}
accounts={accounts} accounts={accounts}
categories={categories.list} categories={categories.list}
payees={state.payees} payees={state.payees}
......
...@@ -62,6 +62,8 @@ function TransactionSearchInput({ accountName, onSearch }) { ...@@ -62,6 +62,8 @@ function TransactionSearchInput({ accountName, onSearch }) {
export function AccountDetails({ export function AccountDetails({
account, account,
pending,
failed,
prependTransactions, prependTransactions,
transactions, transactions,
accounts, accounts,
...@@ -86,7 +88,34 @@ export function AccountDetails({ ...@@ -86,7 +88,34 @@ export function AccountDetails({
return ( return (
<Page <Page
title={account.name} title={
!account.bankId ? (
account.name
) : (
<View
style={{
flexDirection: 'row',
}}
>
<div
style={{
margin: 'auto',
marginRight: 3,
width: 8,
height: 8,
borderRadius: 8,
backgroundColor: pending
? theme.sidebarItemBackgroundPending
: failed
? theme.sidebarItemBackgroundFailed
: theme.sidebarItemBackgroundPositive,
transition: 'transform .3s',
}}
/>
{account.name}
</View>
)
}
headerLeftContent={<MobileBackButton />} headerLeftContent={<MobileBackButton />}
headerRightContent={ headerRightContent={
<ButtonLink <ButtonLink
......
...@@ -6,6 +6,7 @@ import * as queries from 'loot-core/src/client/queries'; ...@@ -6,6 +6,7 @@ import * as queries from 'loot-core/src/client/queries';
import { useAccounts } from '../../../hooks/useAccounts'; import { useAccounts } from '../../../hooks/useAccounts';
import { useCategories } from '../../../hooks/useCategories'; import { useCategories } from '../../../hooks/useCategories';
import { useFailedAccounts } from '../../../hooks/useFailedAccounts';
import { useLocalPref } from '../../../hooks/useLocalPref'; import { useLocalPref } from '../../../hooks/useLocalPref';
import { useNavigate } from '../../../hooks/useNavigate'; import { useNavigate } from '../../../hooks/useNavigate';
import { useSetThemeColor } from '../../../hooks/useSetThemeColor'; import { useSetThemeColor } from '../../../hooks/useSetThemeColor';
...@@ -54,7 +55,15 @@ function AccountHeader({ name, amount, style = {} }) { ...@@ -54,7 +55,15 @@ function AccountHeader({ name, amount, style = {} }) {
); );
} }
function AccountCard({ account, updated, getBalanceQuery, onSelect }) { function AccountCard({
account,
updated,
connected,
pending,
failed,
getBalanceQuery,
onSelect,
}) {
return ( return (
<View <View
style={{ style={{
...@@ -94,6 +103,22 @@ function AccountCard({ account, updated, getBalanceQuery, onSelect }) { ...@@ -94,6 +103,22 @@ function AccountCard({ account, updated, getBalanceQuery, onSelect }) {
alignItems: 'center', alignItems: 'center',
}} }}
> >
{account.bankId && (
<View
style={{
backgroundColor: pending
? theme.sidebarItemBackgroundPending
: failed
? theme.sidebarItemBackgroundFailed
: theme.sidebarItemBackgroundPositive,
marginRight: '8px',
width: 8,
height: 8,
borderRadius: 8,
opacity: connected ? 1 : 0,
}}
/>
)}
<TextOneLine <TextOneLine
style={{ style={{
...styles.text, ...styles.text,
...@@ -106,17 +131,6 @@ function AccountCard({ account, updated, getBalanceQuery, onSelect }) { ...@@ -106,17 +131,6 @@ function AccountCard({ account, updated, getBalanceQuery, onSelect }) {
> >
{account.name} {account.name}
</TextOneLine> </TextOneLine>
{account.bankId && (
<View
style={{
backgroundColor: theme.noticeBackgroundDark,
marginLeft: '-23px',
width: 8,
height: 8,
borderRadius: 8,
}}
/>
)}
</View> </View>
</View> </View>
<CellValue <CellValue
...@@ -153,6 +167,8 @@ function AccountList({ ...@@ -153,6 +167,8 @@ function AccountList({
onSelectAccount, onSelectAccount,
onSync, onSync,
}) { }) {
const failedAccounts = useFailedAccounts();
const syncingAccountIds = useSelector(state => state.account.accountsSyncing);
const budgetedAccounts = accounts.filter(account => account.offbudget === 0); const budgetedAccounts = accounts.filter(account => account.offbudget === 0);
const offbudgetAccounts = accounts.filter(account => account.offbudget === 1); const offbudgetAccounts = accounts.filter(account => account.offbudget === 1);
const noBackgroundColorStyle = { const noBackgroundColorStyle = {
...@@ -194,7 +210,10 @@ function AccountList({ ...@@ -194,7 +210,10 @@ function AccountList({
<AccountCard <AccountCard
account={acct} account={acct}
key={acct.id} key={acct.id}
updated={updatedAccounts.includes(acct.id)} updated={updatedAccounts && updatedAccounts.includes(acct.id)}
connected={!!acct.bank}
pending={syncingAccountIds.includes(acct.id)}
failed={failedAccounts && failedAccounts.has(acct.id)}
getBalanceQuery={getBalanceQuery} getBalanceQuery={getBalanceQuery}
onSelect={onSelectAccount} onSelect={onSelectAccount}
/> />
...@@ -211,7 +230,10 @@ function AccountList({ ...@@ -211,7 +230,10 @@ function AccountList({
<AccountCard <AccountCard
account={acct} account={acct}
key={acct.id} key={acct.id}
updated={updatedAccounts.includes(acct.id)} updated={updatedAccounts && updatedAccounts.includes(acct.id)}
connected={!!acct.bank}
pending={syncingAccountIds.includes(acct.id)}
failed={failedAccounts && failedAccounts.has(acct.id)}
getBalanceQuery={getBalanceQuery} getBalanceQuery={getBalanceQuery}
onSelect={onSelectAccount} onSelect={onSelectAccount}
/> />
......
---
category: Enhancements
authors: [psybers]
---
Show account sync indicators when viewing accounts on mobile.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment