From cea3b08999a940420edb395024527bbcc73b7f82 Mon Sep 17 00:00:00 2001 From: locphamtran Date: Mon, 24 Aug 2026 18:02:09 +0700 Subject: [PATCH] fix(ui): move loop-selection effects after state init (TDZ crash -> black screen) --- app/static/js/app.jsx | 2 +- app/static/js/app.precompiled.js | 4 ++-- app/templates/index.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/static/js/app.jsx b/app/static/js/app.jsx index d06dc1e..87bbf61 100644 --- a/app/static/js/app.jsx +++ b/app/static/js/app.jsx @@ -17784,6 +17784,7 @@ const App = () => { // timeline thu nhỏ ở góc — user phải zoom in mới về đúng). 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. @@ -17792,7 +17793,6 @@ const App = () => { 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); diff --git a/app/static/js/app.precompiled.js b/app/static/js/app.precompiled.js index 2908752..b00d42c 100644 --- a/app/static/js/app.precompiled.js +++ b/app/static/js/app.precompiled.js @@ -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 diff --git a/app/templates/index.html b/app/templates/index.html index 36f0412..689a3c5 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -51,7 +51,7 @@ - +