fix: immediately setHasZapped to true after zapping

This commit is contained in:
daniyal 2024-09-11 22:25:03 +05:00
parent d15c5a21d9
commit 7a1d0bbfb0
3 changed files with 14 additions and 2 deletions

View File

@ -120,6 +120,7 @@ type ZapQRProps = {
handleClose: () => void
handleQRExpiry: () => void
setTotalZapAmount?: Dispatch<SetStateAction<number>>
setHasZapped?: Dispatch<SetStateAction<boolean>>
}
export const ZapQR = React.memo(
@ -127,7 +128,8 @@ export const ZapQR = React.memo(
paymentRequest,
handleClose,
handleQRExpiry,
setTotalZapAmount
setTotalZapAmount,
setHasZapped
}: ZapQRProps) => {
useDidMount(() => {
ZapController.getInstance()
@ -137,6 +139,7 @@ export const ZapQR = React.memo(
if (setTotalZapAmount) {
const amount = getZapAmount(zapReceipt)
setTotalZapAmount((prev) => prev + amount)
if (setHasZapped) setHasZapped(true)
}
})
.catch((err) => {
@ -227,6 +230,8 @@ type ZapPopUpProps = {
notCloseAfterZap?: boolean
lastNode?: ReactNode
setTotalZapAmount?: Dispatch<SetStateAction<number>>
setHasZapped?: Dispatch<SetStateAction<boolean>>
handleClose: () => void
}
@ -239,6 +244,7 @@ export const ZapPopUp = ({
lastNode,
notCloseAfterZap,
setTotalZapAmount,
setHasZapped,
handleClose
}: ZapPopUpProps) => {
const [isLoading, setIsLoading] = useState(false)
@ -337,6 +343,8 @@ export const ZapPopUp = ({
toast.success(`Successfully sent ${amount} sats!`)
if (setTotalZapAmount) {
setTotalZapAmount((prev) => prev + amount)
if (setHasZapped) setHasZapped(true)
}
if (!notCloseAfterZap) {
@ -357,7 +365,8 @@ export const ZapPopUp = ({
notCloseAfterZap,
handleClose,
generatePaymentRequest,
setTotalZapAmount
setTotalZapAmount,
setHasZapped
])
const handleQRExpiry = useCallback(() => {
@ -438,6 +447,7 @@ export const ZapPopUp = ({
handleClose={handleQRClose}
handleQRExpiry={handleQRExpiry}
setTotalZapAmount={setTotalZapAmount}
setHasZapped={setHasZapped}
/>
)}
{lastNode}

View File

@ -590,6 +590,7 @@ const Zap = (props: Event) => {
eventId={props.id}
handleClose={() => setIsOpen(false)}
setTotalZapAmount={setTotalZappedAmount}
setHasZapped={setHasZapped}
/>
)}
</>

View File

@ -74,6 +74,7 @@ export const Zap = ({ modDetails }: ZapProps) => {
lastNode={<ZapSite />}
notCloseAfterZap
setTotalZapAmount={setTotalZappedAmount}
setHasZapped={setHasZapped}
/>
)}
</>