Skip to content

Commit 663b98f

Browse files
committed
cleaner balance calculation
1 parent b058fc4 commit 663b98f

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

packages/desktop-client/src/hooks/usePreviewTransactions.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { useCachedSchedules } from './useCachedSchedules';
2323
import { type ScheduleStatuses } from './useSchedules';
2424
import { useSyncedPref } from './useSyncedPref';
2525

26+
import { aqlQuery } from '@desktop-client/queries/aqlQuery';
2627
import { liveQuery } from '@desktop-client/queries/liveQuery';
2728
import {
2829
pagedQuery,
@@ -179,14 +180,12 @@ export function useTransactions({
179180

180181
useMemo(() => {
181182
if (optionsRef.current.calculateRunningBalances && runningBalanceQuery) {
182-
liveQuery(runningBalanceQuery, {
183-
onData: (data: { id: string; balance: IntegerAmount }[]) => {
184-
const map = new Map<TransactionEntity['id'], IntegerAmount>();
185-
data.forEach(val => {
186-
map.set(val.id, val.balance);
187-
});
188-
setRunningBalances(map);
189-
},
183+
aqlQuery(runningBalanceQuery).then(data => {
184+
const map = new Map<TransactionEntity['id'], IntegerAmount>();
185+
data.data.forEach(val => {
186+
map.set(val.id, val.balance);
187+
});
188+
setRunningBalances(map);
190189
});
191190
} else {
192191
setRunningBalances(new Map());

0 commit comments

Comments
 (0)