Do not switch contact until import is over

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

View File

@ -19,6 +19,7 @@ angular.module('contactsApp')
ctrl.status = parseInt(Math.floor(progress * 100)) + '%';
ctrl.loadingClass = 'icon-loading-small';
}
scope.$apply();
});
});
}, false);

View File

@ -81,6 +81,11 @@ angular.module('contactsApp')
uid: ev.uid
});
}
else if (ev.event === 'import') {
$route.updateParams({
gid: t('contacts', 'All contacts')
});
}
ctrl.contacts = ev.contacts;
}); });
});

View File

@ -158,7 +158,7 @@ angular.module('contactsApp')
});
};
this.create = function(newContact, addressBook, uid) {
this.create = function(newContact, addressBook, uid, fromImport) {
addressBook = addressBook || AddressBookService.getDefaultAddressBook();
try {
newContact = newContact || new Contact(addressBook);
@ -187,8 +187,10 @@ angular.module('contactsApp')
).then(function(xhr) {
newContact.setETag(xhr.getResponseHeader('ETag'));
contacts.put(newUid, newContact);
notifyObservers('create', newUid);
$('#details-fullName').select();
if (fromImport !== true) {
notifyObservers('create', newUid);
$('#details-fullName').select();
}
return newContact;
}).catch(function() {
OC.Notification.showTemporary(t('contacts', 'Contact could not be created.'));
@ -219,12 +221,16 @@ angular.module('contactsApp')
num++;
continue;
}
this.create(newContact, addressBook).then(function() {
this.create(newContact, addressBook, '', true).then(function() {
// Update the progress indicator
if (progressCallback) {
progressCallback(num / singleVCards.length);
}
num++;
/* Import is over, let's notify */
if(num === singleVCards.length) {
notifyObservers('import');
}
});
}
};