diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-06-29 23:17:32 +0200 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-06-29 23:18:47 +0200 |
commit | a4614f83ff6553f3e7b094e44ab2b0cf4ce68ff2 (patch) | |
tree | f9db8920de16516502e7a1dfd07db67955bdd173 | |
parent | 8e4832bd129b91fcfe5c24b821e6daf6d9fe6edb (diff) | |
download | nextcloud-server-a4614f83ff6553f3e7b094e44ab2b0cf4ce68ff2.tar.gz nextcloud-server-a4614f83ff6553f3e7b094e44ab2b0cf4ce68ff2.zip |
Don't add duplicate contacts in the list when en-/disable an address book.
-rw-r--r-- | apps/contacts/js/contacts.js | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 9d41b70a314..5be1fa61292 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -1621,19 +1621,21 @@ Contacts={ var contactlist = $('#contacts ul[data-id="'+b+'"]'); for(var c in book.contacts) { if(book.contacts[c].id == undefined) { continue; } - var contact = Contacts.UI.Card.createEntry(book.contacts[c]); - if(c == self.batchnum-5) { - contact.bind('inview', function(event, isInView, visiblePartX, visiblePartY) { - $(this).unbind(event); - var bookid = $(this).data('bookid'); - var numsiblings = $('.contacts li[data-bookid="'+bookid+'"]').length; - if (isInView && numsiblings >= self.batchnum) { - console.log('This would be a good time to load more contacts.'); - Contacts.UI.Contacts.update(id, bookid, $('#contacts li[data-bookid="'+bookid+'"]').length); - } - }); + if($('#contacts li[data-id="'+book.contacts[c]['id']+'"][data-id="'+book.contacts[c]['bookid']+'"]').length == 0) { + var contact = Contacts.UI.Card.createEntry(book.contacts[c]); + if(c == self.batchnum-5) { + contact.bind('inview', function(event, isInView, visiblePartX, visiblePartY) { + $(this).unbind(event); + var bookid = $(this).data('bookid'); + var numsiblings = $('.contacts li[data-bookid="'+bookid+'"]').length; + if (isInView && numsiblings >= self.batchnum) { + console.log('This would be a good time to load more contacts.'); + Contacts.UI.Contacts.update(id, bookid, $('#contacts li[data-bookid="'+bookid+'"]').length); + } + }); + } + contactlist.append(contact); } - contactlist.append(contact); } }); if($('#contacts h3').length > 1) { |