mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-15 00:11:15 +03:00
skip unnecessary MSEPlayer remount on initial render
se a previous-value ref for the streamName effect in LivePlayer to avoid a wasted WebSocket connect/disconnect cycle
This commit is contained in:
parent
f3a9bf7763
commit
fa7858a1c9
@ -195,6 +195,7 @@ export default function LivePlayer({
|
|||||||
}, [preferredLiveMode]);
|
}, [preferredLiveMode]);
|
||||||
|
|
||||||
const [key, setKey] = useState(0);
|
const [key, setKey] = useState(0);
|
||||||
|
const prevStreamNameRef = useRef(streamName);
|
||||||
|
|
||||||
const resetPlayer = () => {
|
const resetPlayer = () => {
|
||||||
setLiveReady(false);
|
setLiveReady(false);
|
||||||
@ -202,8 +203,11 @@ export default function LivePlayer({
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (streamName) {
|
if (prevStreamNameRef.current !== streamName) {
|
||||||
resetPlayer();
|
prevStreamNameRef.current = streamName;
|
||||||
|
if (streamName) {
|
||||||
|
resetPlayer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [streamName]);
|
}, [streamName]);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user