forked from AkkomaGang/akkoma-fe
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
|
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 }) {
|
setDeleted (state, { status }) {
|
||||||
const newStatus = state.allStatusesObject[status.id]
|
const newStatus = state.allStatusesObject[status.id]
|
||||||
newStatus.deleted = true
|
newStatus.deleted = true
|
||||||
|
@ -521,10 +532,16 @@ const statuses = {
|
||||||
// Optimistic retweeting...
|
// Optimistic retweeting...
|
||||||
commit('setRetweeted', { status, value: true })
|
commit('setRetweeted', { status, value: true })
|
||||||
apiService.retweet({ id: status.id, credentials: rootState.users.currentUser.credentials })
|
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) {
|
unretweet ({ rootState, commit }, status) {
|
||||||
commit('setRetweeted', { status, value: false })
|
commit('setRetweeted', { status, value: false })
|
||||||
apiService.unretweet({ id: status.id, credentials: rootState.users.currentUser.credentials })
|
apiService.unretweet({ id: status.id, credentials: rootState.users.currentUser.credentials })
|
||||||
|
.then(status => {
|
||||||
|
commit('setRetweetedConfirm', { status, user: rootState.users.currentUser })
|
||||||
|
})
|
||||||
},
|
},
|
||||||
queueFlush ({ rootState, commit }, { timeline, id }) {
|
queueFlush ({ rootState, commit }, { timeline, id }) {
|
||||||
commit('queueFlush', { timeline, id })
|
commit('queueFlush', { timeline, id })
|
||||||
|
|
Loading…
Reference in a new issue