mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 01:35:22 +03:00
Wait until camera source is loaded to avoid race condition
This commit is contained in:
parent
df81ccf505
commit
2a2adfaf20
@ -28,8 +28,8 @@ export default function Camera({ camera }) {
|
|||||||
const jsmpegWidth = cameraConfig
|
const jsmpegWidth = cameraConfig
|
||||||
? Math.round(cameraConfig.restream.jsmpeg.height * (cameraConfig.detect.width / cameraConfig.detect.height))
|
? Math.round(cameraConfig.restream.jsmpeg.height * (cameraConfig.detect.width / cameraConfig.detect.height))
|
||||||
: 0;
|
: 0;
|
||||||
const [viewSource, setViewSource] = usePersistence(`${camera}-source`, undefined);
|
const [viewSource, setViewSource, sourceIsLoaded] = usePersistence(`${camera}-source`, 'jsmpeg');
|
||||||
const sourceValues = (cameraConfig && cameraConfig.restream.enabled) ? ['jsmpeg', 'mp4', 'webrtc'] : ['jsmpeg'];
|
const sourceValues = cameraConfig && cameraConfig.restream.enabled ? ['jsmpeg', 'mp4', 'webrtc'] : ['jsmpeg'];
|
||||||
const [options, setOptions] = usePersistence(`${camera}-feed`, emptyObject);
|
const [options, setOptions] = usePersistence(`${camera}-feed`, emptyObject);
|
||||||
|
|
||||||
const handleSetOption = useCallback(
|
const handleSetOption = useCallback(
|
||||||
@ -55,7 +55,7 @@ export default function Camera({ camera }) {
|
|||||||
setShowSettings(!showSettings);
|
setShowSettings(!showSettings);
|
||||||
}, [showSettings, setShowSettings]);
|
}, [showSettings, setShowSettings]);
|
||||||
|
|
||||||
if (!cameraConfig) {
|
if (!cameraConfig || !sourceIsLoaded) {
|
||||||
return <ActivityIndicator />;
|
return <ActivityIndicator />;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,8 +158,10 @@ export default function Camera({ camera }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4 p-2 px-4">
|
<div className="space-y-4 p-2 px-4">
|
||||||
<div className='flex justify-between'>
|
<div className="flex justify-between">
|
||||||
<Heading className='p-2' size="2xl">{camera.replaceAll('_', ' ')}</Heading>
|
<Heading className="p-2" size="2xl">
|
||||||
|
{camera.replaceAll('_', ' ')}
|
||||||
|
</Heading>
|
||||||
<select
|
<select
|
||||||
className="basis-1/8 cursor-pointer rounded dark:bg-slate-800"
|
className="basis-1/8 cursor-pointer rounded dark:bg-slate-800"
|
||||||
value={viewSource}
|
value={viewSource}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user