Timeout syntax fix

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2017-08-21 15:58:21 +02:00
parent ee452c1638
commit d9626f819e
No known key found for this signature in database
GPG Key ID: FB5ACEED51955BF8
2 changed files with 41 additions and 35 deletions

View File

@ -56,41 +56,45 @@ angular.module('contactsApp')
ctrl.loading = true;
ContactService.registerObserverCallback(function(ev) {
$timeout(function() { $scope.$apply(function() {
if (ev.event === 'delete') {
ctrl.getFirstContact(ev.uid);
}
else if (ev.event === 'create') {
$route.updateParams({
gid: $routeParams.gid,
uid: ev.uid
});
}
else if (ev.event === 'importend') {
$route.updateParams({
gid: t('contacts', 'All contacts')
});
}
if(ev.contacts.length !== 0) {
ctrl.contacts = ev.contacts;
}
}); });
$timeout(function() {
$scope.$apply(function() {
if (ev.event === 'delete') {
ctrl.getFirstContact(ev.uid);
}
else if (ev.event === 'create') {
$route.updateParams({
gid: $routeParams.gid,
uid: ev.uid
});
}
else if (ev.event === 'importend') {
$route.updateParams({
gid: t('contacts', 'All contacts')
});
}
if(ev.contacts.length !== 0) {
ctrl.contacts = ev.contacts;
}
});
});
});
AddressBookService.registerObserverCallback(function(ev) {
$timeout(function() { $scope.$apply(function() {
if (ev.event === 'delete') {
// Get contacts
ctrl.loading = true;
ContactService.updateDeletedAddressbook(function() {
ContactService.getAll().then(function(contacts) {
ctrl.contacts = contacts;
ctrl.loading = false;
ctrl.getFirstContact(ctrl.getSelectedId());
$timeout(function() {
$scope.$apply(function() {
if (ev.event === 'delete') {
// Get contacts
ctrl.loading = true;
ContactService.updateDeletedAddressbook(function() {
ContactService.getAll().then(function(contacts) {
ctrl.contacts = contacts;
ctrl.loading = false;
ctrl.getFirstContact(ctrl.getSelectedId());
});
});
});
}
}); });
}
});
});
});
// Get contacts

View File

@ -15,11 +15,13 @@ angular.module('contactsApp')
// Update groupList on contact add/delete/update/groupsUpdate
ContactService.registerObserverCallback(function(ev) {
if (ev.event !== 'getFullContacts') {
$timeout(function () { $scope.$apply(function() {
ContactService.getGroupList().then(function(groups) {
ctrl.groups = groups;
$timeout(function () {
$scope.$apply(function() {
ContactService.getGroupList().then(function(groups) {
ctrl.groups = groups;
});
});
}); });
});
}
});