fix(ui): correct Volume modal to use category mixers for proper display

- Use MonitorCatGroup category mixers with AudioInputMusic/AudioInputChat
  names instead of incorrect MasterGroup/MonitorGroup channel mixers
- Add refresh on modal open to fetch fresh data from native client
- Remove FTUESave call that was causing VU meters to stop working
- Export getAudioInputCategoryMixer and getChatCategoryMixer from useMixerHelper

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Nuwan 2026-02-19 14:19:14 +05:30
parent 4a3a0fee87
commit 34d6a2fbac
2 changed files with 61 additions and 23 deletions

View File

@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect, useState, useCallback } from 'react';
import {
Modal,
ModalHeader,
@ -7,41 +7,76 @@ import {
import SessionTrackVU from './SessionTrackVU';
import SessionTrackGain from './SessionTrackGain'
import { useMixersContext } from '../../context/MixersContext';
import { ChannelGroupIds } from '../../helpers/globals.js';
import { useJamClient } from '../../context/JamClientContext';
import { MIX_MODES, ChannelGroupIds, CategoryGroupIds } from '../../helpers/globals.js';
const JKSessionVolumeModal = ({ isOpen, toggle }) => {
const mixerHelper = useMixersContext();
const jamClient = useJamClient();
const mixers = mixerHelper.myTracks[0]?.mixers;
// Get the real backend mixers for volume controls (like web version)
const getMusicMixers = () => {
const allMixers = mixerHelper.mixers;
const mode = mixerHelper.mixMode;
const targetGroupId = mode === true ? ChannelGroupIds.MasterGroup : ChannelGroupIds.MonitorGroup;
// Local state for fresh mixer data from native client
const [musicMixer, setMusicMixer] = useState(null);
const [chatMixer, setChatMixer] = useState(null);
// Find the real mixer with correct volume values
for (const key in allMixers) {
if (allMixers[key] && allMixers[key].group_id === targetGroupId) {
return allMixers[key]; // Return the real mixer object
}
// Refresh mixer data from native client when modal opens
// This ensures we have the latest values, including changes made in legacy app
useEffect(() => {
if (isOpen && jamClient) {
const refreshMixers = async () => {
try {
// Get fresh mixer data from native client (PERSONAL mode for monitor output)
const freshMixers = await jamClient.SessionGetAllControlState(false);
// Find music and chat category mixers from fresh data
// Category mixers are in MonitorCatGroup (group_id 3) with specific name properties
for (const mixer of freshMixers) {
if (mixer.group_id === ChannelGroupIds.MonitorCatGroup) {
if (mixer.name === CategoryGroupIds.AudioInputMusic) {
setMusicMixer(mixer);
} else if (mixer.name === CategoryGroupIds.AudioInputChat) {
setChatMixer(mixer);
}
}
}
} catch (error) {
console.warn('Failed to refresh mixer data:', error);
}
};
refreshMixers();
}
}, [isOpen, jamClient]);
// Get music category mixer - prefer fresh data from state, fallback to context
const getMusicMixers = useCallback(() => {
if (musicMixer) {
return musicMixer;
}
// Fallback to context data
const categoryMixerResult = mixerHelper.getAudioInputCategoryMixer(MIX_MODES.PERSONAL);
if (categoryMixerResult && categoryMixerResult.mixer) {
return categoryMixerResult.mixer;
}
return null;
};
}, [musicMixer, mixerHelper]);
const getChatMixers = () => {
const allMixers = mixerHelper.mixers;
const targetGroupId = ChannelGroupIds.AudioInputChatGroup;
// Find the real chat mixer with correct volume values
for (const key in allMixers) {
if (allMixers[key] && allMixers[key].group_id === targetGroupId) {
return allMixers[key]; // Return the real mixer object
}
// Get chat category mixer - prefer fresh data from state, fallback to context
const getChatMixers = useCallback(() => {
if (chatMixer) {
return chatMixer;
}
// Fallback to context data
const categoryMixerResult = mixerHelper.getChatCategoryMixer(MIX_MODES.PERSONAL);
if (categoryMixerResult && categoryMixerResult.mixer) {
return categoryMixerResult.mixer;
}
return null;
};
}, [chatMixer, mixerHelper]);
const handleCancel = () => {
// Volume changes are applied immediately via setSessionMixerCategoryPlayoutState
// when the slider is moved, so no explicit save is needed here.
// Note: FTUESave was removed because it was causing VU meters to stop working.
toggle();
};

View File

@ -999,6 +999,9 @@ const useMixerHelper = () => {
faderChanged,
initGain,
setMixerPan,
// Category mixer functions for Volume modal
getAudioInputCategoryMixer,
getChatCategoryMixer,
// Media arrays from mediaSlice
backingTracks,
jamTracks,