]> cat aescling's git repositories - mastodon.git/commitdiff
Don't update follower counts on reblog toggle
authoraschmitz <aschmitz@lardbucket.org>
Sun, 12 Nov 2017 03:42:22 +0000 (21:42 -0600)
committeraschmitz <aschmitz@lardbucket.org>
Sun, 12 Nov 2017 03:42:22 +0000 (21:42 -0600)
app/javascript/mastodon/actions/accounts.js
app/javascript/mastodon/reducers/accounts_counters.js

index cabf72bde288771287bd32761838605f1557f348..f63325658d6af0e8b8c9be371da1231ec38503d8 100644 (file)
@@ -107,10 +107,11 @@ export function fetchAccountFail(id, error) {
 
 export function followAccount(id, reblogs = true) {
   return (dispatch, getState) => {
+    const alreadyFollowing = getState().getIn(['relationships', id, 'following']);
     dispatch(followAccountRequest(id));
 
     api(getState).post(`/api/v1/accounts/${id}/follow`, { reblogs }).then(response => {
-      dispatch(followAccountSuccess(response.data));
+      dispatch(followAccountSuccess(response.data, alreadyFollowing));
     }).catch(error => {
       dispatch(followAccountFail(error));
     });
@@ -136,10 +137,11 @@ export function followAccountRequest(id) {
   };
 };
 
-export function followAccountSuccess(relationship) {
+export function followAccountSuccess(relationship, alreadyFollowing) {
   return {
     type: ACCOUNT_FOLLOW_SUCCESS,
     relationship,
+    alreadyFollowing,
   };
 };
 
index 1ed0fe3e39f69d0198b215ab27f13c797b1f5b1e..1f795199b75ab2b7ad8171feb4e26062f2eb2f2a 100644 (file)
@@ -126,6 +126,7 @@ export default function accountsCounters(state = initialState, action) {
   case STATUS_FETCH_SUCCESS:
     return normalizeAccountFromStatus(state, action.status);
   case ACCOUNT_FOLLOW_SUCCESS:
+    if (action.alreadyFollowing) { return state; }
     return state.updateIn([action.relationship.id, 'followers_count'], num => num + 1);
   case ACCOUNT_UNFOLLOW_SUCCESS:
     return state.updateIn([action.relationship.id, 'followers_count'], num => Math.max(0, num - 1));