Skip to content

Commit 0b6f9cd

Browse files
committed
frontend: update tx's id when account syncs.
1 parent 8564029 commit 0b6f9cd

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

frontends/web/src/components/transactions/details.tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { useEffect, useState } from 'react';
17+
import { useEffect, useState, useCallback } from 'react';
1818
import type { AccountCode, ITransaction } from '@/api/account';
1919
import { getTransaction } from '@/api/account';
20+
import { syncdone } from '@/api/accountsync';
2021
import { usePrevious } from '@/hooks/previous';
2122
import { TxDetailsDialog } from './components/details-dialog';
2223
import { getTxSign } from '@/utils/transaction';
@@ -46,19 +47,32 @@ export const TransactionDetails = ({
4647
}
4748
}, [internalID, prevInternalID]);
4849

49-
useEffect(() => {
50-
if (internalID && !transactionInfo) {
51-
getTransaction(accountCode, internalID).then(transaction => {
50+
const fetchTransaction = useCallback(() => {
51+
if (!internalID) {
52+
return;
53+
}
54+
getTransaction(accountCode, internalID)
55+
.then(transaction => {
5256
if (!transaction) {
5357
console.error(`Unable to retrieve transaction ${internalID}`);
58+
return;
5459
}
5560
setTransactionInfo(transaction);
5661
setOpen(true);
57-
}).catch(console.error);
58-
} else {
59-
setOpen(true);
62+
})
63+
.catch(console.error);
64+
}, [accountCode, internalID]);
65+
66+
useEffect(() => {
67+
fetchTransaction();
68+
}, [fetchTransaction]);
69+
70+
useEffect(() => {
71+
if (!internalID) {
72+
return;
6073
}
61-
}, [accountCode, internalID, transactionInfo]);
74+
return syncdone(accountCode, fetchTransaction)
75+
}, [accountCode, internalID, fetchTransaction]);
6276

6377
if (!transactionInfo) {
6478
return null;

0 commit comments

Comments
 (0)