mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
Vote imporvements
This commit is contained in:
parent
d22e20b79e
commit
5611fd8d66
2 changed files with 25 additions and 21 deletions
|
@ -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 (
|
||||
<div>
|
||||
|
@ -348,35 +362,18 @@ export default function UserFiles({ router, globalData }) {
|
|||
{Array.isArray(upvotes) && Array.isArray(downvotes) && (
|
||||
<UpDownVote
|
||||
onUp={() => {
|
||||
vote('up', dir)
|
||||
.then((res) => {
|
||||
setDirs(res.files)
|
||||
})
|
||||
.catch((res) => {
|
||||
alert(res.msg)
|
||||
})
|
||||
handleVote('up', dir)
|
||||
}}
|
||||
onDown={() => {
|
||||
vote('down', dir)
|
||||
.then((res) => {
|
||||
setDirs(res.files)
|
||||
})
|
||||
.catch((res) => {
|
||||
alert(res.msg)
|
||||
})
|
||||
handleVote('down', dir)
|
||||
}}
|
||||
onClear={() => {
|
||||
vote('clear', dir)
|
||||
.then((res) => {
|
||||
setDirs(res.files)
|
||||
})
|
||||
.catch((res) => {
|
||||
alert(res.msg)
|
||||
})
|
||||
handleVote('clear', dir)
|
||||
}}
|
||||
upvotes={upvotes}
|
||||
downvotes={downvotes}
|
||||
userId={userId}
|
||||
disabled={votingDisabled}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue