feat(contacts/server|client): events for alerts

This commit is contained in:
Christopher committed 2020-12-11 22:02:37 +01:00
1 parent da32d2ca35
commit 4d6bc53eea
2 files changed
+16 -4

No files matched your search

+10
View File
@@ -42,4 +42,14 @@ on(`__cfx_nui:${events.CONTACTS_DELETE_CONTACT}`, (data: any) => {
onNet(events.CONTACTS_DELETE_CONTACT_SUCCESS, () => {
emitNet(events.CONTACTS_GET_CONTACTS)
})
onNet(events.CONTACTS_ACTION_RESULT, (result: string) => {
SendNuiMessage(
JSON.stringify({
app: "CONTACTS",
method: 'setAlert',
data: result
})
)
})
+6 -4
View File
@@ -72,9 +72,10 @@ onNet(events.CONTACTS_ADD_CONTACT, async (number: string, display: string, avata
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) {
console.log("Failed to add contact: ", error);
emitNet(events.CONTACTS_ACTION_RESULT, getSource(), 'CONTACT_ADD_FAILED')
}
});
@@ -84,9 +85,9 @@ onNet(events.CONTACTS_UPDATE_CONTACT, async (contact: Contacts) => {
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) {
console.log(error)
emitNet(events.CONTACTS_ACTION_RESULT, getSource(), 'CONTACT_UPDATE_FAILED')
}
})
@@ -95,7 +96,8 @@ onNet(events.CONTACTS_DELETE_CONTACT, async (contact: ContactId) => {
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) {
console.log("DELETE CONTACT ERROR", error)
emitNet(events.CONTACTS_ACTION_RESULT, getSource(), 'CONTACT_DELETE_FAILED')
}
})