mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
cleanup(photos): A general cleanup of photos
Removes legacy code no longer in use or cleans up code to use new type safe native wrappers
This commit is contained in:
1 parent
83ec915926
commit
16626db5bd
9 files changed
+34
-141
No files matched your search
@@ -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<void>(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);
|
||||
Reference in new issue
Block a user