diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2017-08-15 17:59:50 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2017-08-15 17:59:50 +0200 |
commit | 0ffee756af1f572a4fa11f649b31ce67359f0ac8 (patch) | |
tree | d13da6aeb7817ed8fc1770676e35416a76b10712 /js | |
parent | 2bebe03eab7e5a55570dbb3e0fe9db33d10b63c5 (diff) |
Fix contact ab switch
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'js')
-rw-r--r-- | js/models/contact_model.js | 5 | ||||
-rw-r--r-- | js/services/contact_service.js | 21 |
2 files changed, 20 insertions, 6 deletions
diff --git a/js/models/contact_model.js b/js/models/contact_model.js index d7d1e056..7d984f8e 100644 --- a/js/models/contact_model.js +++ b/js/models/contact_model.js @@ -276,6 +276,11 @@ angular.module('contactsApp') setUrl: function(addressBook, uid) { this.data.url = addressBook.url + uid + '.vcf'; }, + setAddressBook: function(addressBook) { + this.addressBook = addressBook; + this.addressBookId = addressBook.displayName; + this.data.url = addressBook.url + this.uid() + '.vcf'; + }, getISODate: function(date) { function pad(number) { diff --git a/js/services/contact_service.js b/js/services/contact_service.js index cd9890b4..502a78bc 100644 --- a/js/services/contact_service.js +++ b/js/services/contact_service.js @@ -252,14 +252,23 @@ angular.module('contactsApp') return; } contact.syncVCard(); - var clone = angular.copy(contact); var uid = contact.uid(); - // delete the old one before to avoid conflict - this.delete(contact); - - // create the contact in the new target addressbook - this.create(clone, addressbook, uid); + // Delete on server + DavClient.deleteCard(contact.data).then(function() { + // Create new on server + DavClient.createCard( + addressbook, + { + data: contact.data.addressData, + filename: uid + '.vcf' + } + ).then(function(xhr) { + // Edit local cached contact + contact.setETag(xhr.getResponseHeader('ETag')); + contact.setAddressBook(addressbook); + }); + }); }; this.update = function(contact) { |