diff options
author | suntala <33031346+suntala@users.noreply.github.com> | 2018-09-26 16:59:26 +0200 |
---|---|---|
committer | suntala <33031346+suntala@users.noreply.github.com> | 2018-09-26 16:59:26 +0200 |
commit | 28487050c4fe2136fcd521c2b7745b6443a508cd (patch) | |
tree | b656a71380d04ea0acb4a2c846ca64f859286b63 /src | |
parent | f14959a4f41a481abd3027bdc51871e6d2447a9c (diff) |
Check if photo property exists before adding it. #603
Diffstat (limited to 'src')
-rw-r--r-- | src/components/ContactDetails/ContactDetailsAvatar.vue | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/components/ContactDetails/ContactDetailsAvatar.vue b/src/components/ContactDetails/ContactDetailsAvatar.vue index bf7e242a..f91ca9fd 100644 --- a/src/components/ContactDetails/ContactDetailsAvatar.vue +++ b/src/components/ContactDetails/ContactDetailsAvatar.vue @@ -30,7 +30,8 @@ import rfcProps from '../../models/rfcProps'; <div class="contact-header-avatar__options"> <input id="contact-avatar-upload" type="file" class="hidden" accept="image/*" @change="processFile"> - <label v-tooltip.auto="t('contacts', 'Upload a new picture')" for="contact-avatar-upload" class="icon-upload-white" /> + <label v-tooltip.auto="t('contacts', 'Upload a new picture')" for="contact-avatar-upload" + class="icon-upload-white" @click="processFile" /> <div v-if="maximizeAvatar" class="icon-delete-white" @click="removePhoto" /> <div v-if="maximizeAvatar" class="icon-fullscreen-white" @click="toggleSize" /> <div v-if="maximizeAvatar" class="icon-download-white" @click="downloadPhoto" /> @@ -59,9 +60,12 @@ export default { let file = event.target.files[0] let reader = new FileReader() let self = this - // need if contact.photo to check if already there, if it is use updatePropertyWithValue + // check if photo property exists to decide whether to add/update it reader.onload = function(e) { - self.contact.vCard.addPropertyWithValue('photo', reader.result) + self.contact.photo + ? self.contact.photo = reader.result + : self.contact.vCard.addPropertyWithValue('photo', reader.result) + self.$store.dispatch('updateContact', self.contact) } reader.readAsDataURL(file) |