function sync([{ ID } = {}] = [], type) {
        const MAP_EMAILS = contactEmails.getMap();

        if (type === 'contact.details' || type === 'selected') {
            CACHE.map.selected = selected(ID);
            return;
        }

        if (type === 'contacts.sort') {
            CACHE.map.filtered = filtered();
            return;
        }

        const { list, all } = _.reduce(
            get(),
            (acc, contact) => {
                contact.Emails = MAP_EMAILS[contact.ID] || [];
                contact.emails = contact.Emails.map(({ Email = '' }) => Email).join(', ');
                acc.all[contact.ID] = { ...contact };
                acc.list.push(acc.all[contact.ID]);
                return acc;
            },
            { list: [], all: Object.create(null) }
        );

        CACHE.contacts = list;
        CACHE.map = {
            all,
            selected: selected(ID),
            filtered: filtered()
        };
    }
/**
     * Sync the collection and auto select the last contact
     * added if it exists.
     * Warning: the sort is expensive.
     *     - On load/update create a full refresh of the cache
     *     - On select contact/open contact: refresh the selected list
     *     - On sort: refresh only the filtered list
     * @param  {Object} [ { ID }
     * @param  {String} type: type of sync to perform
     */
Sync the collection and auto select the last contact
added if it exists.
Warning: the sort is expensive.
- On load/update create a full refresh of the cache
- On select contact/open contact: refresh the selected list
- On sort: refresh only the filtered list
@param  {Object} [ { ID }
@param  {String} type: type of sync to perform
Sync the collection and auto select the last contact added if it exists . Warning : the sort is expensive . - On load / update create a full refresh of the cache - On select contact / open contact : refresh the selected list - On sort : refresh only the filtered list @param { Object } [ { ID } @param { String } type : type of sync to perform
function sync([{ ID } = {}] = [], type) {
        const MAP_EMAILS = contactEmails.getMap();
        if (type === 'contact.details' || type === 'selected') {
            CACHE.map.selected = selected(ID);
            return;
        }
        if (type === 'contacts.sort') {
            CACHE.map.filtered = filtered();
            return;
        }
        const { list, all } = _.reduce(
            get(),
            (acc, contact) => {
                contact.Emails = MAP_EMAILS[contact.ID] || [];
                contact.emails = contact.Emails.map(({ Email = '' }) => Email).join(', ');
                acc.all[contact.ID] = { ...contact };
                acc.list.push(acc.all[contact.ID]);
                return acc;
            },
            { list: [], all: Object.create(null) }
        );
        CACHE.contacts = list;
        CACHE.map = {
            all,
            selected: selected(ID),
            filtered: filtered()
        };
    }
function sync ( [ { ID } = { } ] = [ ] , type ) { const MAP_EMAILS = contactEmails . getMap ( ) ; if ( type === 'contact.details' || type === 'selected' ) { CACHE . map . selected = selected ( ID ) ; return ; } if ( type === 'contacts.sort' ) { CACHE . map . filtered = filtered ( ) ; return ; } const { list , all } = _ . reduce ( get ( ) , ( acc , contact ) => { contact . Emails = MAP_EMAILS [ contact . ID ] || [ ] ; contact . emails = contact . Emails . map ( ( { Email = '' } ) => Email ) . join ( ', ' ) ; acc . all [ contact . ID ] = { ... contact } ; acc . list . push ( acc . all [ contact . ID ] ) ; return acc ; } , { list : [ ] , all : Object . create ( null ) } ) ; CACHE . contacts = list ; CACHE . map = { all , selected : selected ( ID ) , filtered : filtered ( ) } ; }
Sync the collection and auto select the last contact
 added if it exists.
Sync the collection and auto select the last contact added if it exists .