some consistency

This commit is contained in:
Henry Jameson 2019-01-17 23:01:38 +03:00
parent a680f7d684
commit 8f4fbf8571
3 changed files with 12 additions and 5 deletions

View file

@ -209,7 +209,7 @@ const users = {
store.rootState.api.backendInteractor.verifyCredentials(accessToken) store.rootState.api.backendInteractor.verifyCredentials(accessToken)
.then((data) => { .then((data) => {
if (!data.error) { if (!data.error) {
const { user } = data const user = data
// user.credentials = userCredentials // user.credentials = userCredentials
user.credentials = accessToken user.credentials = accessToken
commit('setCurrentUser', user) commit('setCurrentUser', user)

View file

@ -375,9 +375,7 @@ const verifyCredentials = (user) => {
} }
} }
}) })
.then((data) => ({ .then((data) => data.error ? data : parseUser(data))
user: parseUser(data)
}))
} }
const favorite = ({ id, credentials }) => { const favorite = ({ id, credentials }) => {
@ -429,6 +427,16 @@ const postStatus = ({credentials, status, spoilerText, visibility, sensitive, me
method: 'POST', method: 'POST',
headers: authHeaders(credentials) headers: authHeaders(credentials)
}) })
.then((response) => {
if (response.ok) {
return response.json()
} else {
return {
error: response
}
}
})
.then((data) => data.error ? data : parseStatus(data))
} }
const deleteStatus = ({ id, credentials }) => { const deleteStatus = ({ id, credentials }) => {

View file

@ -5,7 +5,6 @@ const postStatus = ({ store, status, spoilerText, visibility, sensitive, media =
const mediaIds = map(media, 'id') const mediaIds = map(media, 'id')
return apiService.postStatus({credentials: store.state.users.currentUser.credentials, status, spoilerText, visibility, sensitive, mediaIds, inReplyToStatusId, contentType, noAttachmentLinks: store.state.instance.noAttachmentLinks}) return apiService.postStatus({credentials: store.state.users.currentUser.credentials, status, spoilerText, visibility, sensitive, mediaIds, inReplyToStatusId, contentType, noAttachmentLinks: store.state.instance.noAttachmentLinks})
.then((data) => data.json())
.then((data) => { .then((data) => {
if (!data.error) { if (!data.error) {
store.dispatch('addNewStatuses', { store.dispatch('addNewStatuses', {