Date: Fri, 22 Mar 2019 13:00:58 -0400
Subject: [PATCH 4/7] 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 5ba8f04ed6..01361e2568 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 129e6f469f..d2b86e9ea3 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 6b367e4f5b..820feba655 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))
})
}
From 2c4af6693ac87f5008566b6d9a61e9b4c9b3bdd8 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Sat, 27 Apr 2019 14:04:30 -0400
Subject: [PATCH 5/7] clean up
---
src/components/user_settings/user_settings.js | 30 +++++++------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index 820feba655..ae4d069413 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -110,31 +110,21 @@ const UserSettings = {
},
methods: {
updateProfile () {
- const note = this.newBio
- const locked = this.newLocked
- // Backend notation.
- /* eslint-disable camelcase */
- const display_name = this.newName
- const default_scope = this.newDefaultScope
- const no_rich_text = this.newNoRichText
- const hide_follows = this.hideFollows
- const hide_followers = this.hideFollowers
- const show_role = this.showRole
-
- /* eslint-enable camelcase */
this.$store.state.api.backendInteractor
.updateProfile({
params: {
- display_name,
- note,
- locked,
+ note: this.newBio,
+ locked: this.newLocked,
+ source: {
+ privacy: this.newDefaultScope
+ },
// Backend notation.
/* eslint-disable camelcase */
- default_scope,
- no_rich_text,
- hide_follows,
- hide_followers,
- show_role
+ display_name: this.newName,
+ no_rich_text: this.newNoRichText,
+ hide_follows: this.hideFollows,
+ hide_followers: this.hideFollowers,
+ show_role: this.showRole
/* eslint-enable camelcase */
}}).then((user) => {
this.$store.commit('addNewUsers', [user])
From 904a64de8951356d0e1a798349661039d5821d32 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Sat, 27 Apr 2019 14:20:32 -0400
Subject: [PATCH 6/7] use json content type
---
src/services/api/api.service.js | 25 +++++++------------------
1 file changed, 7 insertions(+), 18 deletions(-)
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index 9338c495a5..1cf47bb80f 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -118,27 +118,16 @@ const updateBanner = ({credentials, banner}) => {
.then((data) => parseUser(data))
}
-// Params
-// name
-// url
-// location
-// description
const updateProfile = ({credentials, params}) => {
- // Always include these fields, because they might be empty or false
- const fields = ['note', 'locked', 'no_rich_text', 'hide_follows', 'hide_followers', 'show_role']
- const form = new FormData()
-
- each(params, (value, key) => {
- if (fields.includes(key) || value) {
- form.append(key, value)
- }
- })
- return fetch(MASTODON_PROFILE_UPDATE_URL, {
- headers: authHeaders(credentials),
+ return promisedRequest(MASTODON_PROFILE_UPDATE_URL, {
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json',
+ ...authHeaders(credentials)
+ },
method: 'PATCH',
- body: form
+ body: JSON.stringify(params)
})
- .then((data) => data.json())
.then((data) => parseUser(data))
}
From 3665c86d709f3a04ae3471d09b84a69c8a8c9172 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Sat, 27 Apr 2019 21:51:17 -0400
Subject: [PATCH 7/7] use default_scope parameter
---
src/components/user_settings/user_settings.js | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index ae4d069413..5a7ff44823 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -115,12 +115,10 @@ const UserSettings = {
params: {
note: this.newBio,
locked: this.newLocked,
- source: {
- privacy: this.newDefaultScope
- },
// Backend notation.
/* eslint-disable camelcase */
display_name: this.newName,
+ default_scope: this.newDefaultScope,
no_rich_text: this.newNoRichText,
hide_follows: this.hideFollows,
hide_followers: this.hideFollowers,