summaryrefslogtreecommitdiffstats
path: root/src/store
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-09-25 12:40:22 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-09-25 14:53:28 +0200
commit7349a6fc5bf22d50ac1550f73c12ebdb7536c16f (patch)
treeb90f11c5d596e709cf17119974ce23a2352f9a4d /src/store
parent040992884b416d5c86e3a06731f26a5b1c68d7a8 (diff)
Contact deletion fix and warning if fetchFull fails and/of contact gone
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/store')
-rw-r--r--src/store/addressbooks.js6
-rw-r--r--src/store/contacts.js11
2 files changed, 10 insertions, 7 deletions
diff --git a/src/store/addressbooks.js b/src/store/addressbooks.js
index b0fb217a..74a47bef 100644
--- a/src/store/addressbooks.js
+++ b/src/store/addressbooks.js
@@ -386,9 +386,9 @@ const actions = {
OC.Notification.showTemporary(t('contacts', 'An error occurred'))
})
}
- context.commit('deleteContactFromAddressbook', contact)
- context.commit('updateContactAddressbook', { contact, addressbook })
- context.commit('addContactToAddressbook', contact)
+ await context.commit('deleteContactFromAddressbook', contact)
+ await context.commit('updateContactAddressbook', { contact, addressbook })
+ await context.commit('addContactToAddressbook', contact)
}
}
diff --git a/src/store/contacts.js b/src/store/contacts.js
index f8c152f5..aa0805f0 100644
--- a/src/store/contacts.js
+++ b/src/store/contacts.js
@@ -206,11 +206,13 @@ const actions = {
* Delete a contact from the list and from the associated addressbook
*
* @param {Object} context the store mutations
- * @param {Contact} contact the contact to delete
+ * @param {Object} data destructuring object
+ * @param {Contact} data.contact the contact to delete
+ * @param {Boolean} [data.dav=true] trigger a dav deletion
*/
- async deleteContact(context, contact) {
+ async deleteContact(context, { contact, dav = true }) {
// only local delete if the contact doesn't exists on the server
- if (contact.dav) {
+ if (contact.dav && dav) {
await contact.dav.delete()
.catch((error) => {
console.error(error)
@@ -247,7 +249,7 @@ const actions = {
// create contact
await contact.addressbook.dav.createVCard(vData)
.then((response) => {
- contact.dav = response
+ Vue.set(contact, 'dav', response)
})
.catch((error) => { throw error })
}
@@ -271,6 +273,7 @@ const actions = {
let newContact = new Contact(contact.dav.data, contact.addressbook, contact.dav.url, contact.dav.etag)
context.commit('updateContact', newContact)
})
+ .catch((error) => { throw error })
}
}