This commit is contained in:
taehoon 2019-05-07 23:21:19 -04:00
parent 28c2a700e1
commit a54cf47ba5

View file

@ -488,8 +488,8 @@ export const mutations = {
}, },
addFavsAndRepeats (state, { id, favoritedByUsers, rebloggedByUsers }) { addFavsAndRepeats (state, { id, favoritedByUsers, rebloggedByUsers }) {
const newStatus = state.allStatusesObject[id] const newStatus = state.allStatusesObject[id]
newStatus.favoritedBy = favoritedByUsers newStatus.favoritedBy = favoritedByUsers.filter(_ => _)
newStatus.rebloggedBy = rebloggedByUsers newStatus.rebloggedBy = rebloggedByUsers.filter(_ => _)
} }
} }
@ -525,32 +525,24 @@ const statuses = {
// Optimistic favoriting... // Optimistic favoriting...
commit('setFavorited', { status, value: true }) commit('setFavorited', { status, value: true })
apiService.favorite({ id: status.id, credentials: rootState.users.currentUser.credentials }) apiService.favorite({ id: status.id, credentials: rootState.users.currentUser.credentials })
.then(status => { .then(status => commit('setFavoritedConfirm', { status, user: rootState.users.currentUser }))
commit('setFavoritedConfirm', { status, user: rootState.users.currentUser })
})
}, },
unfavorite ({ rootState, commit }, status) { unfavorite ({ rootState, commit }, status) {
// Optimistic favoriting... // Optimistic favoriting...
commit('setFavorited', { status, value: false }) commit('setFavorited', { status, value: false })
apiService.unfavorite({ id: status.id, credentials: rootState.users.currentUser.credentials }) apiService.unfavorite({ id: status.id, credentials: rootState.users.currentUser.credentials })
.then(status => { .then(status => commit('setFavoritedConfirm', { status, user: rootState.users.currentUser }))
commit('setFavoritedConfirm', { status, user: rootState.users.currentUser })
})
}, },
retweet ({ rootState, commit }, status) { retweet ({ rootState, commit }, status) {
// 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 => { .then(status => commit('setRetweetedConfirm', { status: status.retweeted_status, user: rootState.users.currentUser }))
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 => { .then(status => commit('setRetweetedConfirm', { status, user: rootState.users.currentUser }))
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 })
@ -567,14 +559,7 @@ const statuses = {
rootState.api.backendInteractor.fetchFavoritedByUsers(id), rootState.api.backendInteractor.fetchFavoritedByUsers(id),
rootState.api.backendInteractor.fetchRebloggedByUsers(id) rootState.api.backendInteractor.fetchRebloggedByUsers(id)
]).then(([favoritedByUsers, rebloggedByUsers]) => ]).then(([favoritedByUsers, rebloggedByUsers]) =>
commit( commit('addFavsAndRepeats', { id, favoritedByUsers, rebloggedByUsers })
'addFavsAndRepeats',
{
id,
favoritedByUsers: favoritedByUsers.filter(_ => _),
rebloggedByUsers: rebloggedByUsers.filter(_ => _)
}
)
) )
} }
}, },