mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
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:
62 files changed
+4734
-3470
No files matched your search
@@ -1,7 +1,6 @@
|
||||
import events from '../utils/events';
|
||||
import { pool } from './db';
|
||||
import { getIdentifier, getSource } from './functions';
|
||||
import { Note, NoteId } from '../../typings/notes';
|
||||
import { Note, NoteId, NotesEvents } from '../../typings/notes';
|
||||
import { mainLogger } from './sv_logger';
|
||||
|
||||
const notesLogger = mainLogger.child({ module: 'notes' });
|
||||
@@ -27,13 +26,13 @@ async function updateNote(note: Note, identifier: string): Promise<any> {
|
||||
await pool.query(query, [note.title, note.content, note.id, identifier]);
|
||||
}
|
||||
|
||||
onNet(events.NOTE_ADD_NOTE, async (note: Note) => {
|
||||
onNet(NotesEvents.ADD_NOTE, async (note: Note) => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const _identifier = getIdentifier(pSource);
|
||||
await addNote(_identifier, note);
|
||||
emitNet(events.NOTE_SEND_NOTE_SUCCESS, pSource);
|
||||
emitNet(events.NOTE_ACTION_RESULT, pSource, {
|
||||
emitNet(NotesEvents.SEND_NOTE_SUCCESS, pSource);
|
||||
emitNet(NotesEvents.ACTION_RESULT, pSource, {
|
||||
message: 'NOTES_ADD_SUCCESS',
|
||||
type: 'success',
|
||||
});
|
||||
@@ -41,19 +40,19 @@ onNet(events.NOTE_ADD_NOTE, async (note: Note) => {
|
||||
notesLogger.error(`Failed to add note ${e.message}`, {
|
||||
source: pSource,
|
||||
});
|
||||
emitNet(events.NOTE_ACTION_RESULT, pSource, {
|
||||
emitNet(NotesEvents.ACTION_RESULT, pSource, {
|
||||
message: 'NOTES_ADD_FAILED',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.NOTE_FETCH_ALL_NOTES, async () => {
|
||||
onNet(NotesEvents.FETCH_ALL_NOTES, async () => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const _identifier = getIdentifier(pSource);
|
||||
const notes = await fetchAllNotes(_identifier);
|
||||
emitNet(events.NOTE_SEND_NOTE, pSource, notes);
|
||||
emitNet(NotesEvents.SEND_NOTE, pSource, notes);
|
||||
} catch (e) {
|
||||
notesLogger.error(`Failed to fetch notes ${e.message}`, {
|
||||
source: pSource,
|
||||
@@ -61,45 +60,45 @@ onNet(events.NOTE_FETCH_ALL_NOTES, async () => {
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.NOTE_DELETE_NOTE, async (noteId: NoteId) => {
|
||||
onNet(NotesEvents.DELETE_NOTE, async (noteId: NoteId) => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const _identifier = getIdentifier(pSource);
|
||||
await deleteNote(noteId.id, _identifier);
|
||||
|
||||
emitNet(events.NOTE_DELETE_NOTE_SUCCESS, pSource);
|
||||
emitNet(NotesEvents.DELETE_NOTE_SUCCESS, pSource);
|
||||
|
||||
emitNet(events.NOTE_ACTION_RESULT, pSource, {
|
||||
emitNet(NotesEvents.ACTION_RESULT, pSource, {
|
||||
message: 'NOTES_DELETE_SUCCESS',
|
||||
type: 'success',
|
||||
});
|
||||
} catch (e) {
|
||||
const pSource = (global as any).source;
|
||||
notesLogger.error(`Failed to delete note, ${e.message}`);
|
||||
emitNet(events.NOTE_ACTION_RESULT, pSource, {
|
||||
emitNet(NotesEvents.ACTION_RESULT, pSource, {
|
||||
message: 'NOTES_DELETE_FAILED',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.NOTE_UPDATE_NOTE, async (note: Note) => {
|
||||
onNet(NotesEvents.UPDATE_NOTE, async (note: Note) => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const _identifier = getIdentifier(pSource);
|
||||
await updateNote(note, _identifier);
|
||||
emitNet(events.NOTE_UPDATE_NOTE_SUCCESS, pSource);
|
||||
emitNet(NotesEvents.UPDATE_NOTE_SUCCESS, pSource);
|
||||
|
||||
emitNet(events.NOTE_ACTION_RESULT, pSource, {
|
||||
emitNet(NotesEvents.ACTION_RESULT, pSource, {
|
||||
message: 'NOTES_UPDATE_SUCCESS',
|
||||
type: 'success',
|
||||
});
|
||||
} catch (e) {
|
||||
emitNet(events.NOTE_UPDATE_NOTE_FAILURE, pSource);
|
||||
emitNet(NotesEvents.UPDATE_NOTE_FAILURE, pSource);
|
||||
notesLogger.error(`Failed to update note, ${e.message}`, {
|
||||
source: pSource,
|
||||
});
|
||||
emitNet(events.NOTE_ACTION_RESULT, pSource, {
|
||||
emitNet(NotesEvents.ACTION_RESULT, pSource, {
|
||||
message: 'NOTES_UPDATE_FAILED',
|
||||
type: 'error',
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user