summaryrefslogtreecommitdiffstats
path: root/src/store
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-03-11 11:18:18 +0100
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-03-11 11:21:34 +0100
commitbd71a7f913ec077f6341b9086e7a19969c180c1b (patch)
tree394e29d9969e1d0e935bca6ed2a1b1b7bded7e7a /src/store
parent276cd922f52e66af1788e73459fcfbbbb7fed1d2 (diff)
Properly update store contact on first push
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/store')
-rw-r--r--src/store/contacts.js24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/store/contacts.js b/src/store/contacts.js
index 4b98291f..c119a5d1 100644
--- a/src/store/contacts.js
+++ b/src/store/contacts.js
@@ -248,6 +248,23 @@ const mutations = {
} else {
console.error('Error while handling the following contact', contact)
}
+ },
+
+ /**
+ * Set a contact dav property
+ *
+ * @param {Object} state the store data
+ * @param {Object} data destructuring object
+ * @param {Contact} data.contact the contact to update
+ * @param {Object} data.dav the dav object returned by the cdav library
+ */
+ setContactDav(state, { contact, dav }) {
+ if (state.contacts[contact.key] && contact instanceof Contact) {
+ contact = state.contacts[contact.key]
+ Vue.set(contact, 'dav', dav)
+ } else {
+ console.error('Error while handling the following contact', contact)
+ }
}
}
@@ -317,12 +334,13 @@ const actions = {
if (!contact.dav) {
// create contact
return contact.addressbook.dav.createVCard(vData)
- .then((response) => {
- Vue.set(contact, 'dav', response)
+ .then(dav => {
+ context.commit('setContactDav', { contact, dav })
})
- .catch((error) => { throw error })
+ .catch(error => { throw error })
}
+ // if contact already exists
if (!contact.conflict) {
contact.dav.data = vData
return contact.dav.update()