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

View File

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

View File

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