Skip to content

Commit

Permalink
Merge pull request #115 from nextcloud/fix-group-split
Browse files Browse the repository at this point in the history
Fix duplicate groups
  • Loading branch information
irgendwie committed Feb 5, 2017
2 parents 28feb70 + ed92ee1 commit 509e4ae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions js/models/contact_model.js
Expand Up @@ -322,6 +322,13 @@ angular.module('contactsApp')
property.value = property.value.split(',');
}
}
// Remove duplicate categories
var uniqueCategories = _.unique(property.value);
if(!angular.equals(uniqueCategories, property.value)) {
this.failedProps.push(prop);
property.value = uniqueCategories;
//console.debug(this.uid()+': Categories duplicate: ' + property.value);
}
break;
}
return property;
Expand Down
7 changes: 7 additions & 0 deletions js/tests/models/contact_model.js
Expand Up @@ -48,4 +48,11 @@ describe('contactModel', function() {
var categories = contact.categories();
expect(categories).to.deep.equal(['Test 1', 'Test 2', 'Test 3']);
});

it('should remove duplicate groups', function() {
var contact = new $Contact({displayName: 'test'});
contact.categories(['Test', 'Test', 'Test 2']);
var categories = contact.categories();
expect(categories).to.deep.equal(['Test', 'Test 2']);
});
});

0 comments on commit 509e4ae

Please sign in to comment.