mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
notes cleanup
This commit is contained in:
1 parent
6ee401e3d5
commit
8ff550cd6f
1 file changed
+5
-6
@@ -1,7 +1,7 @@
|
|||||||
import events from "../utils/events";
|
import events from "../utils/events";
|
||||||
import {pool} from "./db";
|
import {pool} from "./db";
|
||||||
import { useIdentifier, getSource } from "./functions";
|
import {getSource, useIdentifier} from "./functions";
|
||||||
import { Note, NoteId } from "../../phone/src/common/interfaces/notes";
|
import {Note, NoteId} from "../../phone/src/common/typings/notes";
|
||||||
|
|
||||||
async function addNote(identifier: string, note: Note): Promise<any> {
|
async function addNote(identifier: string, note: Note): Promise<any> {
|
||||||
const query =
|
const query =
|
||||||
@@ -13,8 +13,7 @@ async function fetchAllNotes(identifier: string): Promise<Note[]> {
|
|||||||
const query =
|
const query =
|
||||||
"SELECT * FROM npwd_notes WHERE identifier = ? ORDER BY id DESC";
|
"SELECT * FROM npwd_notes WHERE identifier = ? ORDER BY id DESC";
|
||||||
const [result] = await pool.query(query, [identifier]);
|
const [result] = await pool.query(query, [identifier]);
|
||||||
const notes = <Note[]>result;
|
return <Note[]>result;
|
||||||
return notes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteNote(noteId: number, identifier: string) {
|
async function deleteNote(noteId: number, identifier: string) {
|
||||||
@@ -31,7 +30,7 @@ async function updateNote(note: Note, identifier: string): Promise<any> {
|
|||||||
onNet(events.NOTE_ADD_NOTE, async (note: Note) => {
|
onNet(events.NOTE_ADD_NOTE, async (note: Note) => {
|
||||||
try {
|
try {
|
||||||
const _identifier = await useIdentifier();
|
const _identifier = await useIdentifier();
|
||||||
addNote(_identifier, note);
|
await addNote(_identifier, note);
|
||||||
emitNet(events.NOTE_SEND_NOTE_SUCCESS, getSource());
|
emitNet(events.NOTE_SEND_NOTE_SUCCESS, getSource());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("NOTES ERROR: ", error);
|
console.log("NOTES ERROR: ", error);
|
||||||
@@ -63,7 +62,7 @@ onNet(events.NOTE_UPDATE_NOTE, async (note: Note) => {
|
|||||||
const _source = (global as any).source;
|
const _source = (global as any).source;
|
||||||
try {
|
try {
|
||||||
const _identifier = await useIdentifier();
|
const _identifier = await useIdentifier();
|
||||||
updateNote(note, _identifier);
|
await updateNote(note, _identifier);
|
||||||
emitNet(events.NOTE_UPDATE_NOTE_SUCCESS, _source);
|
emitNet(events.NOTE_UPDATE_NOTE_SUCCESS, _source);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
emitNet(events.NOTE_UPDATE_NOTE_FAILURE, _source);
|
emitNet(events.NOTE_UPDATE_NOTE_FAILURE, _source);
|
||||||
|
|||||||
Reference in new issue
Block a user