]> cat aescling's git repositories - mastodon.git/commitdiff
Hide negative follower counts from glitch flavour
authorThibaut Girka <thib@sitedethib.com>
Mon, 17 Dec 2018 20:23:44 +0000 (21:23 +0100)
committerThibG <thib@sitedethib.com>
Thu, 20 Dec 2018 13:51:12 +0000 (14:51 +0100)
app/javascript/flavours/glitch/features/account/components/action_bar.js
app/javascript/flavours/glitch/reducers/accounts_counters.js

index ffa5b7e5ebe92576f6dffdb59d7fbb4ae56fe766..fdacb72983e534f4baafe30e121d29e1a9a88875 100644 (file)
@@ -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`}>
               <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>
           </div>
         </div>
index 64dff9b55a0d8dde1324f24e61edc82952503c9d..acf363ca53b6454c5b71130d3e93726ede84f43a 100644 (file)
@@ -141,9 +141,9 @@ export default function accountsCounters(state = initialState, action) {
     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 < 0 ? num : num + 1);
   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:
     return state;
   }