VulpesOS/gaia/shared/js/contacts/merger_adapter.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

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);
};