Sofia Casadei commited on
Commit
fd841fd
Β·
1 Parent(s): 9784bd2

restart on timeout

Browse files
Files changed (1) hide show
  1. static/client.js +19 -11
static/client.js CHANGED
@@ -136,7 +136,7 @@ document.addEventListener('DOMContentLoaded', function() {
136
  const connectionTimeout = setTimeout(() => {
137
  if (peerConnection && peerConnection.connectionState !== 'connected') {
138
  showError('Connection timeout. Please check your network and try again.');
139
- stop(); // Stop connection attempt
140
  }
141
  }, 15000);
142
 
@@ -371,7 +371,7 @@ document.addEventListener('DOMContentLoaded', function() {
371
  }
372
 
373
  // Stop recording and clean up resources
374
- function stop() {
375
  console.log('Stopping recording...');
376
  // Stop audio visualization
377
  if (animationFrame) {
@@ -411,22 +411,30 @@ document.addEventListener('DOMContentLoaded', function() {
411
  // Update button display
412
  updateButtonState();
413
 
414
- // Ask about clearing transcript
415
- if (window.confirm('Clear transcript?')) {
416
- // Clear all transcript text
417
- transcriptDiv.innerHTML = '';
418
- currentParagraph = null;
419
- } else {
420
- // Just end current paragraph
421
- if (currentParagraph) {
422
- currentParagraph.classList.remove('current');
423
  currentParagraph = null;
 
 
 
 
 
 
424
  }
425
  }
426
 
427
  // Reset timestamp
428
  lastUpdateTime = Date.now();
429
  console.log('Recording stopped');
 
 
 
 
 
430
  }
431
 
432
  // Clean up resources when page is closed
 
136
  const connectionTimeout = setTimeout(() => {
137
  if (peerConnection && peerConnection.connectionState !== 'connected') {
138
  showError('Connection timeout. Please check your network and try again.');
139
+ stop(true); // Restart connection on timeout
140
  }
141
  }, 15000);
142
 
 
371
  }
372
 
373
  // Stop recording and clean up resources
374
+ function stop(restartOnTimeout = false) {
375
  console.log('Stopping recording...');
376
  // Stop audio visualization
377
  if (animationFrame) {
 
411
  // Update button display
412
  updateButtonState();
413
 
414
+ // Skip transcript clearing if restarting on timeout
415
+ if (!restartOnTimeout) {
416
+ // Ask about clearing transcript
417
+ if (window.confirm('Clear transcript?')) {
418
+ // Clear all transcript text
419
+ transcriptDiv.innerHTML = '';
 
 
 
420
  currentParagraph = null;
421
+ } else {
422
+ // Just end current paragraph
423
+ if (currentParagraph) {
424
+ currentParagraph.classList.remove('current');
425
+ currentParagraph = null;
426
+ }
427
  }
428
  }
429
 
430
  // Reset timestamp
431
  lastUpdateTime = Date.now();
432
  console.log('Recording stopped');
433
+
434
+ // Restart connection if requested
435
+ if (restartOnTimeout) {
436
+ setupWebRTC();
437
+ }
438
  }
439
 
440
  // Clean up resources when page is closed