fix: move ghost decls before totalBeats to fix TDZ
This commit is contained in:
+15
-45
@@ -4595,23 +4595,10 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
||||
const [rollBeats, setRollBeats] = React.useState(Math.max(noteMaxBeat + 16, 64));
|
||||
const rollBeatsRef = React.useRef(rollBeats);
|
||||
rollBeatsRef.current = rollBeats;
|
||||
const totalBeats = sessionSyncMode ? Math.max(rollBeats, sessionLengthBars * 4 + 16, 64) : Math.max(rollBeats, noteMaxBeat + 16, 64);
|
||||
const drawWidth = totalBeats * pixelsPerBeat;
|
||||
const [rollViewWidth, setRollViewWidth] = React.useState(800);
|
||||
const viewWidth = Math.max(drawWidth, rollViewWidth);
|
||||
const viewBeats = Math.ceil(viewWidth / pixelsPerBeat) + 4;
|
||||
|
||||
const [notes, setNotes] = React.useState(st.notes || []);
|
||||
const notesRef = React.useRef(notes);
|
||||
notesRef.current = notes;
|
||||
React.useEffect(() => { if (!draggedNoteRef.current) setNotes(st.notes || []); }, [st.notes]);
|
||||
const brushVelocityRef = React.useRef(0.8);
|
||||
const [selectedNoteIds, setSelectedNoteIds] = React.useState([]);
|
||||
const [loopStartBeat, setLoopStartBeat] = React.useState(null);
|
||||
const [loopEndBeat, setLoopEndBeat] = React.useState(null);
|
||||
const [isLooping, setIsLooping] = React.useState(false);
|
||||
const [showGhostNotes, setShowGhostNotes] = React.useState(true);
|
||||
const [sessionSyncMode, setSessionSyncMode] = React.useState(true);
|
||||
const [ghostTrackFilter, setGhostTrackFilter] = React.useState(null);
|
||||
|
||||
const allMidiItems = React.useMemo(() => {
|
||||
const result = [];
|
||||
@@ -4640,8 +4627,6 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
||||
const sessionStartBar = sessionSyncMode && activeTargetItem
|
||||
? (activeTargetItem.startTime / secondsPerBar) : 0;
|
||||
|
||||
const [ghostTrackFilter, setGhostTrackFilter] = React.useState(null);
|
||||
|
||||
const sessionLengthBars = React.useMemo(function() {
|
||||
var maxSec = 0;
|
||||
(activeTracks || []).forEach(function(tr) {
|
||||
@@ -4658,36 +4643,21 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
||||
return ghostLayers.filter(function(l) { return ghostTrackFilter.has(l.track_id); });
|
||||
}, [ghostLayers, ghostTrackFilter]);
|
||||
|
||||
const handleSwitchMidiItem = React.useCallback(function(itemId) {
|
||||
if (itemId === st.target_id) return;
|
||||
if (st.isDirty) {
|
||||
onSaveNotes(st.id, st.trackId, st.target_id, notes);
|
||||
}
|
||||
var match = allMidiItems.find(function(m) { return m.id === itemId; });
|
||||
if (!match) return;
|
||||
var trk = (activeTracks || []).find(function(t) { return t.id === match._trackId; });
|
||||
setSubTabs(function(prev) {
|
||||
return prev.map(function(s) {
|
||||
if (s.id !== st.id) return s;
|
||||
return Object.assign({}, s, {
|
||||
trackId: match._trackId,
|
||||
target_id: match.id,
|
||||
label: 'Piano Roll: ' + (match.name || 'MIDI'),
|
||||
notes: match.notes || [],
|
||||
duration: match.duration || 4,
|
||||
instrumentProgram: trk ? trk.instrumentProgram : undefined,
|
||||
instrumentName: trk ? trk.instrumentName : undefined,
|
||||
note_selection: [],
|
||||
currentTime: 0,
|
||||
isDirty: false
|
||||
});
|
||||
});
|
||||
});
|
||||
setSelectedNoteIds([]);
|
||||
setLoopStartBeat(null);
|
||||
setLoopEndBeat(null);
|
||||
}, [st.id, st.target_id, st.isDirty, allMidiItems, activeTracks, onSaveNotes, notes]);
|
||||
const totalBeats = sessionSyncMode ? Math.max(rollBeats, sessionLengthBars * 4 + 16, 64) : Math.max(rollBeats, noteMaxBeat + 16, 64);
|
||||
const drawWidth = totalBeats * pixelsPerBeat;
|
||||
const [rollViewWidth, setRollViewWidth] = React.useState(800);
|
||||
const viewWidth = Math.max(drawWidth, rollViewWidth);
|
||||
const viewBeats = Math.ceil(viewWidth / pixelsPerBeat) + 4;
|
||||
|
||||
const [notes, setNotes] = React.useState(st.notes || []);
|
||||
const notesRef = React.useRef(notes);
|
||||
notesRef.current = notes;
|
||||
React.useEffect(() => { if (!draggedNoteRef.current) setNotes(st.notes || []); }, [st.notes]);
|
||||
const brushVelocityRef = React.useRef(0.8);
|
||||
const [selectedNoteIds, setSelectedNoteIds] = React.useState([]);
|
||||
const [loopStartBeat, setLoopStartBeat] = React.useState(null);
|
||||
const [loopEndBeat, setLoopEndBeat] = React.useState(null);
|
||||
const [isLooping, setIsLooping] = React.useState(false);
|
||||
const rulerDragRef = React.useRef(null);
|
||||
React.useEffect(() => {
|
||||
const handler = (e) => {
|
||||
|
||||
Reference in New Issue
Block a user