Create addressbook if list empty

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2017-01-10 14:00:36 +01:00
parent 01917595a2
commit 42d7a88f4d
No known key found for this signature in database
GPG Key ID: FB5ACEED51955BF8
1 changed files with 8 additions and 0 deletions

View File

@ -7,6 +7,14 @@ angular.module('contactsApp')
AddressBookService.getAll().then(function(addressBooks) {
ctrl.addressBooks = addressBooks;
ctrl.loading = false;
if(ctrl.addressBooks.length === 0) {
AddressBookService.create(t('contacts', 'Contacts')).then(function() {
AddressBookService.getAddressBook(t('contacts', 'Contacts')).then(function(addressBook) {
ctrl.addressBooks.push(addressBook);
$scope.$apply();
});
});
}
});
ctrl.t = {