Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #12767 from jmcanterafonseca/fix_924400
Browse files Browse the repository at this point in the history
Bug 924400 - A no name contact imported from the SIM card does not allow...
  • Loading branch information
gtorodelvalle committed Oct 10, 2013
2 parents a293273 + 9bebc6d commit e2ca5da
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
15 changes: 5 additions & 10 deletions apps/communications/contacts/js/contacts_matcher.js
Expand Up @@ -378,7 +378,7 @@ contacts.Matcher = (function() {

var finalResult = {};

var resultsByName = null;
var resultsByName = [];
if (!isEmptyStr(aContact.name)) {
var targetName = aContact.name[0].trim();
// Filter by familyName using startsWith. Gecko 'startsWith' operation
Expand All @@ -394,27 +394,22 @@ contacts.Matcher = (function() {
return filterFacebook(aResult, options);
});
notifyFindNameReady();
if (isEmptyStr(aContact.familyName)) {
endOfMatchByName(finalResult, targetName, resultsByName, callbacks);
}
};

reqName.onerror = function(e) {
window.console.warn('Error while trying to find by name: ',
e.target.error.name);
resultsByName = [];
notifyFindNameReady();
if (isEmptyStr(aContact.familyName)) {
endOfMatchByName(finalResult, targetName, resultsByName, callbacks);
}
};
}
else {
resultsByName = [];
notifyFindNameReady();
}

if (!isEmptyStr(aContact.familyName)) {
if (isEmptyStr(aContact.familyName)) {
endOfMatchByName(finalResult, targetName, resultsByName, callbacks);
}
else {
var targetFamilyName = aContact.familyName[0].trim();
// Filter by familyName using startsWith. Gecko 'startsWith' operation
// acts as 'equal' but does not match case.
Expand Down
31 changes: 31 additions & 0 deletions apps/communications/contacts/test/unit/contacts_matcher_test.js
Expand Up @@ -537,6 +537,37 @@ suite('Test Contacts Matcher', function() {
testMatch(myObj, 'active', ['name'], done);
});

test('SIM Contact. Name is totally empty and there is tel. No matches',
function(done) {
var myObj = Object.create(contact);
myObj.id = '1A';
myObj.name = myObj.givenName = myObj.familyName = [];
myObj.category = ['sim'];
myObj.tel = [{
type: ['personal'],
value: '9999999'
}];
myObj.email = null;

testMismatch(myObj, 'active', done);
});

test('Regular Contact. Name is totally empty and there is tel. No matches',
function(done) {
var myObj = Object.create(contact);
myObj.id = '1A';
myObj.name = myObj.givenName = myObj.familyName = [];
myObj.category = null;
myObj.tel = [{
type: ['personal'],
value: '9999999'
}];
myObj.email = null;

testMismatch(myObj, 'active', done);
});


test('Matching by phone, email and name', function(done) {
var myObj = Object.create(contact);
myObj.id = '1A';
Expand Down

0 comments on commit e2ca5da

Please sign in to comment.