Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
24 lines
797 B
JavaScript
Executable file
24 lines
797 B
JavaScript
Executable file
'use strict';
|
|
|
|
var contacts = window.contacts || {};
|
|
|
|
contacts.adaptAndMerge = function(incomingContact, matches, callbacks) {
|
|
var listIds = Object.keys(matches);
|
|
var totalMatches = listIds.length;
|
|
|
|
// First contact here we take as the master
|
|
var masterContact = matches[listIds[0]].matchingContact;
|
|
var matchingContacts = [];
|
|
for (var j = 1; j < totalMatches; j++) {
|
|
matchingContacts.push(matches[listIds[j]]);
|
|
}
|
|
// Finally the last matching is the incoming itself
|
|
// XXX: it has no `matchings` entry as it does not come from the matching
|
|
// algorithm.
|
|
// Now only used here but consider to provide a constructor in the future.
|
|
matchingContacts.push({
|
|
matchingContact: incomingContact
|
|
});
|
|
|
|
contacts.Merger.merge(masterContact, matchingContacts, callbacks);
|
|
};
|