mirror of https://github.com/nextcloud/contacts
Add promise queue to avoid race condition
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
83850fa3de
commit
cada30d84b
|
@ -76,7 +76,7 @@ angular.module('contactsApp')
|
|||
};
|
||||
|
||||
ctrl.updateContact = function() {
|
||||
ContactService.update(ctrl.contact);
|
||||
ContactService.AddAndUpdate(ctrl.contact);
|
||||
};
|
||||
|
||||
ctrl.deleteContact = function() {
|
||||
|
|
|
@ -8,6 +8,13 @@ angular.module('contactsApp')
|
|||
var observerCallbacks = [];
|
||||
var loadPromise = undefined;
|
||||
|
||||
var allUpdates = $q.when();
|
||||
this.AddAndUpdate = function(contact) {
|
||||
allUpdates = allUpdates.then(function() {
|
||||
return contactService.update(contact);
|
||||
});
|
||||
};
|
||||
|
||||
this.registerObserverCallback = function(callback) {
|
||||
observerCallbacks.push(callback);
|
||||
};
|
||||
|
@ -180,7 +187,7 @@ angular.module('contactsApp')
|
|||
this.create = function(newContact, addressBook, uid, fromImport) {
|
||||
addressBook = addressBook || AddressBookService.getDefaultAddressBook();
|
||||
if(addressBook.readOnly) {
|
||||
OC.Notification.showTemporary(t('contacts', 'You have no permission to make changes to this address book.'));
|
||||
OC.Notification.showTemporary(t('contacts', 'You don\'t have permission to write to this addressbook.'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
@ -272,7 +279,7 @@ angular.module('contactsApp')
|
|||
return;
|
||||
}
|
||||
if(addressBook.readOnly) {
|
||||
OC.Notification.showTemporary(t('contacts', 'You have no permission to make changes to this address book.'));
|
||||
OC.Notification.showTemporary(t('contacts', 'You don\'t have permission to write to this addressbook.'));
|
||||
return;
|
||||
}
|
||||
contact.syncVCard();
|
||||
|
|
Loading…
Reference in New Issue