Skip to content

Commit

Permalink
Improving Typescript Enhancement 2
Browse files Browse the repository at this point in the history
  • Loading branch information
zaidmstrr committed Apr 26, 2024
1 parent 3bba9f1 commit 17cb8a8
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions components/AttestationButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@ import NostrichNotLoaded from '../assets/images/SVG/Nostrich_not-loaded.svg';
import NostrichValid from '../assets/images/SVG/Nostrich_valid.svg';
import NostrichInvalid from '../assets/images/SVG/Nostrich_invalid.svg';
import NostrichNotFound from '../assets/images/SVG/Nostrich_not-found.svg';

export default function AttestationButton(props: any) {
const { navigation, hash, amount_msat } = props;
const [attestationStatus, setAttestationStatus] = useState('neutral');
const [loading, setLoading] = useState(false);
const [attestations, setAttestations] = useState([]);
type attestationStatus = 'neutral' | 'success' | 'warning' | 'error';

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 17cb8a8

Please sign in to comment.