refs #1035 Re-fetch relationship after mute/block/follow action in sidebar

This commit is contained in:
AkiraFukushima 2019-09-15 22:34:27 +09:00
parent c6d244187e
commit 0579eb337e
1 changed files with 10 additions and 5 deletions

View File

@ -74,37 +74,42 @@ const actions: ActionTree<AccountProfileState, RootState> = {
commit(MUTATION_TYPES.CHANGE_RELATIONSHIP, res.data[0]) commit(MUTATION_TYPES.CHANGE_RELATIONSHIP, res.data[0])
return res.data return res.data
}, },
follow: async ({ commit, rootState }, account: Account) => { follow: async ({ commit, rootState, dispatch }, account: Account) => {
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1') const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res: Response<Relationship> = await client.post<Relationship>(`/accounts/${account.id}/follow`) const res: Response<Relationship> = await client.post<Relationship>(`/accounts/${account.id}/follow`)
commit(MUTATION_TYPES.CHANGE_RELATIONSHIP, res.data) commit(MUTATION_TYPES.CHANGE_RELATIONSHIP, res.data)
dispatch('fetchRelationship', account)
return res.data return res.data
}, },
unfollow: async ({ commit, rootState }, account: Account) => { unfollow: async ({ commit, rootState, dispatch }, account: Account) => {
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1') const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res: Response<Relationship> = await client.post<Relationship>(`/accounts/${account.id}/unfollow`) const res: Response<Relationship> = await client.post<Relationship>(`/accounts/${account.id}/unfollow`)
commit(MUTATION_TYPES.CHANGE_RELATIONSHIP, res.data) commit(MUTATION_TYPES.CHANGE_RELATIONSHIP, res.data)
dispatch('fetchRelationship', account)
return res.data return res.data
}, },
close: ({ commit }) => { close: ({ commit }) => {
commit(MUTATION_TYPES.CHANGE_ACCOUNT, null) commit(MUTATION_TYPES.CHANGE_ACCOUNT, null)
}, },
unmute: async ({ rootState, commit }, account: Account) => { unmute: async ({ rootState, commit, dispatch }, account: Account) => {
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1') const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res: Response<Relationship> = await client.post<Relationship>(`/accounts/${account.id}/unmute`) const res: Response<Relationship> = await client.post<Relationship>(`/accounts/${account.id}/unmute`)
commit(MUTATION_TYPES.CHANGE_RELATIONSHIP, res.data) commit(MUTATION_TYPES.CHANGE_RELATIONSHIP, res.data)
dispatch('fetchRelationship', account)
return res.data return res.data
}, },
block: async ({ rootState, commit }, account: Account) => { block: async ({ rootState, commit, dispatch }, account: Account) => {
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1') const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res: Response<Relationship> = await client.post<Relationship>(`/accounts/${account.id}/block`) const res: Response<Relationship> = await client.post<Relationship>(`/accounts/${account.id}/block`)
commit(MUTATION_TYPES.CHANGE_RELATIONSHIP, res.data) commit(MUTATION_TYPES.CHANGE_RELATIONSHIP, res.data)
dispatch('fetchRelationship', account)
return res.data return res.data
}, },
unblock: async ({ rootState, commit }, account: Account) => { unblock: async ({ rootState, commit, dispatch }, account: Account) => {
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1') const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res: Response<Relationship> = await client.post<Relationship>(`/accounts/${account.id}/unblock`) const res: Response<Relationship> = await client.post<Relationship>(`/accounts/${account.id}/unblock`)
commit(MUTATION_TYPES.CHANGE_RELATIONSHIP, res.data) commit(MUTATION_TYPES.CHANGE_RELATIONSHIP, res.data)
dispatch('fetchRelationship', account)
return res.data return res.data
} }
} }