Only go off of the global count variable

This commit is contained in:
Brandon Rozek 2025-06-11 22:19:56 -04:00
parent 9f57be5587
commit 487cd8cbd7
No known key found for this signature in database
GPG key ID: DFB0E78F805F4567

View file

@ -127,11 +127,11 @@
async function loadHighFiveCount() { async function loadHighFiveCount() {
try { try {
const data = await makeApiRequest('GET'); const data = await makeApiRequest('GET');
currentCount = data.count || 0; currentCount = data.count || currentCount;
updateButtonContent('hand-paper', currentCount); updateButtonContent('hand-paper');
} catch (error) { } catch (error) {
console.error('Failed to load high five count:', error); console.error('Failed to load high five count:', error);
updateButtonContent('hand-paper', currentCount); updateButtonContent('hand-paper');
} }
} }
@ -152,11 +152,11 @@
// Check if user already gave a high five (HTTP 409 response) // Check if user already gave a high five (HTTP 409 response)
if (data.alreadyHighFived) { if (data.alreadyHighFived) {
updateButtonContent('check', newCount); updateButtonContent('check');
showMessage('👋 Already high-fived!', 'success'); showMessage('👋 Already high-fived!', 'success');
setButtonState('disabled'); setButtonState('disabled');
} else { } else {
updateButtonContent('check', newCount); updateButtonContent('check');
showMessage('🎉 Thanks!', 'success'); showMessage('🎉 Thanks!', 'success');
setButtonState('disabled'); setButtonState('disabled');
} }
@ -165,7 +165,7 @@
console.error('Failed to send high five:', error); console.error('Failed to send high five:', error);
showMessage('❌ Failed to send', 'error', CONFIG.TIMEOUTS.ERROR_MESSAGE); showMessage('❌ Failed to send', 'error', CONFIG.TIMEOUTS.ERROR_MESSAGE);
updateButtonContent('hand-paper', currentCount); updateButtonContent('hand-paper');
setButtonState('disabled'); setButtonState('disabled');
setTimeout(() => { setTimeout(() => {
@ -177,10 +177,10 @@
/** /**
* Update button content with icon and count * Update button content with icon and count
*/ */
function updateButtonContent(icon, count) { function updateButtonContent(icon) {
elements.count.textContent = count; elements.count.textContent = currentCount;
const iconClass = icon === 'loading' ? 'fa-spinner fa-spin' : `fa-${icon}`; const iconClass = icon === 'loading' ? 'fa-spinner fa-spin' : `fa-${icon}`;
const text = icon === 'loading' ? 'Sending...' : `(${count})`; const text = icon === 'loading' ? 'Sending...' : `(${currentCount})`;
elements.button.innerHTML = `<i class="fa ${iconClass}" style="margin-right: 0.5rem;" aria-hidden="true"></i>${text}`; elements.button.innerHTML = `<i class="fa ${iconClass}" style="margin-right: 0.5rem;" aria-hidden="true"></i>${text}`;
} }