diff --git a/phone/src/Phone.tsx b/phone/src/Phone.tsx
index d7ca21c..8469c0e 100644
--- a/phone/src/Phone.tsx
+++ b/phone/src/Phone.tsx
@@ -15,7 +15,6 @@ import { useMatchService } from './apps/match/hooks/useMatchService';
import { useMarketplaceService } from './apps/marketplace/hooks/useMarketplaceService';
import { useBankService } from './apps/bank/hooks/useBankService';
import { useMessagesService } from './apps/messages/hooks/useMessageService';
-import { usePhotoService } from './apps/camera/hooks/usePhotoService';
import { isSettingsSchemaValid, useSettings } from './apps/settings/hooks/useSettings';
import { useCallService } from './os/call/hooks/useCallService';
import { useDialService } from './apps/dialer/hooks/useDialService';
diff --git a/phone/src/apps/camera/components/CameraApp.tsx b/phone/src/apps/camera/components/CameraApp.tsx
index 3b7c1f0..7370a0c 100644
--- a/phone/src/apps/camera/components/CameraApp.tsx
+++ b/phone/src/apps/camera/components/CameraApp.tsx
@@ -3,41 +3,20 @@ import { AppWrapper } from '../../../ui/components';
import { AppContent } from '../../../ui/components/AppContent';
import { GalleryGrid } from './grid/GalleryGrid';
import { GalleryModal } from './modal/GalleryModal';
-import InjectDebugData from '../../../os/debug/InjectDebugData';
import { Route, Switch } from 'react-router-dom';
-import { PhotoEvents } from '../../../../../typings/photo';
import { LoadingSpinner } from '../../../ui/components/LoadingSpinner';
-InjectDebugData([
- {
- app: 'CAMERA',
- method: PhotoEvents.SEND_PHOTOS,
- data: [
- {
- id: 1,
- image: 'https://i.file.glass/noDcb.jpeg',
- },
- {
- id: 2,
- image: 'https://i.file.glass/teUcY.jpeg',
- },
- ],
- },
-]);
-
-const CameraApp = () => {
- return (
-
-
-
- }>
-
-
-
-
-
-
- );
-};
+const CameraApp: React.FC = () => (
+
+
+
+ }>
+
+
+
+
+
+
+);
export default CameraApp;
diff --git a/phone/src/apps/camera/components/grid/GalleryGrid.tsx b/phone/src/apps/camera/components/grid/GalleryGrid.tsx
index 907196a..5d6af3d 100644
--- a/phone/src/apps/camera/components/grid/GalleryGrid.tsx
+++ b/phone/src/apps/camera/components/grid/GalleryGrid.tsx
@@ -1,7 +1,6 @@
import React from 'react';
-import { Box, Button, CircularProgress } from '@material-ui/core';
+import { Box, Button } from '@material-ui/core';
import useStyles from './grid.styles';
-import { useCamera } from '../../hooks/useCamera';
import AddIcon from '@material-ui/icons/Add';
import { useHistory } from 'react-router-dom';
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
diff --git a/phone/src/apps/camera/hooks/usePhotoActions.ts b/phone/src/apps/camera/hooks/usePhotoActions.ts
index 4d3e15d..e384cdb 100644
--- a/phone/src/apps/camera/hooks/usePhotoActions.ts
+++ b/phone/src/apps/camera/hooks/usePhotoActions.ts
@@ -1,8 +1,8 @@
-import { usePhotos } from './state';
+import { useSetPhotos } from './state';
import { useCallback } from 'react';
export const usePhotoActions = () => {
- const [photos, setPhotos] = usePhotos();
+ const setPhotos = useSetPhotos();
const takePhoto = useCallback(
(photo) => {
@@ -18,49 +18,5 @@ export const usePhotoActions = () => {
[setPhotos],
);
- return {
- takePhoto,
- deletePhoto,
- };
-
- /*const { t } = useTranslation();
- const { addAlert } = useSnackbar();
-
- const [photos, setPhotos] = usePhotoService();
- const [isUploading, setUploading] = useState(false);*/
- /*
- const onPhotoSuccess = useCallback(
- (photo) => {
- setUploading(false);
- if (!photo?.image) return;
- setPhotos((curr) => [photo, ...curr]);
- },
- [setPhotos],
- );
-
- const onPhotoError = useCallback(
- (i18nKey) => {
- setUploading(false);
- addAlert({ type: 'error', message: t(i18nKey) });
- },
- [addAlert, t],
- );
-
- const [_takePhoto] = useNuiCallback(
- 'CAMERA',
- PhotoEvents.TAKE_PHOTO,
- onPhotoSuccess,
- onPhotoError,
- );
-
- const takePhoto = () => {
- _takePhoto(undefined, { timeout: 60000 });
- };
-
- return {
- photos,
- setPhotos,
- takePhoto,
- isLoading: isUploading,
- };*/
+ return { takePhoto, deletePhoto };
};
diff --git a/phone/src/apps/camera/hooks/usePhotoService.ts b/phone/src/apps/camera/hooks/usePhotoService.ts
deleted file mode 100644
index ff07afe..0000000
--- a/phone/src/apps/camera/hooks/usePhotoService.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { useSetRecoilState } from 'recoil';
-import { useNuiEvent } from 'fivem-nui-react-lib';
-import { photoState } from './state';
-import { PhotoEvents } from '../../../../../typings/photo';
-
-export const usePhotoService = () => {
- const setPhotos = useSetRecoilState(photoState.photos);
- useNuiEvent('CAMERA', PhotoEvents.SEND_PHOTOS, setPhotos);
-};
diff --git a/resources/client/cl_photo.ts b/resources/client/cl_photo.ts
index 778213d..c7fd6fc 100644
--- a/resources/client/cl_photo.ts
+++ b/resources/client/cl_photo.ts
@@ -1,10 +1,10 @@
-import { GalleryPhoto, PhotoEvents } from '../../typings/photo';
+import { PhotoEvents } from '../../typings/photo';
import { Delay } from '../utils/fivem';
import { sendCameraEvent, sendMessage } from '../utils/messages';
import { PhoneEvents } from '../../typings/phone';
import { ClUtils } from './client';
import { animationService } from './animations/animation.controller';
-import { RegisterNuiProxy } from './cl_utils';
+import { RegisterNuiCB, RegisterNuiProxy } from './cl_utils';
const SCREENSHOT_BASIC_TOKEN = GetConvar('SCREENSHOT_BASIC_TOKEN', 'none');
@@ -33,9 +33,7 @@ const displayHelperText = () => {
EndTextCommandDisplayHelp(0, true, false, -1);
};
-RegisterNuiCallbackType(PhotoEvents.TAKE_PHOTO);
-on(`__cfx_nui:${PhotoEvents.TAKE_PHOTO}`, async (data: any, cb: Function) => {
- /*cb();*/
+RegisterNuiCB(PhotoEvents.TAKE_PHOTO, async (_, cb) => {
await animationService.openCamera();
emit('npwd:disableControlActions', false);
// Create Phone Prop
@@ -56,9 +54,14 @@ on(`__cfx_nui:${PhotoEvents.TAKE_PHOTO}`, async (data: any, cb: Function) => {
frontCam = !frontCam;
CellFrontCamActivate(frontCam);
} else if (IsControlJustPressed(1, 176)) {
- const resp = await handleTakePicture();
-
- cb(resp);
+ if (SCREENSHOT_BASIC_TOKEN !== 'none') {
+ const resp = await handleTakePicture();
+ cb(resp);
+ break;
+ }
+ console.error(
+ 'You may be trying to take a photo, but your token is not setup for upload! See NPWD Docs for more info!',
+ );
} else if (IsControlJustPressed(1, 177)) {
handleCameraExit();
break;
@@ -79,11 +82,15 @@ const handleTakePicture = async () => {
CellCamActivate(false, false);
openPhoneTemp();
inCameraMode = false;
+ ClearHelp(true);
return resp;
};
-const handleCameraExit = () => {
+const handleCameraExit = async () => {
+ ClearHelp(true);
+ animationService.closeCamera();
+ emit('npwd:disableControlActions', true);
DestroyMobilePhone();
CellCamActivate(false, false);
openPhoneTemp();
@@ -91,10 +98,6 @@ const handleCameraExit = () => {
inCameraMode = false;
};
-onNet(PhotoEvents.SEND_PHOTOS, (photos: string[]) => {
- sendCameraEvent(PhotoEvents.SEND_PHOTOS, photos);
-});
-
const takePhoto = () =>
new Promise((res, rej) => {
// Return and log error if screenshot basic token not found
@@ -113,7 +116,6 @@ const takePhoto = () =>
async (data: any) => {
try {
const imageLink = JSON.parse(data).data.link;
-
const resp = await ClUtils.emitNetPromise(PhotoEvents.UPLOAD_PHOTO, imageLink);
console.log('export shit', resp);
res(resp);
@@ -125,11 +127,4 @@ const takePhoto = () =>
});
RegisterNuiProxy(PhotoEvents.FETCH_PHOTOS);
-
-RegisterNuiCallbackType(PhotoEvents.DELETE_PHOTO);
-on(`__cfx_nui:${PhotoEvents.DELETE_PHOTO}`, async (data: GalleryPhoto, cb: Function) => {
- console.log('my data', data);
- /*emitNet(PhotoEvents.DELETE_PHOTO, data);*/
- const resp = await ClUtils.emitNetPromise(PhotoEvents.DELETE_PHOTO, data);
- cb(resp);
-});
+RegisterNuiProxy(PhotoEvents.DELETE_PHOTO);
diff --git a/resources/server/photo/photo.controller.ts b/resources/server/photo/photo.controller.ts
index d636580..a48c27a 100644
--- a/resources/server/photo/photo.controller.ts
+++ b/resources/server/photo/photo.controller.ts
@@ -1,16 +1,8 @@
-import { getSource } from '../utils/miscUtils';
import { GalleryPhoto, PhotoEvents } from '../../../typings/photo';
import PhotoService from './photo.service';
import { photoLogger } from './photo.utils';
import { onNetPromise } from '../utils/PromiseNetEvents/onNetPromise';
-/*onNet(PhotoEvents.UPLOAD_PHOTO, async (image: string) => {
- const src = getSource();
- PhotoService.handleUploadPhoto(src, image).catch((e) =>
- photoLogger.error(`Error occurred in upload photo event (${src}), Error: ${e.message}`),
- );
-});*/
-
onNetPromise(PhotoEvents.UPLOAD_PHOTO, (reqObj, resp) => {
PhotoService.handleUploadPhoto(reqObj, resp).catch((e) => {
photoLogger.error(
@@ -29,13 +21,6 @@ onNetPromise(PhotoEvents.FETCH_PHOTOS, (reqObj, resp) => {
});
});
-/*onNet(PhotoEvents.FETCH_PHOTOS, async () => {
- const src = getSource();
- PhotoService.handleFetchPhotos(src).catch((e) =>
- photoLogger.error(`Error occurred in upload photo event (${src}), Error: ${e.message}`),
- );
-});*/
-
onNetPromise(PhotoEvents.DELETE_PHOTO, (reqObj, resp) => {
PhotoService.handleDeletePhoto(reqObj, resp).catch((e) => {
photoLogger.error(
@@ -44,10 +29,3 @@ onNetPromise(PhotoEvents.DELETE_PHOTO, (reqObj, resp) => {
resp({ status: 'error', errorMsg: 'INTERNAL_ERROR' });
});
});
-
-/*onNet(PhotoEvents.DELETE_PHOTO, async (photo: GalleryPhoto) => {
- const src = getSource();
- PhotoService.handleDeletePhoto(src, photo).catch((e) =>
- photoLogger.error(`Error occurred in delete photo event (${src}), Error: ${e.message}`),
- );
-});*/
diff --git a/resources/server/photo/photo.service.ts b/resources/server/photo/photo.service.ts
index af17e05..8a38abd 100644
--- a/resources/server/photo/photo.service.ts
+++ b/resources/server/photo/photo.service.ts
@@ -1,5 +1,5 @@
import PlayerService from '../players/player.service';
-import { GalleryPhoto, PhotoEvents } from '../../../typings/photo';
+import { GalleryPhoto } from '../../../typings/photo';
import PhotoDB, { _PhotoDB } from './photo.db';
import { photoLogger } from './photo.utils';
import { PromiseEventResp, PromiseRequest } from '../utils/PromiseNetEvents/promise.types';
diff --git a/typings/photo.ts b/typings/photo.ts
index d4d1f03..410c4f9 100644
--- a/typings/photo.ts
+++ b/typings/photo.ts
@@ -6,11 +6,7 @@ export interface GalleryPhoto {
export enum PhotoEvents {
TAKE_PHOTO = 'npwd:TakePhoto',
TAKE_PHOTO_SUCCESS = 'npwd:TakePhotoSuccess',
- TAKE_PHOTO_ERROR = 'npwd:TakePhotoError',
UPLOAD_PHOTO = 'npwd:UploadPhoto',
- UPLOAD_PHOTO_SUCCESS = 'npwd:UploadPhotoSuccess',
FETCH_PHOTOS = 'npwd:FetchPhotos',
- SEND_PHOTOS = 'npwd:SendPhotos',
DELETE_PHOTO = 'npwd:deletePhoto',
- DELETE_PHOTO_SUCCESS = 'npwd:deletePhotoSuccess',
}