Added Contact Model (#34)

This commit is contained in:
Aliyss Snow 2020-02-03 00:08:36 +01:00 • committed by GitHub
commit e2351db722
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 134 additions and 0 deletions

View file

@ -68,6 +68,27 @@ exports.LoadUtils = () => {
return chats.map(chat => window.WWebJS.getChatModel(chat));
};
window.WWebJS.getContactModel = contact => {
let res = contact.serialize();
res.isBusiness = contact.isBusiness;
if (contact.businessProfile) {
res.businessProfile = contact.businessProfile.serialize();
}
return res;
};
window.WWebJS.getContact = contactId => {
const contact = window.Store.Contact.get(contactId);
return window.WWebJS.getContactModel(contact);
};
window.WWebJS.getContacts = () => {
const contacts = window.Store.Contact.models;
return contacts.map(contact => window.WWebJS.getContactModel(contact));
};
window.WWebJS.downloadBuffer = (url) => {
return new Promise(function(resolve, reject) {
let xhr = new XMLHttpRequest();