From 1b41f63c0b6f47707c32ad29c15eb7269419fdb6 Mon Sep 17 00:00:00 2001 From: Philipp Walter Date: Tue, 4 Jun 2024 13:11:10 +0200 Subject: [PATCH] fix(ui): fix orange ticket confetti (#1941) --- src/screens/OrangeTicket.tsx | 153 +---------------------------------- src/utils/lightning/index.ts | 9 +-- 2 files changed, 6 insertions(+), 156 deletions(-) diff --git a/src/screens/OrangeTicket.tsx b/src/screens/OrangeTicket.tsx index a6d0ad66c..5360c4a1d 100644 --- a/src/screens/OrangeTicket.tsx +++ b/src/screens/OrangeTicket.tsx @@ -1,48 +1,20 @@ -import React, { - memo, - ReactElement, - useCallback, - useEffect, - useState, -} from 'react'; -import { Image, StyleSheet, View } from 'react-native'; -import Lottie from 'lottie-react-native'; -import { useTranslation } from 'react-i18next'; +import React, { memo, ReactElement, useCallback, useEffect } from 'react'; import { ldk } from '@synonymdev/react-native-ldk'; -import Button from '../components/Button'; -import AmountToggle from '../components/AmountToggle'; -import SafeAreaInset from '../components/SafeAreaInset'; -import BottomSheetWrapper from '../components/BottomSheetWrapper'; -import BottomSheetNavigationHeader from '../components/BottomSheetNavigationHeader'; -import { useAppDispatch, useAppSelector } from '../hooks/redux'; +import { useAppSelector } from '../hooks/redux'; import { useLightningMaxInboundCapacity } from '../hooks/lightning'; -import { useBottomSheetBackPress, useSnapPoints } from '../hooks/bottomSheet'; import { showToast } from '../utils/notifications'; import { getNodeIdFromStorage, waitForLdk } from '../utils/lightning'; -import { closeSheet } from '../store/slices/ui'; import { viewControllerSelector } from '../store/reselect/ui'; import { createLightningInvoice } from '../store/utils/lightning'; import { __TREASURE_HUNT_HOST__ } from '../constants/env'; -import { rootNavigation } from '../navigation/root/RootNavigator'; - -const confettiPurpleSrc = require('../assets/lottie/confetti-purple.json'); -const imageSrc = require('../assets/illustrations/coin-stack-x.png'); const OrangeTicket = (): ReactElement => { - const { t } = useTranslation('wallet'); - const snapPoints = useSnapPoints('large'); - const dispatch = useAppDispatch(); const maxInboundCapacitySat = useLightningMaxInboundCapacity(); - const [isLoading, setIsLoading] = useState(true); - const [paymentHash, setPaymentHash] = useState(); - const [amount, setAmount] = useState(); const { isOpen, ticketId } = useAppSelector((state) => { return viewControllerSelector(state, 'orangeTicket'); }); - useBottomSheetBackPress('orangeTicket'); - const getPrize = useCallback(async (): Promise => { const getLightningInvoice = async (): Promise => { const response = await createLightningInvoice({ @@ -156,146 +128,27 @@ const OrangeTicket = (): ReactElement => { if (chestResponse.error) { return; } - setAmount(chestResponse.amountSat); const openResponse = await openChest(); if (openResponse.error) { return; } - setAmount(openResponse.amountSat); const claimResponse = await claimPrize(); if (claimResponse.error) { return; } - setIsLoading(false); - setPaymentHash(claimResponse.btResponse.payment.paymentHash); }, [ticketId, maxInboundCapacitySat]); useEffect(() => { if (!isOpen) { - setIsLoading(true); return; } getPrize(); }, [isOpen, getPrize]); - if (!isOpen || isLoading) { - return <>; - } - - const onAmountPress = (): void => { - if (paymentHash) { - dispatch(closeSheet('orangeTicket')); - rootNavigation.navigate('ActivityDetail', { id: paymentHash }); - } - }; - - const onButtonPress = (): void => { - dispatch(closeSheet('orangeTicket')); - }; - - return ( - - - - - - - - - {amount && } - - - - - - - - -