Skip to content

Commit

Permalink
fix: call saveTx only once per tx
Browse files Browse the repository at this point in the history
  • Loading branch information
chloezxyy committed Jan 25, 2024
1 parent 3feba51 commit 2ebbd4e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions mobile-app/app/components/OceanInterface/OceanInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export function OceanInterface(): JSX.Element | null {
const slideAnim = useRef(new Animated.Value(0)).current;
// state
const [tx, setTx] = useState<OceanTransaction | undefined>(transaction);
const [calledTx, setCalledTx] = useState<string | undefined>();
const [err, setError] = useState<string | undefined>(e?.message);
const [txUrl, setTxUrl] = useState<string | undefined>();
// evm tx state
Expand Down Expand Up @@ -167,18 +168,23 @@ export function OceanInterface(): JSX.Element | null {
}),
},
);
// store called transaction
setCalledTx((prevTx) =>
prevTx !== tx?.tx.txId ? tx?.tx.txId : prevTx,
);
} catch (e) {
/* empty */
/* empty - don't do anything even if saveTx is not called */
}
};
if (
tx !== undefined &&
calledTx !== tx?.tx.txId && // to ensure that api is only called once per tx
tx?.tx.txId !== undefined &&
network === EnvironmentNetwork.MainNet &&
isSaveTxEnabled
) {
saveTx(tx.tx.txId);
}
}, [tx, network, isSaveTxEnabled]);
}, [tx?.tx.txId, calledTx, network, isSaveTxEnabled]);

useEffect(() => {
// get evm tx id and url (if any)
Expand Down

0 comments on commit 2ebbd4e

Please sign in to comment.