diff --git a/components/lightning.js b/components/lightning.js index c15f45af..948abf56 100644 --- a/components/lightning.js +++ b/components/lightning.js @@ -8,6 +8,10 @@ export class LightningProvider extends React.Component { bolts: [] } + /** + * Strike lightning on the screen, if the user has the setting enabled + * @returns boolean indicating whether the strike actually happened, based on user preferences + */ strike = () => { const should = window.localStorage.getItem('lnAnimate') || 'yes' if (should === 'yes') { @@ -16,7 +20,9 @@ export class LightningProvider extends React.Component { bolts: [...state.bolts, this.unstrike(state.bolts.length)} />] } }) + return true } + return false } unstrike = (index) => { diff --git a/pages/rewards/index.js b/pages/rewards/index.js index ad5014a0..6d833130 100644 --- a/pages/rewards/index.js +++ b/pages/rewards/index.js @@ -15,6 +15,7 @@ import { useShowModal } from '../../components/modal' import dynamic from 'next/dynamic' import { SSR } from '../../lib/constants' import { useToast } from '../../components/toast' +import { useLightning } from '../../components/lightning' const GrowthPieChart = dynamic(() => import('../../components/charts').then(mod => mod.GrowthPieChart), { loading: () =>
Loading...
@@ -90,6 +91,7 @@ export default function Rewards ({ ssrData }) { export function DonateButton () { const showModal = useShowModal() const toaster = useToast() + const strike = useLightning() const [donateToRewards] = useMutation( gql` mutation donateToRewards($sats: Int!, $hash: String, $hmac: String) { @@ -117,7 +119,10 @@ export function DonateButton () { console.error(error) toaster.danger('failed to donate') } else { - toaster.success('donated') + const didStrike = strike() + if (!didStrike) { + toaster.success('donated') + } } onClose() }}