diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-10-25 08:30:32 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-10-25 08:30:32 +0200 |
commit | 7780971ef6aaf57da4fb04219f264dc38caeac4b (patch) | |
tree | 36bac7f449f62322413fc68f15452823a51e9a9b /src | |
parent | ffb098c0eed287a5aef07b68678e6cbe23d95582 (diff) |
Fix etag conflict
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/models/contact.js | 3 | ||||
-rw-r--r-- | src/store/contacts.js | 14 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/models/contact.js b/src/models/contact.js index 104f11ff..250d2f05 100644 --- a/src/models/contact.js +++ b/src/models/contact.js @@ -45,6 +45,9 @@ export default class Contact { this.jCal = jCal this.addressbook = addressbook this.vCard = new ICAL.Component(this.jCal) + + // used to state a contact is not up to date with + // the server and cannot be pushed (etag) this.conflict = false // if no uid set, create one diff --git a/src/store/contacts.js b/src/store/contacts.js index cfcd26ba..4c5cdf8e 100644 --- a/src/store/contacts.js +++ b/src/store/contacts.js @@ -276,18 +276,18 @@ const actions = { if (!contact.conflict) { contact.dav.data = vData return contact.dav.update() - .then((response) => { + .then(() => { + // all clear, let's update the store + context.commit('updateContact', contact) + }) + .catch((error) => { // wrong etag, we most likely have a conflict - if (response && response.status === 412) { + if (error && error.status === 412) { // saving the new etag so that the user can manually // trigger a fetchCompleteData without any further errors - contact.conflict = response.xhr.getResponseHeader('etag') - } else { - // all clear, let's update the store - context.commit('updateContact', contact) + contact.conflict = error.xhr.getResponseHeader('etag') } }) - .catch((error) => { throw error }) } else { console.error('This contact is outdated, refusing to push', contact) } |