mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-02 22:17:39 +00:00
Also trying something out with the response structure on the server to cut down on redundant calls.
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { Note, NotesEvents } from '../../../typings/notes';
|
|
import { getSource } from '../utils/miscUtils';
|
|
import NotesService from './notes.service';
|
|
import { notesLogger } from './notes.utils';
|
|
|
|
onNet(NotesEvents.ADD_NOTE, (note: Note) => {
|
|
const src = getSource();
|
|
NotesService.handleAddNote(src, note).catch((e) =>
|
|
notesLogger.error(`Error occured in add note event (${src}), Error: ${e.message}`),
|
|
);
|
|
});
|
|
|
|
onNet(NotesEvents.FETCH_ALL_NOTES, async (limit?: number) => {
|
|
const src = getSource();
|
|
NotesService.handleFetchNotes(src, limit).catch((e) =>
|
|
notesLogger.error(`Error occured in fetch note event (${src}), Error: ${e.message}`),
|
|
);
|
|
});
|
|
|
|
onNet(NotesEvents.DELETE_NOTE, async (noteId: number) => {
|
|
const src = getSource();
|
|
NotesService.handleDeleteNote(src, noteId).catch((e) =>
|
|
notesLogger.error(`Error occured in delete note event (${src}), Error: ${e.message}`),
|
|
);
|
|
});
|
|
|
|
onNet(NotesEvents.UPDATE_NOTE, async (note: Note) => {
|
|
const src = getSource();
|
|
NotesService.handleUpdateNote(src, note).catch((e) =>
|
|
notesLogger.error(`Error occured in fetch note event (${src}), Error: ${e.message}`),
|
|
);
|
|
});
|