fix quick succession of upvotes boosting
This commit is contained in:
parent
c80e4d107c
commit
10730bf7d5
@ -8,10 +8,12 @@ import ActionTooltip from './action-tooltip'
|
|||||||
import { useItemAct } from './item-act'
|
import { useItemAct } from './item-act'
|
||||||
import Window from '../svgs/window-2-fill.svg'
|
import Window from '../svgs/window-2-fill.svg'
|
||||||
import { useMe } from './me'
|
import { useMe } from './me'
|
||||||
|
import { useState } from 'react'
|
||||||
|
|
||||||
export default function UpVote ({ item, className }) {
|
export default function UpVote ({ item, className }) {
|
||||||
const { setError } = useFundError()
|
const { setError } = useFundError()
|
||||||
const { setItem } = useItemAct()
|
const { setItem } = useItemAct()
|
||||||
|
const [voteLock, setVoteLock] = useState()
|
||||||
const me = useMe()
|
const me = useMe()
|
||||||
const [act] = useMutation(
|
const [act] = useMutation(
|
||||||
gql`
|
gql`
|
||||||
@ -99,7 +101,7 @@ export default function UpVote ({ item, className }) {
|
|||||||
me
|
me
|
||||||
? async (e) => {
|
? async (e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
if (!item) return
|
if (!item || voteLock) return
|
||||||
|
|
||||||
// we can't tip ourselves
|
// we can't tip ourselves
|
||||||
if (noSelfTips) {
|
if (noSelfTips) {
|
||||||
@ -109,8 +111,8 @@ export default function UpVote ({ item, className }) {
|
|||||||
if (item?.meVote) {
|
if (item?.meVote) {
|
||||||
if (me?.tipDefault) {
|
if (me?.tipDefault) {
|
||||||
try {
|
try {
|
||||||
await act({ variables: { id: item.id, act: 'TIP', sats: me.tipDefault } })
|
|
||||||
strike()
|
strike()
|
||||||
|
await act({ variables: { id: item.id, act: 'TIP', sats: me.tipDefault } })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
@ -123,6 +125,7 @@ export default function UpVote ({ item, className }) {
|
|||||||
strike()
|
strike()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setVoteLock(true)
|
||||||
await act({ variables: { id: item.id, act: 'VOTE', sats: 1 } })
|
await act({ variables: { id: item.id, act: 'VOTE', sats: 1 } })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.toString().includes('insufficient funds')) {
|
if (error.toString().includes('insufficient funds')) {
|
||||||
@ -130,6 +133,8 @@ export default function UpVote ({ item, className }) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
throw new Error({ message: error.toString() })
|
throw new Error({ message: error.toString() })
|
||||||
|
} finally {
|
||||||
|
setVoteLock(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
: signIn
|
: signIn
|
||||||
|
Loading…
x
Reference in New Issue
Block a user