From c8c02da433459aa0935b7dfbcaa47357c730a711 Mon Sep 17 00:00:00 2001 From: jknapp Date: Sat, 30 Aug 2025 17:44:05 -0700 Subject: [PATCH] Add comprehensive debugging for hold button state issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Debugging Enhancements: - Added detailed console logging for hold button element detection - Enhanced AJAX request/response logging for hold operations - Added button state verification with delayed checks - Tracked endCall() function calls that might reset button state - Added logging for button text and class changes This will help identify: 1. Whether the button element is found correctly 2. If AJAX calls are succeeding or failing 3. Whether button updates are being applied 4. If other functions are interfering with button state 5. Timing issues with DOM updates Use browser console to debug hold button behavior during testing. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- assets/js/browser-phone-frontend.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/assets/js/browser-phone-frontend.js b/assets/js/browser-phone-frontend.js index 8422cb5..68e2d05 100644 --- a/assets/js/browser-phone-frontend.js +++ b/assets/js/browser-phone-frontend.js @@ -527,6 +527,7 @@ $('.twp-browser-phone-container').removeClass('incoming-call'); // Reset control buttons + console.log('endCall() called - resetting hold button from:', $('#twp-hold-btn').text()); $('#twp-hold-btn').text('Hold').removeClass('btn-active'); $('#twp-record-btn').text('Record').removeClass('btn-active'); @@ -1559,6 +1560,10 @@ const $holdBtn = $('#twp-hold-btn'); const currentHoldState = isOnHold; + console.log('Hold button element found:', $holdBtn.length); + console.log('Current hold state:', currentHoldState); + console.log('Current button text:', $holdBtn.text()); + // Update button immediately for better UX if (currentHoldState) { $holdBtn.text('Resuming...').prop('disabled', true); @@ -1566,6 +1571,13 @@ $holdBtn.text('Holding...').prop('disabled', true); } + console.log('Sending hold toggle request:', { + action: 'twp_toggle_hold', + call_sid: callSid, + hold: !currentHoldState, + nonce: twp_frontend_ajax.nonce + }); + $.ajax({ url: twp_frontend_ajax.ajax_url, method: 'POST', @@ -1585,13 +1597,20 @@ console.log('Hold state updated to:', isOnHold); if (isOnHold) { + console.log('Setting button to Resume state...'); $holdBtn.text('Resume').addClass('btn-active').prop('disabled', false); + console.log('Button after update - text:', $holdBtn.text(), 'classes:', $holdBtn.attr('class')); showMessage('Call placed on hold - Click Resume to continue', 'info'); - console.log('Button updated to Resume state'); + + // Verify the button was actually updated + setTimeout(function() { + console.log('Button state after 100ms:', $holdBtn.text(), $holdBtn.hasClass('btn-active')); + }, 100); } else { + console.log('Setting button to Hold state...'); $holdBtn.text('Hold').removeClass('btn-active').prop('disabled', false); + console.log('Button after update - text:', $holdBtn.text(), 'classes:', $holdBtn.attr('class')); showMessage('Call resumed', 'info'); - console.log('Button updated to Hold state'); } } else { console.error('Hold toggle failed:', response);