fix(ui): move loop-selection effects after state init (TDZ crash -> black screen)

This commit is contained in:
2026-08-24 18:02:09 +07:00
parent 51e62a1158
commit cea3b08999
3 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -1130,10 +1130,10 @@ const handleSectionItemDragStartRef=useRef(null);const[localSelectionTrackId,set
try{const v=parseFloat(localStorage.getItem('sf_zoom'));if(isFinite(v)&&v>0)return v;}catch(e){}return 100;});React.useEffect(()=>{try{localStorage.setItem('sf_zoom',String(zoom));}catch(e){}// Zoom TIMELINE (App) — serialize project dùng cái này (window.__currentZoom
// là zoom của Media Explorer — lưu nhầm làm project load ra zoom 1.0 →
// timeline thu nhỏ ở góc — user phải zoom in mới về đúng).
window.__sfTimelineZoom=zoom;},[zoom]);// Persist transport loop selection qua save/reload — serialize đọc từ window
window.__sfTimelineZoom=zoom;},[zoom]);const[isLoopingSelection,setIsLoopingSelection]=useState(false);// Persist transport loop selection qua save/reload — serialize đọc từ window
// refs (module-level không truy cập state). Lưu cả vùng chọn (giây) để loop
// vùng chọn hoạt động lại đúng sau khi mở project.
React.useEffect(()=>{window.__sfLoopSelection=isLoopingSelection;},[isLoopingSelection]);React.useEffect(()=>{window.__sfSelectionStart=selectionStart;window.__sfSelectionEnd=selectionEnd;},[selectionStart,selectionEnd]);const[isLoopingSelection,setIsLoopingSelection]=useState(false);const[beginBar,setBeginBar]=useState(0);const[endBar,setEndBar]=useState(0);const[numberBar,setNumberBar]=useState(1);// Quét chọn (sweep — tempo track/timeline) → đồng bộ bars hiển thị dưới
React.useEffect(()=>{window.__sfLoopSelection=isLoopingSelection;},[isLoopingSelection]);React.useEffect(()=>{window.__sfSelectionStart=selectionStart;window.__sfSelectionEnd=selectionEnd;},[selectionStart,selectionEnd]);const[beginBar,setBeginBar]=useState(0);const[endBar,setEndBar]=useState(0);const[numberBar,setNumberBar]=useState(1);// Quét chọn (sweep — tempo track/timeline) → đồng bộ bars hiển thị dưới
// statusbar: beginBar = bar chứa selectionStart, endBar = bar chứa
// selectionEnd, numberBar = số bar được chọn. Trước đây beginBar/endBar/
// numberBar CHỈ đổi khi nhập tay input — quét không cập nhật → statusbar