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 React, { useState } from 'react';
import { Box, Button } from '@material-ui/core'; import { Box, Button, CircularProgress } from '@material-ui/core';
import useStyles from './grid.styles'; import useStyles from './grid.styles';
import AddIcon from '@material-ui/icons/Add'; import AddIcon from '@material-ui/icons/Add';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
@@ -22,6 +22,7 @@ export const GalleryGrid = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const photos = usePhotosValue(); const photos = usePhotosValue();
const { takePhoto } = usePhotoActions(); const { takePhoto } = usePhotoActions();
const [isLoading, setIsLoading] = useState<boolean>(false);
const referal = query.referal ? decodeURIComponent(query.referal) : '/camera/image'; const referal = query.referal ? decodeURIComponent(query.referal) : '/camera/image';
@@ -30,6 +31,7 @@ export const GalleryGrid = () => {
}; };
const handleTakePhoto = () => { const handleTakePhoto = () => {
setIsLoading(true);
fetchNui<ServerPromiseResp<GalleryPhoto>>(PhotoEvents.TAKE_PHOTO).then((serverResp) => { fetchNui<ServerPromiseResp<GalleryPhoto>>(PhotoEvents.TAKE_PHOTO).then((serverResp) => {
if (serverResp.status !== 'ok') { if (serverResp.status !== 'ok') {
return addAlert({ return addAlert({
@@ -39,6 +41,7 @@ export const GalleryGrid = () => {
} }
takePhoto(serverResp.data); takePhoto(serverResp.data);
setIsLoading(false);
}); });
}; };
@@ -57,8 +60,13 @@ export const GalleryGrid = () => {
<div> <div>
<Box display="flex" flexWrap="wrap" alignContent="flex-start" className={classes.root}> <Box display="flex" flexWrap="wrap" alignContent="flex-start" className={classes.root}>
<Box> <Box>
<Button onClick={handleTakePhoto} style={{ borderRadius: 0 }} className={classes.photo}> <Button
<AddIcon fontSize="large" /> disabled={isLoading}
onClick={handleTakePhoto}
style={{ borderRadius: 0 }}
className={classes.photo}
>
{!isLoading ? <AddIcon fontSize="large" /> : <CircularProgress />}
</Button> </Button>
</Box> </Box>
{photos.map((photo) => ( {photos.map((photo) => (
+2 -2
View File
@@ -76,11 +76,11 @@ RegisterNuiCB<void>(PhotoEvents.TAKE_PHOTO, async (_, cb) => {
const handleTakePicture = async () => { const handleTakePicture = async () => {
// Wait a frame so we don't draw the display helper text // Wait a frame so we don't draw the display helper text
await Delay(0); await Delay(0);
const resp = await takePhoto();
await Delay(200);
DestroyMobilePhone(); DestroyMobilePhone();
CellCamActivate(false, false); CellCamActivate(false, false);
openPhoneTemp(); openPhoneTemp();
const resp = await takePhoto();
await Delay(200);
inCameraMode = false; inCameraMode = false;
ClearHelp(true); ClearHelp(true);