mirror of
https://git.youjo.love/youjo/youjo-fe.git
synced 2024-11-20 13:59:55 +01:00
update status interaction upon retweet action response
This commit is contained in:
parent
f75e40e462
commit
ff3a7e8b5b
1 changed files with 17 additions and 0 deletions
|
@ -428,6 +428,17 @@ export const mutations = {
|
|||
|
||||
newStatus.repeated = value
|
||||
},
|
||||
setRetweetedConfirm (state, { status, user }) {
|
||||
const newStatus = state.allStatusesObject[status.id]
|
||||
newStatus.repeated = status.repeated
|
||||
newStatus.repeat_num = status.repeat_num
|
||||
const index = findIndex(newStatus.rebloggedBy, { id: user.id })
|
||||
if (index !== -1 && !newStatus.repeated) {
|
||||
newStatus.rebloggedBy.splice(index, 1)
|
||||
} else if (index === -1 && newStatus.repeated) {
|
||||
newStatus.rebloggedBy.push(user)
|
||||
}
|
||||
},
|
||||
setDeleted (state, { status }) {
|
||||
const newStatus = state.allStatusesObject[status.id]
|
||||
newStatus.deleted = true
|
||||
|
@ -521,10 +532,16 @@ const statuses = {
|
|||
// Optimistic retweeting...
|
||||
commit('setRetweeted', { status, value: true })
|
||||
apiService.retweet({ id: status.id, credentials: rootState.users.currentUser.credentials })
|
||||
.then(status => {
|
||||
commit('setRetweetedConfirm', { status: status.retweeted_status, user: rootState.users.currentUser })
|
||||
})
|
||||
},
|
||||
unretweet ({ rootState, commit }, status) {
|
||||
commit('setRetweeted', { status, value: false })
|
||||
apiService.unretweet({ id: status.id, credentials: rootState.users.currentUser.credentials })
|
||||
.then(status => {
|
||||
commit('setRetweetedConfirm', { status, user: rootState.users.currentUser })
|
||||
})
|
||||
},
|
||||
queueFlush ({ rootState, commit }, { timeline, id }) {
|
||||
commit('queueFlush', { timeline, id })
|
||||
|
|
Loading…
Reference in a new issue