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: []
|
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 = () => {
|
strike = () => {
|
||||||
const should = window.localStorage.getItem('lnAnimate') || 'yes'
|
const should = window.localStorage.getItem('lnAnimate') || 'yes'
|
||||||
if (should === '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)} />]
|
bolts: [...state.bolts, <Lightning key={state.bolts.length} onDone={() => this.unstrike(state.bolts.length)} />]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
unstrike = (index) => {
|
unstrike = (index) => {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { useShowModal } from '../../components/modal'
|
||||||
import dynamic from 'next/dynamic'
|
import dynamic from 'next/dynamic'
|
||||||
import { SSR } from '../../lib/constants'
|
import { SSR } from '../../lib/constants'
|
||||||
import { useToast } from '../../components/toast'
|
import { useToast } from '../../components/toast'
|
||||||
|
import { useLightning } from '../../components/lightning'
|
||||||
|
|
||||||
const GrowthPieChart = dynamic(() => import('../../components/charts').then(mod => mod.GrowthPieChart), {
|
const GrowthPieChart = dynamic(() => import('../../components/charts').then(mod => mod.GrowthPieChart), {
|
||||||
loading: () => <div>Loading...</div>
|
loading: () => <div>Loading...</div>
|
||||||
|
@ -90,6 +91,7 @@ export default function Rewards ({ ssrData }) {
|
||||||
export function DonateButton () {
|
export function DonateButton () {
|
||||||
const showModal = useShowModal()
|
const showModal = useShowModal()
|
||||||
const toaster = useToast()
|
const toaster = useToast()
|
||||||
|
const strike = useLightning()
|
||||||
const [donateToRewards] = useMutation(
|
const [donateToRewards] = useMutation(
|
||||||
gql`
|
gql`
|
||||||
mutation donateToRewards($sats: Int!, $hash: String, $hmac: String) {
|
mutation donateToRewards($sats: Int!, $hash: String, $hmac: String) {
|
||||||
|
@ -117,8 +119,11 @@ export function DonateButton () {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
toaster.danger('failed to donate')
|
toaster.danger('failed to donate')
|
||||||
} else {
|
} else {
|
||||||
|
const didStrike = strike()
|
||||||
|
if (!didStrike) {
|
||||||
toaster.success('donated')
|
toaster.success('donated')
|
||||||
}
|
}
|
||||||
|
}
|
||||||
onClose()
|
onClose()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in New Issue