From c58de1777e8945a41b26690be3f73e055d19d143 Mon Sep 17 00:00:00 2001 From: Swanand Shekhar Bhuskute <103440604+SwanandBhuskute@users.noreply.github.com> Date: Fri, 29 Nov 2024 18:27:32 +0530 Subject: [PATCH] fixing back button for camera asset (#9246) --- src/components/CameraFeed/ConfigureCamera.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/CameraFeed/ConfigureCamera.tsx b/src/components/CameraFeed/ConfigureCamera.tsx index f969ed2b0ca..eec453053d6 100644 --- a/src/components/CameraFeed/ConfigureCamera.tsx +++ b/src/components/CameraFeed/ConfigureCamera.tsx @@ -89,16 +89,15 @@ export default function ConfigureCamera(props: Props) { const firstBedId = linkedAssetBeds?.[0]?.bed_object.id ?? unlinkedBeds?.[0]?.id; - useEffect(() => { - if (!query.bed && firstBedId) { - setQuery({ bed: firstBedId }); - } - }, [query.bed, firstBedId]); + + const selectedBedId = query.bed || firstBedId; const selectedAssetBed = linkedAssetBeds?.find( - (a) => a.bed_object.id === query.bed, + (a) => a.bed_object.id === selectedBedId, + ); + const selectedUnlinkedBed = unlinkedBeds?.find( + (bed) => bed.id === selectedBedId, ); - const selectedUnlinkedBed = unlinkedBeds?.find((bed) => bed.id === query.bed); const cameraPresetsQuery = useQuery(FeedRoutes.listAssetBedPresets, { pathParams: { assetbed_id: selectedAssetBed?.id ?? "" },