removed instrumentSelectionTrackId from projectStore, align the instrumentSelectionTrackId with selectedTrackId.

This commit is contained in:
Xiaohan-Tian
2025-08-12 18:14:25 -07:00
parent ee34115423
commit 7ada648d14
3 changed files with 17 additions and 30 deletions
+4 -4
View File
@@ -6,14 +6,14 @@ import { KGMidiTrack, type InstrumentType } from '../core/track/KGMidiTrack';
const InstrumentSelection: React.FC = () => {
const {
tracks,
instrumentSelectionTrackId,
selectedTrackId,
closeInstrumentSelection,
setTrackInstrument
} = useProjectStore();
const targetTrack = useMemo(() => {
return tracks.find(t => t.getId().toString() === instrumentSelectionTrackId) || null;
}, [tracks, instrumentSelectionTrackId]);
return tracks.find(t => t.getId().toString() === selectedTrackId) || null;
}, [tracks, selectedTrackId]);
const currentInstrumentKey: InstrumentType = (targetTrack && targetTrack instanceof KGMidiTrack)
? (targetTrack.getInstrument() as InstrumentType)
@@ -27,7 +27,7 @@ const InstrumentSelection: React.FC = () => {
useEffect(() => {
// Sync when the target track or its instrument changes
setSelectedGroupKey(currentInstrumentDef?.group || 'PIANO_AND_KEYBOARDS');
}, [instrumentSelectionTrackId, currentInstrumentKey, currentInstrumentDef]);
}, [selectedTrackId, currentInstrumentKey, currentInstrumentDef]);
const groups = useMemo(() => Object.entries(INSTRUMENT_GROUPS) as Array<[string, string]>, []);
+2 -2
View File
@@ -193,8 +193,8 @@ const TrackInfoItem: React.FC<TrackInfoItemProps> = ({
e.stopPropagation();
// Select this track as active when opening instrument panel
setSelectedTrack(track.getId().toString());
// Toggle global InstrumentSelection panel for this track
toggleInstrumentSelectionForTrack(track.getId().toString());
// Toggle global InstrumentSelection panel (it follows selectedTrackId)
toggleInstrumentSelectionForTrack();
};
// Handle settings button click