mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-17 15:35:10 +00:00
Don't update follower counts on reblog toggle
This commit is contained in:
parent
5128c4261e
commit
48c705bbad
|
@ -107,10 +107,11 @@ export function fetchAccountFail(id, error) {
|
||||||
|
|
||||||
export function followAccount(id, reblogs = true) {
|
export function followAccount(id, reblogs = true) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
|
const alreadyFollowing = getState().getIn(['relationships', id, 'following']);
|
||||||
dispatch(followAccountRequest(id));
|
dispatch(followAccountRequest(id));
|
||||||
|
|
||||||
api(getState).post(`/api/v1/accounts/${id}/follow`, { reblogs }).then(response => {
|
api(getState).post(`/api/v1/accounts/${id}/follow`, { reblogs }).then(response => {
|
||||||
dispatch(followAccountSuccess(response.data));
|
dispatch(followAccountSuccess(response.data, alreadyFollowing));
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
dispatch(followAccountFail(error));
|
dispatch(followAccountFail(error));
|
||||||
});
|
});
|
||||||
|
@ -136,10 +137,11 @@ export function followAccountRequest(id) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export function followAccountSuccess(relationship) {
|
export function followAccountSuccess(relationship, alreadyFollowing) {
|
||||||
return {
|
return {
|
||||||
type: ACCOUNT_FOLLOW_SUCCESS,
|
type: ACCOUNT_FOLLOW_SUCCESS,
|
||||||
relationship,
|
relationship,
|
||||||
|
alreadyFollowing,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,7 @@ export default function accountsCounters(state = initialState, action) {
|
||||||
case STATUS_FETCH_SUCCESS:
|
case STATUS_FETCH_SUCCESS:
|
||||||
return normalizeAccountFromStatus(state, action.status);
|
return normalizeAccountFromStatus(state, action.status);
|
||||||
case ACCOUNT_FOLLOW_SUCCESS:
|
case ACCOUNT_FOLLOW_SUCCESS:
|
||||||
|
if (action.alreadyFollowing) { return state; }
|
||||||
return state.updateIn([action.relationship.id, 'followers_count'], num => num + 1);
|
return state.updateIn([action.relationship.id, 'followers_count'], num => num + 1);
|
||||||
case ACCOUNT_UNFOLLOW_SUCCESS:
|
case ACCOUNT_UNFOLLOW_SUCCESS:
|
||||||
return state.updateIn([action.relationship.id, 'followers_count'], num => Math.max(0, num - 1));
|
return state.updateIn([action.relationship.id, 'followers_count'], num => Math.max(0, num - 1));
|
||||||
|
|
Loading…
Reference in a new issue