Hide negative follower counts from glitch flavour

master
Thibaut Girka 6 years ago committed by ThibG
parent a1c56fcef1
commit 1b18eb49e3
  1. 2
      app/javascript/flavours/glitch/features/account/components/action_bar.js
  2. 4
      app/javascript/flavours/glitch/reducers/accounts_counters.js

@ -164,7 +164,7 @@ export default class ActionBar extends React.PureComponent {
<NavLink exact activeClassName='active' className='account__action-bar__tab' to={`/accounts/${account.get('id')}/followers`}> <NavLink exact activeClassName='active' className='account__action-bar__tab' to={`/accounts/${account.get('id')}/followers`}>
<FormattedMessage id='account.followers' defaultMessage='Followers' /> <FormattedMessage id='account.followers' defaultMessage='Followers' />
<strong><FormattedNumber value={account.get('followers_count')} /></strong> <strong>{ account.get('followers_count') < 0 ? '-' : <FormattedNumber value={account.get('followers_count')} /> }</strong>
</NavLink> </NavLink>
</div> </div>
</div> </div>

@ -141,9 +141,9 @@ export default function accountsCounters(state = initialState, action) {
if (action.alreadyFollowing) { if (action.alreadyFollowing) {
return state; return state;
} }
return state.updateIn([action.relationship.id, 'followers_count'], num => num + 1); return state.updateIn([action.relationship.id, 'followers_count'], num => num < 0 ? 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 => num < 0 ? num : Math.max(0, num - 1));
default: default:
return state; return state;
} }

Loading…
Cancel
Save