feat(camera): disable camera mode

This commit is contained in:
Christopher committed 2021-08-02 11:58:25 +02:00
1 parent 5dcb654516
commit 96aa7107ba
2 files changed
+14 -6

No files matched your search

@@ -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<boolean>(false);
const referal = query.referal ? decodeURIComponent(query.referal) : '/camera/image';
@@ -30,6 +31,7 @@ export const GalleryGrid = () => {
};
const handleTakePhoto = () => {
setIsLoading(true);
fetchNui<ServerPromiseResp<GalleryPhoto>>(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 = () => {
<div>
<Box display="flex" flexWrap="wrap" alignContent="flex-start" className={classes.root}>
<Box>
<Button onClick={handleTakePhoto} style={{ borderRadius: 0 }} className={classes.photo}>
<AddIcon fontSize="large" />
<Button
disabled={isLoading}
onClick={handleTakePhoto}
style={{ borderRadius: 0 }}
className={classes.photo}
>
{!isLoading ? <AddIcon fontSize="large" /> : <CircularProgress />}
</Button>
</Box>
{photos.map((photo) => (
+2 -2
View File
@@ -76,11 +76,11 @@ RegisterNuiCB<void>(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);