Fix contact list and contact iteration function

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2017-09-13 19:55:22 +02:00
parent 4d1734970d
commit 5c343999e4
No known key found for this signature in database
GPG Key ID: FB5ACEED51955BF8
3 changed files with 13 additions and 13 deletions

View File

@ -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) {

View File

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

View File

@ -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()}">