fix: updateBedtimeRange variable scoping - originalText accessible in finally block
This commit is contained in:
@@ -2544,12 +2544,15 @@ async function updateBedtimeRange(guildId) {
|
||||
const [startHour, startMinute] = startTime.split(':').map(Number);
|
||||
const [endHour, endMinute] = endTime.split(':').map(Number);
|
||||
|
||||
const button = document.querySelector(`button[onclick="updateBedtimeRange('${guildIdStr}')"]`);
|
||||
const originalText = button ? button.textContent : 'Update Bedtime Range';
|
||||
|
||||
try {
|
||||
// Show loading state
|
||||
const button = document.querySelector(`button[onclick="updateBedtimeRange('${guildIdStr}')"]`);
|
||||
const originalText = button.textContent;
|
||||
if (button) {
|
||||
button.textContent = 'Updating...';
|
||||
button.disabled = true;
|
||||
}
|
||||
|
||||
// Send the update request
|
||||
const response = await fetch(`/servers/${guildIdStr}/bedtime-range`, {
|
||||
@@ -2579,9 +2582,8 @@ async function updateBedtimeRange(guildId) {
|
||||
} catch (error) {
|
||||
console.error('Failed to update bedtime range:', error);
|
||||
showNotification(error.message || 'Failed to update bedtime range', 'error');
|
||||
|
||||
} finally {
|
||||
// Restore button state
|
||||
const button = document.querySelector(`button[onclick="updateBedtimeRange('${guildIdStr}')"]`);
|
||||
if (button) {
|
||||
button.textContent = originalText;
|
||||
button.disabled = false;
|
||||
|
||||
Reference in New Issue
Block a user