fix: silent "Tip not confirmed" error

Currently, the payment is made but the graphql api is not able to confirm it, so I just wrapped it with a catch to silent the error, however it has to be fixed from the backend soon
This commit is contained in:
MTG2000
2022-01-17 16:29:14 +02:00
parent c6020935dc
commit 262d54cc43
2 changed files with 21 additions and 12 deletions

View File

@@ -10,7 +10,7 @@ import { ALL_CATEGORIES_PROJECTS_QUERY, ALL_CATEGORIES_PROJECTS_RES } from "./qu
export default function ProjectsSection() {
const { data, loading } = useQuery<ALL_CATEGORIES_PROJECTS_RES>(ALL_CATEGORIES_PROJECTS_QUERY);
console.log(data, loading);
if (loading || !data) return <div className='mt-32 lg:mt-48'>
{Array(3).fill(0).map((_, idx) => <ProjectsRowSkeleton key={idx} />)}

View File

@@ -68,17 +68,24 @@ export default function TipCard({ onClose, direction, tipValue, ...props }: Prop
const [vote, { data }] = useMutation(VOTE, {
onCompleted: async (votingData) => {
setPaymentStatus(PaymentStatus.AWAITING_PAYMENT);
const webln = await Wallet_Service.getWebln()
webln.sendPayment(votingData.vote.payment_request).then((res: any) => {
console.log("waiting for payment", res);
confirmVote({ variables: { paymentRequest: votingData.vote.payment_request, preimage: res.preimage } });
try {
setPaymentStatus(PaymentStatus.AWAITING_PAYMENT);
const webln = await Wallet_Service.getWebln()
const paymentResponse = await webln.sendPayment(votingData.vote.payment_request);
setPaymentStatus(PaymentStatus.PAID);
})
.catch((err: any) => {
console.log(err);
setPaymentStatus(PaymentStatus.NOT_PAID);
});
confirmVote({ variables: { paymentRequest: votingData.vote.payment_request, preimage: paymentResponse.preimage } })
.catch() // ONLY TEMPROARY !!! SHOULD BE FIXED FROM BACKEND
.finally(() => {
setTimeout(() => {
onClose?.();
}, 2000);
})
} catch (error) {
console.log(error);
setPaymentStatus(PaymentStatus.NOT_PAID);
}
}
});
@@ -88,7 +95,9 @@ export default function TipCard({ onClose, direction, tipValue, ...props }: Prop
setTimeout(() => {
onClose?.();
}, 2000);
}
},
onError: () => { }
});
const onChangeInput = (event: React.ChangeEvent<HTMLInputElement>) => {