Lightning strike on donation, if enabled. Else success toast (#517)
* Lightning strike on donation, if enabled. Else success toast * remove extra toast from merge --------- Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com> Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
This commit is contained in:
parent
9c774d596b
commit
8017355924
|
@ -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, <Lightning key={state.bolts.length} onDone={() => this.unstrike(state.bolts.length)} />]
|
||||
}
|
||||
})
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
unstrike = (index) => {
|
||||
|
|
|
@ -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: () => <div>Loading...</div>
|
||||
|
@ -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,8 +119,11 @@ export function DonateButton () {
|
|||
console.error(error)
|
||||
toaster.danger('failed to donate')
|
||||
} else {
|
||||
const didStrike = strike()
|
||||
if (!didStrike) {
|
||||
toaster.success('donated')
|
||||
}
|
||||
}
|
||||
onClose()
|
||||
}}
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue