refactor error handling of pinStatus
This commit is contained in:
parent
ce1d19136d
commit
1229622fed
3 changed files with 8 additions and 17 deletions
|
@ -24,11 +24,8 @@ const ExtraButtons = {
|
|||
},
|
||||
pinStatus () {
|
||||
this.refreshPopper()
|
||||
this.$store.dispatch('pinStatus', this.status.id).then((status) => {
|
||||
if (status.error) {
|
||||
this.$emit('onError', status.error)
|
||||
}
|
||||
})
|
||||
this.$store.dispatch('pinStatus', this.status.id)
|
||||
.catch(err => this.$emit('onError', err.error.error))
|
||||
},
|
||||
unpinStatus () {
|
||||
this.refreshPopper()
|
||||
|
|
|
@ -546,12 +546,8 @@ const statuses = {
|
|||
.then(statuses => dispatch('addNewStatuses', { statuses, timeline: 'user', userId }))
|
||||
},
|
||||
pinStatus ({ rootState, commit }, statusId) {
|
||||
return rootState.api.backendInteractor.pinOwnStatus(statusId).then((status) => {
|
||||
if (!status.error) {
|
||||
commit('setPinned', { status })
|
||||
}
|
||||
return status
|
||||
})
|
||||
return rootState.api.backendInteractor.pinOwnStatus(statusId)
|
||||
.then((status) => commit('setPinned', { status }))
|
||||
},
|
||||
unpinStatus ({ rootState, commit }, statusId) {
|
||||
rootState.api.backendInteractor.unpinOwnStatus(statusId)
|
||||
|
|
|
@ -213,19 +213,17 @@ const unfollowUser = ({id, credentials}) => {
|
|||
}
|
||||
|
||||
const pinOwnStatus = ({ id, credentials }) => {
|
||||
let url = MASTODON_PIN_OWN_STATUS(id)
|
||||
return fetch(url, {
|
||||
return promisedRequest(MASTODON_PIN_OWN_STATUS(id), {
|
||||
headers: authHeaders(credentials),
|
||||
method: 'POST'
|
||||
}).then((data) => data.json())
|
||||
})
|
||||
}
|
||||
|
||||
const unpinOwnStatus = ({ id, credentials }) => {
|
||||
let url = MASTODON_UNPIN_OWN_STATUS(id)
|
||||
return fetch(url, {
|
||||
return promisedRequest(MASTODON_UNPIN_OWN_STATUS(id), {
|
||||
headers: authHeaders(credentials),
|
||||
method: 'POST'
|
||||
}).then((data) => data.json())
|
||||
})
|
||||
}
|
||||
|
||||
const blockUser = ({id, credentials}) => {
|
||||
|
|
Loading…
Reference in a new issue