fix: prevent metronome from auto-starting when opening controls

The metronome was starting immediately when opening the controls popup,
which is incorrect behavior. Users should explicitly click the Apply
button to start the metronome.

Changes:
- Removed SessionOpenMetronome() call from handleMetronomeSelected
- Metronome controls now show without starting audio
- Apply button calls SessionSetMetronome() to start/update metronome
- Subsequent opens still don't auto-start

Behavior:
- Open metronome → Controls appear, no audio
- Click Apply → Metronome starts with chosen settings
- Close & reopen → Controls appear, no auto-start

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Nuwan 2026-01-25 07:15:17 +05:30
parent 746cfd72fa
commit 9229d3fe8c
1 changed files with 7 additions and 9 deletions

View File

@ -1025,28 +1025,26 @@ const JKSessionScreen = () => {
// Stop any current playback first (like legacy MixerStore)
await jamClient.SessionStopPlay();
// Open the metronome with default settings
// Default metronome settings for the controls
const bpm = 120;
const sound = "Beep";
const sound = 2; // Beep
const meter = 1;
const mode = 0;
const cricket = false;
console.log(`Opening metronome with bpm: ${bpm}, sound: ${sound}, meter: ${meter}, mode: ${mode}`);
console.log(`Opening metronome controls with default settings: bpm=${bpm}, sound=${sound}, meter=${meter}`);
// Inform server about metronome opening (like legacy SessionStore)
await openMetronome({ id: currentSession.id });
// Start the metronome audio (backend will handle GUI via callback)
const result = await jamClient.SessionOpenMetronome(bpm, sound, meter, mode);
// Update local metronome state to show popup immediately
// NOTE: We don't start the metronome audio here - user must click Apply in popup
if (updateMetronomeState) {
updateMetronomeState({
isOpen: true,
bpm: bpm,
sound: 2, // Beep
sound: sound,
meter: meter,
cricket: mode === 1
cricket: cricket
});
}