From 8ff550cd6fa919812cd2337d2ffdfd834ca4212a Mon Sep 17 00:00:00 2001 From: Christopher Date: Sun, 3 Jan 2021 21:42:33 +0100 Subject: [PATCH] notes cleanup --- resources/server/sv_notes.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/resources/server/sv_notes.ts b/resources/server/sv_notes.ts index ac6d6e2..dc8b4c8 100644 --- a/resources/server/sv_notes.ts +++ b/resources/server/sv_notes.ts @@ -1,7 +1,7 @@ import events from "../utils/events"; -import { pool } from "./db"; -import { useIdentifier, getSource } from "./functions"; -import { Note, NoteId } from "../../phone/src/common/interfaces/notes"; +import {pool} from "./db"; +import {getSource, useIdentifier} from "./functions"; +import {Note, NoteId} from "../../phone/src/common/typings/notes"; async function addNote(identifier: string, note: Note): Promise { const query = @@ -13,8 +13,7 @@ async function fetchAllNotes(identifier: string): Promise { const query = "SELECT * FROM npwd_notes WHERE identifier = ? ORDER BY id DESC"; const [result] = await pool.query(query, [identifier]); - const notes = result; - return notes; + return result; } async function deleteNote(noteId: number, identifier: string) { @@ -31,7 +30,7 @@ async function updateNote(note: Note, identifier: string): Promise { onNet(events.NOTE_ADD_NOTE, async (note: Note) => { try { const _identifier = await useIdentifier(); - addNote(_identifier, note); + await addNote(_identifier, note); emitNet(events.NOTE_SEND_NOTE_SUCCESS, getSource()); } catch (error) { console.log("NOTES ERROR: ", error); @@ -63,7 +62,7 @@ onNet(events.NOTE_UPDATE_NOTE, async (note: Note) => { const _source = (global as any).source; try { const _identifier = await useIdentifier(); - updateNote(note, _identifier); + await updateNote(note, _identifier); emitNet(events.NOTE_UPDATE_NOTE_SUCCESS, _source); } catch (error) { emitNet(events.NOTE_UPDATE_NOTE_FAILURE, _source);