From 96aa7107ba811049cf3ff66fa2215dfcc1b561aa Mon Sep 17 00:00:00 2001 From: Christopher Date: Mon, 2 Aug 2021 11:58:25 +0200 Subject: [PATCH] feat(camera): disable camera mode --- .../apps/camera/components/grid/GalleryGrid.tsx | 16 ++++++++++++---- resources/client/cl_photo.ts | 4 ++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/phone/src/apps/camera/components/grid/GalleryGrid.tsx b/phone/src/apps/camera/components/grid/GalleryGrid.tsx index 5d6af3d..1d3f97e 100644 --- a/phone/src/apps/camera/components/grid/GalleryGrid.tsx +++ b/phone/src/apps/camera/components/grid/GalleryGrid.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { Box, Button } from '@material-ui/core'; +import React, { useState } from 'react'; +import { Box, Button, CircularProgress } from '@material-ui/core'; import useStyles from './grid.styles'; import AddIcon from '@material-ui/icons/Add'; import { useHistory } from 'react-router-dom'; @@ -22,6 +22,7 @@ export const GalleryGrid = () => { const { t } = useTranslation(); const photos = usePhotosValue(); const { takePhoto } = usePhotoActions(); + const [isLoading, setIsLoading] = useState(false); const referal = query.referal ? decodeURIComponent(query.referal) : '/camera/image'; @@ -30,6 +31,7 @@ export const GalleryGrid = () => { }; const handleTakePhoto = () => { + setIsLoading(true); fetchNui>(PhotoEvents.TAKE_PHOTO).then((serverResp) => { if (serverResp.status !== 'ok') { return addAlert({ @@ -39,6 +41,7 @@ export const GalleryGrid = () => { } takePhoto(serverResp.data); + setIsLoading(false); }); }; @@ -57,8 +60,13 @@ export const GalleryGrid = () => {
- {photos.map((photo) => ( diff --git a/resources/client/cl_photo.ts b/resources/client/cl_photo.ts index c7fd6fc..5497c83 100644 --- a/resources/client/cl_photo.ts +++ b/resources/client/cl_photo.ts @@ -76,11 +76,11 @@ RegisterNuiCB(PhotoEvents.TAKE_PHOTO, async (_, cb) => { const handleTakePicture = async () => { // Wait a frame so we don't draw the display helper text await Delay(0); - const resp = await takePhoto(); - await Delay(200); DestroyMobilePhone(); CellCamActivate(false, false); openPhoneTemp(); + const resp = await takePhoto(); + await Delay(200); inCameraMode = false; ClearHelp(true);