Merge branch 'dev' of rajukottedi/chirpy-blogging into prod

This commit is contained in:
Bangara Raju Kottedi 2023-08-25 21:42:47 +05:30 committed by Gogs
commit 1d9ac4dbce

View File

@ -6,10 +6,20 @@ likesLoader.style.display = "none"
let likesAmount = likesCount.innerHTML; let likesAmount = likesCount.innerHTML;
function apiCall(url) { function onLoadAndClick(){
likesLoader.style.display = "inline-flex"
likesCount.style.display = "none";
heartIcon.style.pointerEvents = 'none';
}
function apiCall(url, event) {
onLoadAndClick();
ajax(url) ajax(url)
.then(function (result) { .then(function (result) {
console.log(result); console.log(result);
if(event === "click"){
heartIcon.classList.toggle("liked");
}
likesCount.innerHTML = result; likesCount.innerHTML = result;
likesLoader.style.display = "none" likesLoader.style.display = "none"
likesCount.style.display = "inline-flex"; likesCount.style.display = "inline-flex";
@ -17,7 +27,7 @@ function apiCall(url) {
}) })
.catch(function () { .catch(function () {
likesLoader.style.display = "none"; likesLoader.style.display = "none";
likesCount.style.display = "inline-block"; likesCount.style.display = "inline-flex";
}); });
} }
@ -26,16 +36,11 @@ var apiUrl = serviceUrl + "/GetPostLikes?siteId=" + siteId + "&postId=" + postId
apiCall(apiUrl); apiCall(apiUrl);
heartIcon.addEventListener("click", () => { heartIcon.addEventListener("click", () => {
likesLoader.style.display = "inline-flex" if (!heartIcon.classList.contains("liked")) {
likesCount.style.display = "none";
heartIcon.style.pointerEvents = 'none';
heartIcon.classList.toggle("liked");
if (heartIcon.classList.contains("liked")) {
apiUrl = serviceUrl + "/LikePost?siteId=" + siteId + "&postId=" + postId; apiUrl = serviceUrl + "/LikePost?siteId=" + siteId + "&postId=" + postId;
} else { } else {
apiUrl = serviceUrl + "/DislikePost?siteId=" + siteId + "&postId=" + postId; apiUrl = serviceUrl + "/DislikePost?siteId=" + siteId + "&postId=" + postId;
} }
apiCall(apiUrl); apiCall(apiUrl, "click");
}); });