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:
yiling
2026-07-04 15:29:07 +08:00
parent 0bbb846beb
commit ba88cdad78
@@ -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