Skip to content

Commit

Permalink
TyepeScript Enhancement and async changes 2
Browse files Browse the repository at this point in the history
  • Loading branch information
zaidmstrr committed May 1, 2024
1 parent 155d322 commit a40b60e
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions components/AttestationButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,23 @@ export default function AttestationButton(props: any) {

return (
<TouchableOpacity
onPress={() => {
onPress={async () => {
if (attestationStatus === 'neutral') {
setLoading(true);
stores.lightningAddressStore
.lookupAttestations(hash, amount_msat)
.then(({ attestations, status }) => {
setAttestations(attestations);
setAttestationStatus(status || '');
setLoading(false);
})
.catch(() => {
setLoading(false);
});
try {
const { attestations, status } =
await stores.lightningAddressStore.lookupAttestations(
hash,
amount_msat
);
setAttestations(attestations);
setAttestationStatus(status || '' || 'error');
} catch (error) {
console.error('Error fetching attestations:', error);
setAttestationStatus('error' || '');
} finally {
setLoading(false);
}
} else {
if (attestationStatus === 'success') {
navigation.navigate('Attestation', {
Expand Down

0 comments on commit a40b60e

Please sign in to comment.