Update meme voting
This commit is contained in:
parent
7b5f418344
commit
3116e66c47
@ -667,10 +667,35 @@ async function reloadMemeVotes(memeID) {
|
||||
}
|
||||
|
||||
async function voteMeme(memeID, isUpvote){
|
||||
await doAction("/meme", {
|
||||
action: "voteMeme",
|
||||
meme_id: memeID,
|
||||
is_upvote: isUpvote
|
||||
}, "Meme bol upvotenutý", "Nastala chyba pri upvoteovaní meme-u", true);
|
||||
let memeVoteUpvoteElement = document.getElementById(`meme_votes_upvote_${memeID}`);
|
||||
let memeVoteDownvoteElement = document.getElementById(`meme_votes_downvote_${memeID}`);
|
||||
let memeVoteDelete = false;
|
||||
if(isUpvote) {
|
||||
if(memeVoteUpvoteElement.classList.contains("ri-arrow-up-circle-fill")){
|
||||
deleteVoteMeme(memeID);
|
||||
memeVoteDelete = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(memeVoteDownvoteElementElement.classList.contains("ri-arrow-up-circle-fill")){
|
||||
deleteVoteMeme(memeID);
|
||||
memeVoteDelete = true;
|
||||
}
|
||||
}
|
||||
if (!memeVoteDelete) {
|
||||
await doAction("/meme", {
|
||||
action: "voteMeme",
|
||||
meme_id: memeID,
|
||||
is_upvote: isUpvote
|
||||
}, "Meme bol votovaný", "Nastala chyba pri votovaný", true);
|
||||
}
|
||||
await reloadMemeVotes(memeID);
|
||||
}
|
||||
|
||||
async function deleteVoteMeme(memeId) {
|
||||
await doAction("/meme", {
|
||||
action: "deleteVoteMeme",
|
||||
meme_id: memeId
|
||||
}, "Hlas na meme bol zmazaný", "Nastala chyba pri mazaní hlasu na meme", true);
|
||||
await reloadMemeVotes(memeId);
|
||||
}
|
Loading…
Reference in New Issue
Block a user