diff --git a/src/components/upDownVote.js b/src/components/upDownVote.js index f145c2c..06c18c5 100644 --- a/src/components/upDownVote.js +++ b/src/components/upDownVote.js @@ -9,6 +9,7 @@ export default function UpDownVote({ upvotes, downvotes, userId, + disabled, }) { const upvoted = upvotes.includes(userId) const downvoted = downvotes.includes(userId) @@ -19,6 +20,9 @@ export default function UpDownVote({ className={styles.action} onClick={(e) => { e.stopPropagation() + if (disabled) { + return + } if (!upvoted) { onUp() } else { @@ -33,6 +37,9 @@ export default function UpDownVote({ className={styles.action} onClick={(e) => { e.stopPropagation() + if (disabled) { + return + } if (!downvoted) { onDown() } else { diff --git a/src/pages/userfiles.js b/src/pages/userfiles.js index 2b2c358..371c73b 100644 --- a/src/pages/userfiles.js +++ b/src/pages/userfiles.js @@ -193,6 +193,7 @@ export default function UserFiles({ router, globalData }) { const [usageShowing, setUsageShowing] = useState(false) const [searchTerm, setSearchTerm] = useState() const [uploading, setUploading] = useState(false) + const [votingDisabled, setVotingDisabled] = useState(false) const currDir = router.query.dir ? decodeURIComponent(router.query.dir) : '' @@ -236,6 +237,19 @@ export default function UserFiles({ router, globalData }) { } } + const handleVote = (type, dir) => { + setVotingDisabled(true) + vote(type, dir) + .then((res) => { + setDirs(res.files) + setVotingDisabled(false) + }) + .catch((res) => { + alert(res.msg) + setVotingDisabled(false) + }) + } + const renderDirList = (dirs) => { return (