mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
styling: Enforced styling across all files (#55)
This commit is contained in:
165 files changed
+1879
-1725
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { ESX } from "./server";
|
||||
import { pool } from "./db";
|
||||
import events from "../utils/events";
|
||||
import { useIdentifier, getSource } from './functions'
|
||||
import { useIdentifier, getSource } from "./functions";
|
||||
|
||||
interface Contacts {
|
||||
id?: number;
|
||||
@@ -14,7 +14,6 @@ interface ContactId {
|
||||
id: number;
|
||||
}
|
||||
|
||||
|
||||
async function fetchAllContacts(identifier: string): Promise<Contacts[]> {
|
||||
const query = "SELECT * FROM npwd_phone_contacts WHERE identifier = ?";
|
||||
const [results] = await pool.query(query, [identifier]);
|
||||
@@ -31,26 +30,36 @@ async function addContact(
|
||||
const query =
|
||||
"INSERT INTO npwd_phone_contacts (identifier, number, display, avatar) VALUES (?, ?, ?, ?)";
|
||||
|
||||
const [result] = await pool.query(query, [identifier, number, display, avatar]);
|
||||
const [result] = await pool.query(query, [
|
||||
identifier,
|
||||
number,
|
||||
display,
|
||||
avatar,
|
||||
]);
|
||||
}
|
||||
|
||||
async function updateContact(contact: Contacts, identifier: string): Promise<any> {
|
||||
const query = "UPDATE npwd_phone_contacts SET number = ?, display = ?, avatar = ? WHERE id = ? AND identifier = ?"
|
||||
async function updateContact(
|
||||
contact: Contacts,
|
||||
identifier: string
|
||||
): Promise<any> {
|
||||
const query =
|
||||
"UPDATE npwd_phone_contacts SET number = ?, display = ?, avatar = ? WHERE id = ? AND identifier = ?";
|
||||
await pool.query(query, [
|
||||
contact.number,
|
||||
contact.display,
|
||||
contact.avatar,
|
||||
contact.id,
|
||||
identifier
|
||||
])
|
||||
identifier,
|
||||
]);
|
||||
}
|
||||
|
||||
async function deleteContact(contact: ContactId, identifier: string): Promise<any> {
|
||||
const query = "DELETE FROM npwd_phone_contacts WHERE id = ? AND identifier = ?"
|
||||
await pool.query(query, [
|
||||
contact.id,
|
||||
identifier
|
||||
])
|
||||
async function deleteContact(
|
||||
contact: ContactId,
|
||||
identifier: string
|
||||
): Promise<any> {
|
||||
const query =
|
||||
"DELETE FROM npwd_phone_contacts WHERE id = ? AND identifier = ?";
|
||||
await pool.query(query, [contact.id, identifier]);
|
||||
}
|
||||
|
||||
onNet(events.CONTACTS_GET_CONTACTS, async () => {
|
||||
@@ -64,40 +73,62 @@ onNet(events.CONTACTS_GET_CONTACTS, async () => {
|
||||
} catch (error) {
|
||||
console.log("Failed to fetch contacts: ", error);
|
||||
}
|
||||
})
|
||||
|
||||
onNet(events.CONTACTS_ADD_CONTACT, async (number: string, display: string, avatar: string) => {
|
||||
try {
|
||||
const _source = (global as any).source;
|
||||
const _identifier = await useIdentifier()
|
||||
addContact(_identifier, number, display, avatar);
|
||||
emitNet(events.CONTACTS_ADD_CONTACT_SUCCESS, _source)
|
||||
emitNet(events.CONTACTS_ACTION_RESULT, getSource(), 'CONTACT_ADD_SUCCESS')
|
||||
|
||||
} catch(error) {
|
||||
emitNet(events.CONTACTS_ACTION_RESULT, getSource(), 'CONTACT_ADD_FAILED')
|
||||
}
|
||||
});
|
||||
|
||||
onNet(
|
||||
events.CONTACTS_ADD_CONTACT,
|
||||
async (number: string, display: string, avatar: string) => {
|
||||
try {
|
||||
const _source = (global as any).source;
|
||||
const _identifier = await useIdentifier();
|
||||
addContact(_identifier, number, display, avatar);
|
||||
emitNet(events.CONTACTS_ADD_CONTACT_SUCCESS, _source);
|
||||
emitNet(
|
||||
events.CONTACTS_ACTION_RESULT,
|
||||
getSource(),
|
||||
"CONTACT_ADD_SUCCESS"
|
||||
);
|
||||
} catch (error) {
|
||||
emitNet(events.CONTACTS_ACTION_RESULT, getSource(), "CONTACT_ADD_FAILED");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
onNet(events.CONTACTS_UPDATE_CONTACT, async (contact: Contacts) => {
|
||||
try {
|
||||
const _source = (global as any)._source
|
||||
const _identifier = await useIdentifier()
|
||||
updateContact(contact, _identifier)
|
||||
emitNet(events.CONTACTS_UPDATE_CONTACT_SUCCESS, _source)
|
||||
emitNet(events.CONTACTS_ACTION_RESULT, getSource(), 'CONTACT_UPDATE_SUCCESS')
|
||||
const _source = (global as any)._source;
|
||||
const _identifier = await useIdentifier();
|
||||
updateContact(contact, _identifier);
|
||||
emitNet(events.CONTACTS_UPDATE_CONTACT_SUCCESS, _source);
|
||||
emitNet(
|
||||
events.CONTACTS_ACTION_RESULT,
|
||||
getSource(),
|
||||
"CONTACT_UPDATE_SUCCESS"
|
||||
);
|
||||
} catch (error) {
|
||||
emitNet(events.CONTACTS_ACTION_RESULT, getSource(), 'CONTACT_UPDATE_FAILED')
|
||||
emitNet(
|
||||
events.CONTACTS_ACTION_RESULT,
|
||||
getSource(),
|
||||
"CONTACT_UPDATE_FAILED"
|
||||
);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
onNet(events.CONTACTS_DELETE_CONTACT, async (contact: ContactId) => {
|
||||
try {
|
||||
const _identifier = await useIdentifier()
|
||||
deleteContact(contact, _identifier)
|
||||
emitNet(events.CONTACTS_DELETE_CONTACT_SUCCESS, getSource())
|
||||
emitNet(events.CONTACTS_ACTION_RESULT, getSource(), 'CONTACT_DELETE_SUCCESS')
|
||||
const _identifier = await useIdentifier();
|
||||
deleteContact(contact, _identifier);
|
||||
emitNet(events.CONTACTS_DELETE_CONTACT_SUCCESS, getSource());
|
||||
emitNet(
|
||||
events.CONTACTS_ACTION_RESULT,
|
||||
getSource(),
|
||||
"CONTACT_DELETE_SUCCESS"
|
||||
);
|
||||
} catch (error) {
|
||||
emitNet(events.CONTACTS_ACTION_RESULT, getSource(), 'CONTACT_DELETE_FAILED')
|
||||
emitNet(
|
||||
events.CONTACTS_ACTION_RESULT,
|
||||
getSource(),
|
||||
"CONTACT_DELETE_FAILED"
|
||||
);
|
||||
}
|
||||
})
|
||||
});
|
||||
Reference in new issue
Block a user