fixed tip button bug (#1049)

* fixed tip button bug
This commit is contained in:
ingawei 2022-10-14 02:20:32 -05:00 committed by GitHub
parent b4162a0896
commit 0a70652667
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,11 +61,11 @@ export function Tipper(prop: {
) )
const addTip = (delta: number) => { const addTip = (delta: number) => {
setTempTip(tempTip + delta) setTempTip((tempTip) => tempTip + delta)
const timeoutId = setTimeout(() => { const timeoutId = setTimeout(() => {
me && me &&
saveTip(me, comment, delta) saveTip(me, comment, delta)
.then(() => setTempTip(tempTip - delta)) .then(() => setTempTip((tempTip) => tempTip - delta))
.catch((e) => console.error(e)) .catch((e) => console.error(e))
}, TIP_UNDO_DURATION + 1000) }, TIP_UNDO_DURATION + 1000)
toast.custom( toast.custom(
@ -74,7 +74,7 @@ export function Tipper(prop: {
userName={comment.userName} userName={comment.userName}
onUndoClick={() => { onUndoClick={() => {
clearTimeout(timeoutId) clearTimeout(timeoutId)
setTempTip(tempTip - delta) setTempTip((tempTip) => tempTip - delta)
}} }}
/> />
), ),