From ff3a7e8b5ba4a46c740eea8e59b8746088e09a05 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Tue, 7 May 2019 23:17:52 -0400
Subject: [PATCH] update status interaction upon retweet action response
---
src/modules/statuses.js | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/modules/statuses.js b/src/modules/statuses.js
index 3559e5dd..9556c6d4 100644
--- a/src/modules/statuses.js
+++ b/src/modules/statuses.js
@@ -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 })