mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 16:39:06 +00:00
fix(webui): sync compare video pane resolution/source on asset change
currentResolution state and currentSrcRef were only initialized on mount, so if file.id changed without a remount the video.js init effect (keyed on file.id) would re-create the player with a stale source. Add an effect that resets them when file.id changes, before the init effect runs, making the pane robust even without a per-asset key on the parent.
This commit is contained in:
@@ -153,6 +153,15 @@ export const CompareVideoPane = forwardRef<ComparePaneHandle, CompareVideoPanePr
|
||||
}
|
||||
}, [containerSize.width, containerSize.height, vidW, vidH, hasManuallyZoomed])
|
||||
|
||||
// Keep the resolution selection and source url in sync when the displayed
|
||||
// asset changes, so the player (re)initializes with the correct source even
|
||||
// if the parent renders this pane without a per-asset `key`. Runs before the
|
||||
// video.js init effect below (declaration order) so the ref is fresh.
|
||||
useEffect(() => {
|
||||
setCurrentResolution(initialRes?.resolution ?? 'Original')
|
||||
currentSrcRef.current = initialRes?.url
|
||||
}, [file.id])
|
||||
|
||||
// Initialize video.js
|
||||
useEffect(() => {
|
||||
if (!videoContainerRef.current) return
|
||||
|
||||
Reference in New Issue
Block a user