disabling service worker for api calls

This commit is contained in:
Bangara Raju Kottedi 2024-05-07 04:20:44 +05:30
parent f06a42cb69
commit 5e0b39a1fb
3 changed files with 6 additions and 1 deletions

View File

@ -22,7 +22,9 @@
if(Number(comments.innerText) !== NaN){ if(Number(comments.innerText) !== NaN){
commentsCount = Number(comments.innerText); commentsCount = Number(comments.innerText);
} }
ajax(serviceUrl + "/UpdatePostCommentsCount?blogUrl=" + siteId + "&postSlug=" + postId, "POST", commentsCount); if(commentsCount !== commentsCountFromResponse){
ajax(serviceUrl + "/UpdatePostCommentsCount?blogUrl=" + siteId + "&postSlug=" + postId, "POST", commentsCount);
}
}); });
var config = { childList: true }; var config = { childList: true };
observer.observe(target, config); observer.observe(target, config);

View File

@ -148,6 +148,7 @@
xhr.open(type, url); xhr.open(type, url);
xhr.setRequestHeader('XApiKey', 'c6eAXYcNT873TT7BfMgQyS4ii7hxa53TLEUN7pAGaaU='); xhr.setRequestHeader('XApiKey', 'c6eAXYcNT873TT7BfMgQyS4ii7hxa53TLEUN7pAGaaU=');
xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('ngsw-bypass', '');
xhr.send(JSON.stringify(payload)); xhr.send(JSON.stringify(payload));
}); });
} }

View File

@ -29,6 +29,7 @@
const views = document.getElementById("views-count"); const views = document.getElementById("views-count");
const likes = document.getElementById("likes-count"); const likes = document.getElementById("likes-count");
const postLikesAndViews = document.getElementById("likes-views"); const postLikesAndViews = document.getElementById("likes-views");
var commentsCountFromResponse = 0;
postLikesAndViews.style.display = "none"; postLikesAndViews.style.display = "none";
@ -60,6 +61,7 @@
if(response.postExists){ if(response.postExists){
views.innerText = response.views; views.innerText = response.views;
likes.innerText = response.likes; likes.innerText = response.likes;
commentsCountFromResponse = response.comments;
postLikesAndViews.style.display = "inline"; postLikesAndViews.style.display = "inline";
} }
} }