From e14720419f743f630eec8a671833eb08923e3dee Mon Sep 17 00:00:00 2001
From: taehoon
Date: Sat, 16 Mar 2019 08:40:46 -0400
Subject: [PATCH] Switch to mastoapi for updating user profile
---
src/components/user_settings/user_settings.js | 14 ++++++--------
src/services/api/api.service.js | 13 ++++++-------
2 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index bc824393..6b367e4f 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -110,11 +110,11 @@ const UserSettings = {
},
methods: {
updateProfile () {
- const name = this.newName
- const description = this.newBio
+ 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
@@ -125,8 +125,8 @@ const UserSettings = {
this.$store.state.api.backendInteractor
.updateProfile({
params: {
- name,
- description,
+ display_name,
+ note,
locked,
// Backend notation.
/* eslint-disable camelcase */
@@ -137,10 +137,8 @@ const UserSettings = {
show_role
/* eslint-enable camelcase */
}}).then((user) => {
- if (!user.error) {
- this.$store.commit('addNewUsers', [user])
- this.$store.commit('setCurrentUser', user)
- }
+ this.$store.commit('addNewUsers', [user])
+ this.$store.commit('setCurrentUser', user)
})
},
changeVis (visibility) {
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index eaebb3f1..9338c495 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -4,7 +4,6 @@ const ALL_FOLLOWING_URL = '/api/qvitter/allfollowing'
const MENTIONS_URL = '/api/statuses/mentions.json'
const REGISTRATION_URL = '/api/account/register.json'
const BG_UPDATE_URL = '/api/qvitter/update_background_image.json'
-const PROFILE_UPDATE_URL = '/api/account/update_profile.json'
const EXTERNAL_PROFILE_URL = '/api/externalprofile/show.json'
const QVITTER_USER_NOTIFICATIONS_READ_URL = '/api/qvitter/statuses/notifications/read.json'
const FOLLOW_IMPORT_URL = '/api/pleroma/follow_import'
@@ -126,9 +125,7 @@ const updateBanner = ({credentials, banner}) => {
// description
const updateProfile = ({credentials, params}) => {
// Always include these fields, because they might be empty or false
- const fields = ['description', 'locked', 'no_rich_text', 'hide_follows', 'hide_followers', 'show_role']
- let url = PROFILE_UPDATE_URL
-
+ const fields = ['note', 'locked', 'no_rich_text', 'hide_follows', 'hide_followers', 'show_role']
const form = new FormData()
each(params, (value, key) => {
@@ -136,11 +133,13 @@ const updateProfile = ({credentials, params}) => {
form.append(key, value)
}
})
- return fetch(url, {
+ return fetch(MASTODON_PROFILE_UPDATE_URL, {
headers: authHeaders(credentials),
- method: 'POST',
+ method: 'PATCH',
body: form
- }).then((data) => data.json())
+ })
+ .then((data) => data.json())
+ .then((data) => parseUser(data))
}
// Params needed: