From ac0b45fa149dad9be84074313b69b9f3d360928a Mon Sep 17 00:00:00 2001
From: taehoon
Date: Fri, 22 Mar 2019 13:00:58 -0400
Subject: [PATCH] Update avatar uploading
---
src/components/image_cropper/image_cropper.js | 16 ++--------------
src/components/image_cropper/image_cropper.vue | 4 ++--
src/components/user_settings/user_settings.js | 9 +++++----
3 files changed, 9 insertions(+), 20 deletions(-)
diff --git a/src/components/image_cropper/image_cropper.js b/src/components/image_cropper/image_cropper.js
index 5ba8f04e..01361e25 100644
--- a/src/components/image_cropper/image_cropper.js
+++ b/src/components/image_cropper/image_cropper.js
@@ -70,22 +70,10 @@ const ImageCropper = {
this.dataUrl = undefined
this.$emit('close')
},
- submit () {
+ submit (cropping = true) {
this.submitting = true
this.avatarUploadError = null
- this.submitHandler(this.cropper, this.file)
- .then(() => this.destroy())
- .catch((err) => {
- this.submitError = err
- })
- .finally(() => {
- this.submitting = false
- })
- },
- submitWithoutCropping () {
- this.submitting = true
- this.avatarUploadError = null
- this.submitHandler(false, this.dataUrl)
+ this.submitHandler(cropping && this.cropper, this.file)
.then(() => this.destroy())
.catch((err) => {
this.submitError = err
diff --git a/src/components/image_cropper/image_cropper.vue b/src/components/image_cropper/image_cropper.vue
index 129e6f46..d2b86e9e 100644
--- a/src/components/image_cropper/image_cropper.vue
+++ b/src/components/image_cropper/image_cropper.vue
@@ -5,9 +5,9 @@
-
+
-
+
diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index 6b367e4f..820feba6 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -163,16 +163,17 @@ const UserSettings = {
reader.readAsDataURL(file)
},
submitAvatar (cropper, file) {
+ const that = this
return new Promise((resolve, reject) => {
function updateAvatar (avatar) {
- this.$store.state.api.backendInteractor.updateAvatar({ avatar })
+ that.$store.state.api.backendInteractor.updateAvatar({ avatar })
.then((user) => {
- this.$store.commit('addNewUsers', [user])
- this.$store.commit('setCurrentUser', user)
+ that.$store.commit('addNewUsers', [user])
+ that.$store.commit('setCurrentUser', user)
resolve()
})
.catch((err) => {
- reject(new Error(this.$t('upload.error.base') + ' ' + err.message))
+ reject(new Error(that.$t('upload.error.base') + ' ' + err.message))
})
}