fix(server/notes): Temporarily use old resp format

This commit is contained in:
Taso committed 2021-04-18 15:38:51 -04:00
1 parent 635dc907ce
commit 8af7530f18
2 files changed
+43 -71

No files matched your search

+10 -18
View File
@@ -1,4 +1,4 @@
import { Note, NoteServerResponse, NotesEvents } from '../../typings/notes';
import { Note, NotesEvents } from '../../typings/notes';
import { sendNotesEvent } from '../utils/messages';
onNet(NotesEvents.SEND_NOTE, (notes: any) => {
@@ -20,22 +20,14 @@ on(`__cfx_nui:${NotesEvents.UPDATE_NOTE}`, (note: Note) => {
emitNet(NotesEvents.UPDATE_NOTE, note);
});
// Trying out this response structure
onNet(
NotesEvents.SERVER_RESP,
({ alert, action, suceeded, refetch, data }: NoteServerResponse<Note[] | Note>) => {
if (alert) {
sendNotesEvent(NotesEvents.SEND_ALERT, alert);
}
onNet(NotesEvents.UPDATE_NOTE_SUCCESS, () => {
emitNet(NotesEvents.FETCH_ALL_NOTES);
});
switch (action) {
case 'SEND':
sendNotesEvent(NotesEvents.SEND_NOTE, data);
break;
}
onNet(NotesEvents.ACTION_RESULT, (alert: any) => {
sendNotesEvent(NotesEvents.SEND_ALERT, alert);
});
if (refetch && suceeded) {
emitNet(NotesEvents.FETCH_ALL_NOTES);
}
},
);
onNet(NotesEvents.DELETE_NOTE_SUCCESS, () => {
emitNet(NotesEvents.FETCH_ALL_NOTES);
});