Select first contact after import if available.

This commit is contained in:
Alexander Weidinger 2017-09-30 15:25:33 +02:00
parent 3df3154b2e
commit 2987b07a1b
2 changed files with 12 additions and 3 deletions

View File

@ -56,6 +56,13 @@ angular.module('contactsApp')
ctrl.loading = true;
ContactService.registerObserverCallback(function(ev) {
/* after import at first refresh the contactList */
if (ev.event === 'importend') {
$scope.$apply(function() {
ctrl.contactList = ev.contacts;
});
}
/* update route parameters */
$timeout(function() {
$scope.$apply(function() {
switch(ev.event) {
@ -69,10 +76,12 @@ angular.module('contactsApp')
});
break;
case 'importend':
/* after import select 'All contacts' group and first contact */
$route.updateParams({
gid: t('contacts', 'All contacts')
gid: t('contacts', 'All contacts'),
uid: ctrl.filteredContacts.length !== 0 ? ctrl.filteredContacts[0].uid() : undefined
});
break;
return;
case 'getFullContacts' || 'update':
break;
default:

View File

@ -260,7 +260,7 @@ angular.module('contactsApp')
}
num++;
/* Import is over, let's notify */
if(num >= singleVCards.length) {
if (num === singleVCards.length + 1) {
notifyObservers('importend');
}
});