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){
|
async function voteMeme(memeID, isUpvote){
|
||||||
await doAction("/meme", {
|
let memeVoteUpvoteElement = document.getElementById(`meme_votes_upvote_${memeID}`);
|
||||||
action: "voteMeme",
|
let memeVoteDownvoteElement = document.getElementById(`meme_votes_downvote_${memeID}`);
|
||||||
meme_id: memeID,
|
let memeVoteDelete = false;
|
||||||
is_upvote: isUpvote
|
if(isUpvote) {
|
||||||
}, "Meme bol upvotenutý", "Nastala chyba pri upvoteovaní meme-u", true);
|
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);
|
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