diff options
author | aschmitz <aschmitz@lardbucket.org> | 2017-11-11 21:42:22 -0600 |
---|---|---|
committer | aschmitz <aschmitz@lardbucket.org> | 2017-11-11 21:42:22 -0600 |
commit | 48c705bbadd8dfba83030f304154c822d98a7da7 (patch) | |
tree | a4c37f7772bbcd9f1a2c5e05455dbfa2129d06ac | |
parent | 5128c4261e8c067321e70ffda560f14036f56bb0 (diff) |
Don't update follower counts on reblog toggle
-rw-r--r-- | app/javascript/mastodon/actions/accounts.js | 6 | ||||
-rw-r--r-- | app/javascript/mastodon/reducers/accounts_counters.js | 1 |
2 files changed, 5 insertions, 2 deletions
diff --git a/app/javascript/mastodon/actions/accounts.js b/app/javascript/mastodon/actions/accounts.js index cabf72bde..f63325658 100644 --- a/app/javascript/mastodon/actions/accounts.js +++ b/app/javascript/mastodon/actions/accounts.js @@ -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, }; }; diff --git a/app/javascript/mastodon/reducers/accounts_counters.js b/app/javascript/mastodon/reducers/accounts_counters.js index 1ed0fe3e3..1f795199b 100644 --- a/app/javascript/mastodon/reducers/accounts_counters.js +++ b/app/javascript/mastodon/reducers/accounts_counters.js @@ -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)); |