mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-04 06:06:19 +01:00
reset counters
This commit is contained in:
@@ -271,19 +271,32 @@
|
||||
|
||||
function hitAuth(classLookup, table, URL){
|
||||
toggleButtons(classLookup);
|
||||
fetch(URL)
|
||||
let output = fetch(URL)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
toggleButtons(classLookup);
|
||||
return
|
||||
return true;
|
||||
}
|
||||
removeRow(table, classLookup)
|
||||
})
|
||||
.catch(error => {
|
||||
toggleButtons(classLookup);
|
||||
return;
|
||||
return false;
|
||||
});
|
||||
toggleButtons(classLookup);
|
||||
return output;
|
||||
}
|
||||
|
||||
function decreaseCounter(id){
|
||||
elem = document.getElementById(id);
|
||||
console.log(elem);
|
||||
count = Number(elem.innerText);
|
||||
count -= 1;
|
||||
if (!count){
|
||||
elem.classList.add("d-none");
|
||||
} else {
|
||||
elem.innerText = count;
|
||||
}
|
||||
}
|
||||
|
||||
let acceptJoinButtons = document.querySelectorAll(".join-accept");
|
||||
@@ -291,7 +304,10 @@
|
||||
elem.addEventListener("click", function(event) {
|
||||
url = `${acceptJoinURL}${event.target.id}/`
|
||||
let elemClass = `.btns-join-${event.target.id}`
|
||||
hitAuth(elemClass, tableAdd, url)
|
||||
if (hitAuth(elemClass, tableAdd, url)){
|
||||
decreaseCounter("acceptRequestsCounter")
|
||||
decreaseCounter("globalNotificationCount")
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -300,7 +316,10 @@
|
||||
elem.addEventListener("click", function(event) {
|
||||
url = `${rejectJoinURL}${event.target.id}/`
|
||||
let elemClass = `.btns-join-${event.target.id}`
|
||||
hitAuth(elemClass, tableAdd, url)
|
||||
if (hitAuth(elemClass, tableAdd, url)){
|
||||
decreaseCounter("acceptRequestsCounter")
|
||||
decreaseCounter("globalNotificationCount")
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -309,7 +328,10 @@
|
||||
elem.addEventListener("click", function(event) {
|
||||
url = `${acceptLeaveURL}${event.target.id}/`
|
||||
let elemClass = `.btns-leave-${event.target.id}`
|
||||
hitAuth(elemClass, tableRem, url)
|
||||
if (hitAuth(elemClass, tableRem, url)){
|
||||
decreaseCounter("leaveRequestsCounter")
|
||||
decreaseCounter("globalNotificationCount")
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -318,7 +340,10 @@
|
||||
elem.addEventListener("click", function(event) {
|
||||
url = `${rejectLeaveURL}${event.target.id}/`
|
||||
let elemClass = `.btns-leave-${event.target.id}`
|
||||
hitAuth(elemClass, tableRem, url)
|
||||
if (hitAuth(elemClass, tableRem, url)){
|
||||
decreaseCounter("leaveRequestsCounter")
|
||||
decreaseCounter("globalNotificationCount")
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user