refactor(events): Events are now tied to a common enum typings (#167)

* chore(scripts/twitter): Refactored twitter to use event enums

* chore(scripts/marketplace): Refactored marketplace to use event enums

* chore(scripts/messages): Refactored messages to use event enums

* chore(scripts/contacts): Refactored contacts to use event enums

* chore(scripts/calls): Refactored calls to use event enums

* chore(scripts/notes): Refactored notes to use event enums

* chore(scripts/photos): Refactored photos to use event enums

* chore(scripts/bank): Refactored bank to use event enums

* chore(scripts/phone): Refactored phone to use event enums

* chore(events): Removed old events object

* refactor(phone/nui-events): Attached NUI events to respective enum

* tweak(event-enums): Added npwd prefix to all events

* tweak(phone/serve): Added craco to override CRA without eject

Also bumped react-scripts to 4.0.1, with seemingly no issues

* fix(typings/twitter): Fixed method enums for twitter
This commit is contained in:
Taso authored and GitHub committed 2021-03-22 13:37:07 -04:00
1 parent 53d5bb459d
commit 0f61088999
62 files changed
+4734 -3470

No files matched your search

+7 -8
View File
@@ -1,7 +1,6 @@
import events from '../utils/events';
import { pool } from './db';
import { getIdentifier, getSource } from './functions';
import { IPhoto } from '../../typings/photo';
import { IPhoto, PhotoEvents } from '../../typings/photo';
import { mainLogger } from './sv_logger';
const photoLogger = mainLogger.child({ module: 'photo' });
@@ -22,12 +21,12 @@ async function deletePhoto(photo: IPhoto, identifier: string) {
await pool.query(query, [photo.image, identifier]);
}
onNet(events.CAMERA_UPLOAD_PHOTO, async (image: string) => {
onNet(PhotoEvents.UPLOAD_PHOTO, async (image: string) => {
const _source = getSource();
try {
const identifier = getIdentifier(_source);
await uploadPhoto(identifier, image);
emitNet(events.CAMERA_UPLOAD_PHOTO_SUCCESS, _source);
emitNet(PhotoEvents.UPLOAD_PHOTO_SUCCESS, _source);
} catch (e) {
photoLogger.error(`Failed to upload photo, ${e.message}`, {
source: _source,
@@ -35,12 +34,12 @@ onNet(events.CAMERA_UPLOAD_PHOTO, async (image: string) => {
}
});
onNet(events.CAMERA_FETCH_PHOTOS, async () => {
onNet(PhotoEvents.FETCH_PHOTOS, async () => {
const _source = getSource();
try {
const identifier = getIdentifier(_source);
const photos = await getPhotosByIdentifier(identifier);
emitNet(events.CAMERA_SEND_PHOTOS, _source, photos);
emitNet(PhotoEvents.SEND_PHOTOS, _source, photos);
} catch (e) {
photoLogger.error(`Failed to fetch photos, ${e.message}`, {
source: _source,
@@ -48,12 +47,12 @@ onNet(events.CAMERA_FETCH_PHOTOS, async () => {
}
});
onNet(events.CAMERA_DELETE_PHOTO, async (photo: IPhoto) => {
onNet(PhotoEvents.DELETE_PHOTO, async (photo: IPhoto) => {
const _source = getSource();
try {
const identifier = getIdentifier(_source);
await deletePhoto(photo, identifier);
emitNet(events.CAMERA_DELETE_PHOTO_SUCCESS, _source);
emitNet(PhotoEvents.DELETE_PHOTO_SUCCESS, _source);
} catch (e) {
photoLogger.error(`Failed to fetch photos, ${e.message}`, {
source: _source,