Skip to content

Commit

Permalink
Code review update
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Apr 13, 2024
1 parent d253770 commit 458fa43
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function MobileBackButton({ style }: MobileBackButtonProps) {
return (
<Button
type="bare"
aria-label="Back"
style={{
color: theme.mobileHeaderText,
justifyContent: 'center',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,39 +176,31 @@ function TransactionListWithPreviews({ account }) {
);
}, []);

const fetchTransactions = useCallback(async () => {
const fetchTransactions = useCallback(() => {
const query = makeRootQuery();
setCurrentQuery(query);
updateQuery(query);
}, [makeRootQuery, updateQuery]);

useEffect(() => {
let unlisten;

async function setUpAccount() {
unlisten = listen('sync-event', ({ type, tables }) => {
if (type === 'applied') {
if (
tables.includes('transactions') ||
tables.includes('category_mapping') ||
tables.includes('payee_mapping')
) {
paged.current?.run();
}

if (tables.includes('payees') || tables.includes('payee_mapping')) {
dispatch(getPayees());
}
const unlisten = listen('sync-event', ({ type, tables }) => {
if (type === 'applied') {
if (
tables.includes('transactions') ||
tables.includes('category_mapping') ||
tables.includes('payee_mapping')
) {
paged.current?.run();
}
});

await fetchTransactions();

dispatch(markAccountRead(account.id));
}

setUpAccount();
if (tables.includes('payees') || tables.includes('payee_mapping')) {
dispatch(getPayees());
}
}
});

fetchTransactions();
dispatch(markAccountRead(account.id));
return () => unlisten();
}, [account.id, dispatch, fetchTransactions]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { useNavigate } from '../../../hooks/useNavigate';
import { SvgAdd } from '../../../icons/v1';
import { theme } from '../../../style';
import { Link } from '../../common/Link';
import { Button } from '../../common/Button';

type AddTransactionButtonProps = {
to: string;
Expand All @@ -18,9 +18,7 @@ export function AddTransactionButton({
}: AddTransactionButtonProps) {
const navigate = useNavigate();
return (
<Link
variant="button"
to={to}
<Button
type="bare"
aria-label="Add transaction"
style={{
Expand All @@ -32,13 +30,11 @@ export function AddTransactionButton({
color: theme.mobileHeaderText,
background: theme.mobileHeaderTextHover,
}}
activeStyle={{ background: 'transparent' }}
onClick={e => {
e.preventDefault();
onClick={() => {
navigate(to, { state: { accountId, categoryId } });
}}
>
<SvgAdd width={20} height={20} />
</Link>
</Button>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function ListBox(props) {
const { loadMore } = props;

const { hasScrolledToBottom } = useScroll();
const scrolledToBottom = hasScrolledToBottom();
const scrolledToBottom = hasScrolledToBottom(5);
const prevScrolledToBottom = usePrevious(scrolledToBottom);

if (!prevScrolledToBottom && scrolledToBottom) {
Expand Down

0 comments on commit 458fa43

Please sign in to comment.