feat(Alerts): alerts for contacts

This commit is contained in:
Christopher committed 2021-02-18 23:20:24 +01:00
1 parent 11af8bfb5a
commit 9846a4e1ae
4 files changed
+31 -21

No files matched your search

+24 -6
View File
@@ -85,9 +85,15 @@ onNet(
const _identifier = getIdentifier(_source);
await addContact(_identifier, number, display, avatar);
emitNet(events.CONTACTS_ADD_CONTACT_SUCCESS, _source);
emitNet(events.CONTACTS_ACTION_RESULT, _source, 'CONTACT_ADD_SUCCESS');
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
message: 'CONTACT_ADD_SUCCESS',
type: 'success'
});
} catch (e) {
emitNet(events.CONTACTS_ACTION_RESULT, _source, 'CONTACT_ADD_FAILED');
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
message: 'CONTACT_ADD_FAILED',
type: 'error'
});
contactsLogger.error(`Failed to add contact, ${e.message}`, {
source: _source,
});
@@ -106,11 +112,17 @@ onNet(events.CONTACTS_UPDATE_CONTACT, async (contact: Contacts) => {
emitNet(events.CONTACTS_UPDATE_CONTACT_SUCCESS, _source);
// console.log('ffs, didd it return successful');
emitNet(events.CONTACTS_ACTION_RESULT, _source, 'CONTACT_UPDATE_SUCCESS');
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
message: 'CONTACT_UPDATE_SUCCESS',
type: 'success'
});
// console.log('UPDATED CONTACT: ', contact);
} catch (e) {
const _source = (global as any).source;
emitNet(events.CONTACTS_ACTION_RESULT, _source, 'CONTACT_UPDATE_FAILED');
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
message: 'CONTACT_UPDATE_FAILED',
type: 'error'
});
contactsLogger.error(`Failed to update contact, ${e.message}`, {
source: _source,
});
@@ -123,11 +135,17 @@ onNet(events.CONTACTS_DELETE_CONTACT, async (contact: ContactId) => {
const _identifier = await getIdentifier(_source);
await deleteContact(contact, _identifier);
emitNet(events.CONTACTS_DELETE_CONTACT_SUCCESS, _source);
emitNet(events.CONTACTS_ACTION_RESULT, _source, 'CONTACT_DELETE_SUCCESS');
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
message: 'CONTACT_DELETE_SUCCESS',
type: 'success'
});
} catch (e) {
contactsLogger.error(`Failed to delete contact, ${e.message}`, {
source: _source,
});
emitNet(events.CONTACTS_ACTION_RESULT, _source, 'CONTACT_DELETE_FAILED');
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
message: 'CONTACT_DELETE_FAILED',
type: 'error'
});
}
});