mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
feat(camera): refactor to new promise event format
This commit is contained in:
1 parent
1566bb0fdb
commit
4e8c57492b
15 files changed
+274
-141
No files matched your search
@@ -2,24 +2,52 @@ 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) => {
|
||||
/*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<string, GalleryPhoto>(PhotoEvents.UPLOAD_PHOTO, (reqObj, resp) => {
|
||||
PhotoService.handleUploadPhoto(reqObj, resp).catch((e) => {
|
||||
photoLogger.error(
|
||||
`Error occurred in upload photo event (${reqObj.source}), Error: ${e.message}`,
|
||||
);
|
||||
resp({ status: 'error', errorMsg: 'INTERNAL_ERROR' });
|
||||
});
|
||||
});
|
||||
|
||||
onNet(PhotoEvents.FETCH_PHOTOS, async () => {
|
||||
onNetPromise<void, GalleryPhoto[]>(PhotoEvents.FETCH_PHOTOS, (reqObj, resp) => {
|
||||
PhotoService.handleFetchPhotos(reqObj, resp).catch((e) => {
|
||||
photoLogger.error(
|
||||
`Error occurred in upload photo event (${reqObj.source}), Error: ${e.message}`,
|
||||
);
|
||||
resp({ status: 'error', errorMsg: 'INTERNAL_ERROR' });
|
||||
});
|
||||
});
|
||||
|
||||
/*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<GalleryPhoto, void>(PhotoEvents.DELETE_PHOTO, (reqObj, resp) => {
|
||||
PhotoService.handleDeletePhoto(reqObj, resp).catch((e) => {
|
||||
photoLogger.error(
|
||||
`Error occurred in delete photo event (${reqObj.source}), Error: ${e.message}`,
|
||||
);
|
||||
resp({ status: 'error', errorMsg: 'INTERNAL_ERROR' });
|
||||
});
|
||||
});
|
||||
|
||||
onNet(PhotoEvents.DELETE_PHOTO, async (photo: GalleryPhoto) => {
|
||||
/*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}`),
|
||||
);
|
||||
});
|
||||
});*/
|
||||
Reference in new issue
Block a user