From f5712816ac2cc2a1ab23377392bb16c0130f0f8f Mon Sep 17 00:00:00 2001 From: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> Date: Thu, 16 Nov 2023 17:13:06 +0530 Subject: [PATCH] Initital connect trigger --- .../Facility/Consultations/Feed.tsx | 35 +++++++++++-------- .../Facility/Consultations/LiveFeed.tsx | 15 +++++--- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/Components/Facility/Consultations/Feed.tsx b/src/Components/Facility/Consultations/Feed.tsx index 5f196c61353..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,20 +271,7 @@ 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); - } - }, - }); + startStreamFeed(); }, 5000); } else if (!statusReported) { triggerGoal("Camera Feed Viewed", { diff --git a/src/Components/Facility/Consultations/LiveFeed.tsx b/src/Components/Facility/Consultations/LiveFeed.tsx index 9dd84750587..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,10 +217,7 @@ const LiveFeed = (props: any) => { if (streamStatus !== StreamStatus.Playing) { setStreamStatus(StreamStatus.Loading); tId = setTimeout(() => { - startStream({ - onSuccess: () => setStreamStatus(StreamStatus.Playing), - onError: () => setStreamStatus(StreamStatus.Offline), - }); + startStreamFeed(); }, 5000); }