Skip to content

Commit

Permalink
Merge branch 'coronasafe:develop' into Fix#6372-new
Browse files Browse the repository at this point in the history
  • Loading branch information
AshrafMd-1 authored Nov 16, 2023
2 parents a19f10b + 43d08e1 commit 32b8660
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
37 changes: 22 additions & 15 deletions src/Components/Facility/Consultations/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,28 @@ export const Feed: React.FC<IFeedProps> = ({ 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: (_) => {
Expand All @@ -243,21 +263,8 @@ export const Feed: React.FC<IFeedProps> = ({ 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,
Expand Down
17 changes: 12 additions & 5 deletions src/Components/Facility/Consultations/LiveFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ const LiveFeed = (props: any) => {
useEffect(() => {
if (cameraAsset?.hostname) {
fetchCameraPresets();
setTimeout(() => {
startStreamFeed();
}, 1000);
}
}, []);

Expand All @@ -189,6 +192,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)
Expand All @@ -204,11 +214,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 () => {
Expand Down

0 comments on commit 32b8660

Please sign in to comment.