mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
more cleanup
This commit is contained in:
1 parent
bf06c1ed3f
commit
80132e48d7
1 file changed
+8
-11
@@ -18,7 +18,8 @@ interface ContactId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function fetchAllContacts(identifier: string): Promise<Contacts[]> {
|
async function fetchAllContacts(identifier: string): Promise<Contacts[]> {
|
||||||
const query = 'SELECT * FROM npwd_phone_contacts WHERE identifier = ? ORDER BY display ASC';
|
const query =
|
||||||
|
'SELECT * FROM npwd_phone_contacts WHERE identifier = ? ORDER BY display ASC';
|
||||||
const [results] = await pool.query(query, [identifier]);
|
const [results] = await pool.query(query, [identifier]);
|
||||||
const contacts = <Contacts[]>results;
|
const contacts = <Contacts[]>results;
|
||||||
return contacts;
|
return contacts;
|
||||||
@@ -87,12 +88,12 @@ onNet(
|
|||||||
emitNet(events.CONTACTS_ADD_CONTACT_SUCCESS, _source);
|
emitNet(events.CONTACTS_ADD_CONTACT_SUCCESS, _source);
|
||||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
||||||
message: 'CONTACT_ADD_SUCCESS',
|
message: 'CONTACT_ADD_SUCCESS',
|
||||||
type: 'success'
|
type: 'success',
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
||||||
message: 'CONTACT_ADD_FAILED',
|
message: 'CONTACT_ADD_FAILED',
|
||||||
type: 'error'
|
type: 'error',
|
||||||
});
|
});
|
||||||
contactsLogger.error(`Failed to add contact, ${e.message}`, {
|
contactsLogger.error(`Failed to add contact, ${e.message}`, {
|
||||||
source: _source,
|
source: _source,
|
||||||
@@ -105,23 +106,19 @@ onNet(events.CONTACTS_UPDATE_CONTACT, async (contact: Contacts) => {
|
|||||||
const _source = getSource();
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const _identifier = ESX.GetPlayerFromId(_source).getIdentifier();
|
const _identifier = ESX.GetPlayerFromId(_source).getIdentifier();
|
||||||
// console.log('nice identifier bro', _identifier);
|
|
||||||
await updateContact(contact, _identifier);
|
await updateContact(contact, _identifier);
|
||||||
// console.log('i updated the contact server side!');
|
|
||||||
|
|
||||||
emitNet(events.CONTACTS_UPDATE_CONTACT_SUCCESS, _source);
|
emitNet(events.CONTACTS_UPDATE_CONTACT_SUCCESS, _source);
|
||||||
// console.log('ffs, didd it return successful');
|
|
||||||
|
|
||||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
||||||
message: 'CONTACT_UPDATE_SUCCESS',
|
message: 'CONTACT_UPDATE_SUCCESS',
|
||||||
type: 'success'
|
type: 'success',
|
||||||
});
|
});
|
||||||
// console.log('UPDATED CONTACT: ', contact);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const _source = (global as any).source;
|
const _source = (global as any).source;
|
||||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
||||||
message: 'CONTACT_UPDATE_FAILED',
|
message: 'CONTACT_UPDATE_FAILED',
|
||||||
type: 'error'
|
type: 'error',
|
||||||
});
|
});
|
||||||
contactsLogger.error(`Failed to update contact, ${e.message}`, {
|
contactsLogger.error(`Failed to update contact, ${e.message}`, {
|
||||||
source: _source,
|
source: _source,
|
||||||
@@ -137,7 +134,7 @@ onNet(events.CONTACTS_DELETE_CONTACT, async (contact: ContactId) => {
|
|||||||
emitNet(events.CONTACTS_DELETE_CONTACT_SUCCESS, _source);
|
emitNet(events.CONTACTS_DELETE_CONTACT_SUCCESS, _source);
|
||||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
||||||
message: 'CONTACT_DELETE_SUCCESS',
|
message: 'CONTACT_DELETE_SUCCESS',
|
||||||
type: 'success'
|
type: 'success',
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
contactsLogger.error(`Failed to delete contact, ${e.message}`, {
|
contactsLogger.error(`Failed to delete contact, ${e.message}`, {
|
||||||
@@ -145,7 +142,7 @@ onNet(events.CONTACTS_DELETE_CONTACT, async (contact: ContactId) => {
|
|||||||
});
|
});
|
||||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
||||||
message: 'CONTACT_DELETE_FAILED',
|
message: 'CONTACT_DELETE_FAILED',
|
||||||
type: 'error'
|
type: 'error',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user