mirror of https://github.com/nextcloud/contacts
Fix contact list and contact iteration function
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
4d1734970d
commit
5c343999e4
|
@ -21,7 +21,7 @@ angular.module('contactsApp')
|
|||
clearInterval(ctrl.intervalId);
|
||||
ctrl.intervalId = setInterval(
|
||||
function () {
|
||||
if (!ctrl.loading && ctrl.contacts && ctrl.contacts.length > ctrl.limitTo) {
|
||||
if (!ctrl.loading && ctrl.contactList && ctrl.contactList.length > ctrl.limitTo) {
|
||||
ctrl.limitTo += 25;
|
||||
$scope.$apply();
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ angular.module('contactsApp')
|
|||
});
|
||||
}
|
||||
if(ev.contacts.length !== 0) {
|
||||
ctrl.contacts = ev.contacts;
|
||||
ctrl.contactList = ev.contacts;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -87,7 +87,7 @@ angular.module('contactsApp')
|
|||
ctrl.loading = true;
|
||||
ContactService.updateDeletedAddressbook(function() {
|
||||
ContactService.getAll().then(function(contacts) {
|
||||
ctrl.contacts = contacts;
|
||||
ctrl.contactList = contacts;
|
||||
ctrl.loading = false;
|
||||
ctrl.selectNearestContact(ctrl.getSelectedId());
|
||||
});
|
||||
|
@ -101,7 +101,7 @@ angular.module('contactsApp')
|
|||
ContactService.getAll().then(function(contacts) {
|
||||
if(contacts.length>0) {
|
||||
$scope.$apply(function() {
|
||||
ctrl.contacts = contacts;
|
||||
ctrl.contactList = contacts;
|
||||
});
|
||||
} else {
|
||||
ctrl.loading = false;
|
||||
|
@ -210,10 +210,10 @@ angular.module('contactsApp')
|
|||
});
|
||||
|
||||
ctrl.hasContacts = function () {
|
||||
if (!ctrl.contacts) {
|
||||
if (!ctrl.contactList) {
|
||||
return false;
|
||||
}
|
||||
return ctrl.contacts.length > 0;
|
||||
return ctrl.contactList.length > 0;
|
||||
};
|
||||
|
||||
ctrl.setSelectedId = function (contactId) {
|
||||
|
|
|
@ -69,15 +69,15 @@ angular.module('contactsApp')
|
|||
enabledAddressBooks.forEach(function (addressBook) {
|
||||
promises.push(
|
||||
AddressBookService.sync(addressBook).then(function (addressBook) {
|
||||
for (var i in addressBook.objects) {
|
||||
if (addressBook.objects[i].addressData) {
|
||||
var contact = new Contact(addressBook, addressBook.objects[i]);
|
||||
addressBook.objects.forEach(function(vcard) {
|
||||
try {
|
||||
var contact = new Contact(addressBook, vcard);
|
||||
contactsCache.put(contact.uid(), contact);
|
||||
} else {
|
||||
} catch(error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Invalid contact received: ' + addressBook.objects[i].url);
|
||||
console.log('Invalid contact received: ', vcard);
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div style="height: 90%" class="contacts-list" ng-class="{loading: ctrl.loading, 'mobile-show': ctrl.show}">
|
||||
<div class="app-content-list-item"
|
||||
ng-repeat="contact in ctrl.contactList = (ctrl.contacts | contactGroupFilter:ctrl.routeParams.gid | localeOrderBy:ctrl.sortBy | filter:query | limitTo:ctrl.limitTo) as filtered track by contact.uid()"
|
||||
ng-repeat="contact in (ctrl.contactList | contactGroupFilter:ctrl.routeParams.gid | localeOrderBy:ctrl.sortBy | filter:query | limitTo:ctrl.limitTo) as filtered track by contact.uid()"
|
||||
contact data="contact"
|
||||
ng-click="setSelected(contact.uid())"
|
||||
ng-class="{active: contact.uid() === ctrl.getSelectedId()}">
|
||||
|
|
Loading…
Reference in New Issue