Reply To: Remove notification count if zero
One aspect I forgot was if the user is not logged in, ths would fix that:
const notificationsCounter = document.getElementById('ab-pending-notifications');
const notificationsIndicator = document.getElementById('wp-admin-bar-bp-notifications');
function counterChange() {
if (notificationsCounter.innerText == '0') {
notificationsIndicator.style.display = 'none';
} else {
notificationsIndicator.style.display = 'block';
}
}
if (notificationCounter){
notificationsCounter.addEventListener('change', counterChange);
}
counterChange();