mirror of
https://github.com/Brandon-Rozek/website-theme.git
synced 2025-07-31 14:12:01 +00:00
Only go off of the global count variable
This commit is contained in:
parent
9f57be5587
commit
487cd8cbd7
1 changed files with 9 additions and 9 deletions
|
@ -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}`;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue