fix(ui): handle both string and numeric instrument_id formats

On page load, instrument_id from server is already a string ("piano").
After user selection, it's a numeric client_id (61) that needs conversion.
Now checks type before converting to handle both cases correctly.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Nuwan 2026-02-15 10:43:35 +05:30
parent 2b4bd8b934
commit ae7a745659
1 changed files with 7 additions and 5 deletions

View File

@ -11,11 +11,13 @@ const JKSessionAudioInputs = ({ myTracks, chat, mixerHelper, isRemote = false })
) : (
<>
{myTracks.map((track, index) => {
// Convert client instrument_id to server format for icon lookup
// instrument_id is numeric (e.g., 61 for Piano), but icon map uses server strings ("piano")
const serverInstrument = track.track?.instrument_id
? convertClientInstrumentToServer(track.track.instrument_id)
: track.track?.instrument;
// Determine the server instrument string for icon lookup
// - On page load: instrument_id may be a string from server ("piano")
// - After selection: instrument_id is numeric client_id (61) that needs conversion
const instrumentId = track.track?.instrument_id;
const serverInstrument = typeof instrumentId === 'number'
? convertClientInstrumentToServer(instrumentId)
: (instrumentId || track.track?.instrument);
const instrumentIcon = getInstrumentIcon45_inverted(serverInstrument);
return (
<div>