Commit 1229622f authored by Tae Hoon's avatar Tae Hoon

refactor error handling of pinStatus

parent ce1d1913
...@@ -24,11 +24,8 @@ const ExtraButtons = { ...@@ -24,11 +24,8 @@ const ExtraButtons = {
}, },
pinStatus () { pinStatus () {
this.refreshPopper() this.refreshPopper()
this.$store.dispatch('pinStatus', this.status.id).then((status) => { this.$store.dispatch('pinStatus', this.status.id)
if (status.error) { .catch(err => this.$emit('onError', err.error.error))
this.$emit('onError', status.error)
}
})
}, },
unpinStatus () { unpinStatus () {
this.refreshPopper() this.refreshPopper()
......
...@@ -546,12 +546,8 @@ const statuses = { ...@@ -546,12 +546,8 @@ const statuses = {
.then(statuses => dispatch('addNewStatuses', { statuses, timeline: 'user', userId })) .then(statuses => dispatch('addNewStatuses', { statuses, timeline: 'user', userId }))
}, },
pinStatus ({ rootState, commit }, statusId) { pinStatus ({ rootState, commit }, statusId) {
return rootState.api.backendInteractor.pinOwnStatus(statusId).then((status) => { return rootState.api.backendInteractor.pinOwnStatus(statusId)
if (!status.error) { .then((status) => commit('setPinned', { status }))
commit('setPinned', { status })
}
return status
})
}, },
unpinStatus ({ rootState, commit }, statusId) { unpinStatus ({ rootState, commit }, statusId) {
rootState.api.backendInteractor.unpinOwnStatus(statusId) rootState.api.backendInteractor.unpinOwnStatus(statusId)
......
...@@ -213,19 +213,17 @@ const unfollowUser = ({id, credentials}) => { ...@@ -213,19 +213,17 @@ const unfollowUser = ({id, credentials}) => {
} }
const pinOwnStatus = ({ id, credentials }) => { const pinOwnStatus = ({ id, credentials }) => {
let url = MASTODON_PIN_OWN_STATUS(id) return promisedRequest(MASTODON_PIN_OWN_STATUS(id), {
return fetch(url, {
headers: authHeaders(credentials), headers: authHeaders(credentials),
method: 'POST' method: 'POST'
}).then((data) => data.json()) })
} }
const unpinOwnStatus = ({ id, credentials }) => { const unpinOwnStatus = ({ id, credentials }) => {
let url = MASTODON_UNPIN_OWN_STATUS(id) return promisedRequest(MASTODON_UNPIN_OWN_STATUS(id), {
return fetch(url, {
headers: authHeaders(credentials), headers: authHeaders(credentials),
method: 'POST' method: 'POST'
}).then((data) => data.json()) })
} }
const blockUser = ({id, credentials}) => { const blockUser = ({id, credentials}) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment