Boopster commited on
Commit
0cd2a35
·
1 Parent(s): df20c79

feat: initialize metronome UI with default values before loading server status and use defaults for missing status fields.

Browse files
reachy_mini_metronome/static/index.html CHANGED
@@ -509,14 +509,27 @@
509
 
510
  // Initialize
511
  document.addEventListener('DOMContentLoaded', async () => {
 
 
 
 
 
 
 
 
 
 
512
  const status = await getStatus();
513
  if (status) {
514
- bpmValue.textContent = status.bpm;
515
- bpmSlider.value = status.bpm;
516
- timeSignatureSelect.value = status.time_signature;
517
- timeSigValue.textContent = getTimeSigText(status.time_signature);
518
- updateBeatDots(status.time_signature);
519
- isRunning = status.running;
 
 
 
520
  updateToggleButton();
521
  if (isRunning) {
522
  startStatusPolling();
 
509
 
510
  // Initialize
511
  document.addEventListener('DOMContentLoaded', async () => {
512
+ // Set defaults first
513
+ const defaultBpm = 120;
514
+ const defaultTimeSig = 4;
515
+
516
+ bpmValue.textContent = defaultBpm;
517
+ bpmSlider.value = defaultBpm;
518
+ timeSigValue.textContent = getTimeSigText(defaultTimeSig);
519
+ updateBeatDots(defaultTimeSig);
520
+
521
+ // Then try to get actual status from server
522
  const status = await getStatus();
523
  if (status) {
524
+ const bpm = status.bpm ?? defaultBpm;
525
+ const timeSig = status.time_signature ?? defaultTimeSig;
526
+
527
+ bpmValue.textContent = bpm;
528
+ bpmSlider.value = bpm;
529
+ timeSignatureSelect.value = timeSig;
530
+ timeSigValue.textContent = getTimeSigText(timeSig);
531
+ updateBeatDots(timeSig);
532
+ isRunning = status.running ?? false;
533
  updateToggleButton();
534
  if (isRunning) {
535
  startStatusPolling();