diff --git a/src/Components/Facility/Consultations/Feed.tsx b/src/Components/Facility/Consultations/Feed.tsx index ac39be325e9..25b656a0a79 100644 --- a/src/Components/Facility/Consultations/Feed.tsx +++ b/src/Components/Facility/Consultations/Feed.tsx @@ -230,8 +230,28 @@ export const Feed: React.FC = ({ consultationId, facilityId }) => { } }; + const startStreamFeed = () => { + startStream({ + onSuccess: () => setStreamStatus(StreamStatus.Playing), + onError: () => { + setStreamStatus(StreamStatus.Offline); + if (!statusReported) { + triggerGoal("Camera Feed Viewed", { + consultationId, + userId: authUser.id, + result: "error", + }); + setStatusReported(true); + } + }, + }); + }; + useEffect(() => { if (cameraAsset.id) { + setTimeout(() => { + startStreamFeed(); + }, 1000); getPresets({ onSuccess: (resp) => setPresets(resp), onError: (_) => { @@ -251,21 +271,8 @@ export const Feed: React.FC = ({ consultationId, facilityId }) => { setStreamStatus(StreamStatus.Loading); } tId = setTimeout(() => { - startStream({ - onSuccess: () => setStreamStatus(StreamStatus.Playing), - onError: () => { - setStreamStatus(StreamStatus.Offline); - if (!statusReported) { - triggerGoal("Camera Feed Viewed", { - consultationId, - userId: authUser.id, - result: "error", - }); - setStatusReported(true); - } - }, - }); - }, 100); + startStreamFeed(); + }, 5000); } else if (!statusReported) { triggerGoal("Camera Feed Viewed", { consultationId, diff --git a/src/Components/Facility/Consultations/LiveFeed.tsx b/src/Components/Facility/Consultations/LiveFeed.tsx index aba473e958d..cd3f055921e 100644 --- a/src/Components/Facility/Consultations/LiveFeed.tsx +++ b/src/Components/Facility/Consultations/LiveFeed.tsx @@ -177,6 +177,9 @@ const LiveFeed = (props: any) => { useEffect(() => { if (cameraAsset?.hostname) { fetchCameraPresets(); + setTimeout(() => { + startStreamFeed(); + }, 1000); } }, []); @@ -192,6 +195,13 @@ const LiveFeed = (props: any) => { } }, [page.offset, cameraAsset.id, refreshPresetsHash]); + const startStreamFeed = () => { + startStream({ + onSuccess: () => setStreamStatus(StreamStatus.Playing), + onError: () => setStreamStatus(StreamStatus.Offline), + }); + }; + const viewOptions = (page: number) => { return presets ? Object.entries(presets) @@ -207,11 +217,8 @@ const LiveFeed = (props: any) => { if (streamStatus !== StreamStatus.Playing) { setStreamStatus(StreamStatus.Loading); tId = setTimeout(() => { - startStream({ - onSuccess: () => setStreamStatus(StreamStatus.Playing), - onError: () => setStreamStatus(StreamStatus.Offline), - }); - }, 500); + startStreamFeed(); + }, 5000); } return () => {