mirror of https://github.com/nextcloud/contacts
Contact deletion fix and warning if fetchFull fails and/of contact gone
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
040992884b
commit
7349a6fc5b
|
@ -347,6 +347,12 @@ export default {
|
|||
this.localContact = localContact
|
||||
this.loadingData = false
|
||||
})
|
||||
.catch((error) => {
|
||||
OC.Notification.showTemporary(t('contacts', 'The contact doesn\'t exists anymore on the server.'))
|
||||
console.error(error)
|
||||
// trigger a local deletion from the store only
|
||||
this.$store.dispatch('deleteContact', { contact: this.contact, dav: false })
|
||||
})
|
||||
} else if (contact) {
|
||||
// create empty contact and copy inner data
|
||||
// wait for an update to really push the contact on the server!
|
||||
|
@ -362,7 +368,7 @@ export default {
|
|||
* Dispatch contact deletion request
|
||||
*/
|
||||
deleteContact() {
|
||||
this.$store.dispatch('deleteContact', this.contact)
|
||||
this.$store.dispatch('deleteContact', { contact: this.contact })
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -64,7 +64,7 @@ export default {
|
|||
* Dispatch contact deletion request
|
||||
*/
|
||||
deleteContact() {
|
||||
this.$store.dispatch('deleteContact', this.contact)
|
||||
this.$store.dispatch('deleteContact', { contact: this.contact })
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,11 +30,15 @@ export default class Contact {
|
|||
*
|
||||
* @param {string} vcard the vcard data as string with proper new lines
|
||||
* @param {object} addressbook the addressbook which the contat belongs to
|
||||
* @param {string} [url] the url of the contact
|
||||
* @param {string} [etag] the current etag of the contact
|
||||
* @param {string} [url=''] the url of the contact
|
||||
* @param {string} [etag=''] the current etag of the contact
|
||||
* @memberof Contact
|
||||
*/
|
||||
constructor(vcard = '', addressbook, url = '', etag = '') {
|
||||
constructor(vcard, addressbook, url = '', etag = '') {
|
||||
if (typeof vcard !== 'string' || vcard.length === 0) {
|
||||
throw new Error('Invalid vCard')
|
||||
}
|
||||
|
||||
let jCal = ICAL.parse(vcard)
|
||||
if (jCal[0] !== 'vcard') {
|
||||
throw new Error('Only one contact is allowed in the vcard data')
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue