From 1e771e87af673b42c5679c911903d50cdada8fae Mon Sep 17 00:00:00 2001 From: Christopher Date: Sun, 7 Feb 2021 04:14:00 +0100 Subject: [PATCH] feat(photo/client|sever): fetch photo on upload --- resources/client/cl_photo.ts | 4 ++++ resources/server/sv_photo.ts | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/resources/client/cl_photo.ts b/resources/client/cl_photo.ts index 8652caf..6bc00e4 100644 --- a/resources/client/cl_photo.ts +++ b/resources/client/cl_photo.ts @@ -127,6 +127,10 @@ function takePhoto() { ); } +onNet(events.CAMERA_UPLOAD_PHOTO_SUCCESS, () => { + emitNet(events.CAMERA_FETCH_PHOTOS); +}) + // delete photo RegisterNuiCallbackType(events.CAMERA_DELETE_PHOTO); diff --git a/resources/server/sv_photo.ts b/resources/server/sv_photo.ts index 2314e7d..a98db9f 100644 --- a/resources/server/sv_photo.ts +++ b/resources/server/sv_photo.ts @@ -26,8 +26,14 @@ async function deletePhoto(photo: IPhoto, identifier: string) { } onNet(events.CAMERA_UPLOAD_PHOTO, async (image: string) => { - const identifier = await useIdentifier(); - await uploadPhoto(identifier, image); + try { + const pSource = (global as any).source; + const identifier = await useIdentifier(); + await uploadPhoto(identifier, image); + emitNet(events.CAMERA_UPLOAD_PHOTO_SUCCESS, pSource); + } catch (error) { + console.dir(error) + } }); onNet(events.CAMERA_FETCH_PHOTOS, async () => {