From ca9ac011a51fc7c8b3031b7c688617dd54049e12 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 4 Jun 2018 05:15:50 +0200 Subject: [PATCH] Display numbers in account header using shortNumberFormat for consistency (#7723) --- app/javascript/mastodon/components/hashtag.js | 11 ++--------- .../features/account/components/action_bar.js | 9 +++++---- app/javascript/mastodon/utils/numbers.js | 10 ++++++++++ 3 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 app/javascript/mastodon/utils/numbers.js diff --git a/app/javascript/mastodon/components/hashtag.js b/app/javascript/mastodon/components/hashtag.js index cc37a91e2f..a407df31e3 100644 --- a/app/javascript/mastodon/components/hashtag.js +++ b/app/javascript/mastodon/components/hashtag.js @@ -1,16 +1,9 @@ import React from 'react'; import { Sparklines, SparklinesCurve } from 'react-sparklines'; import { Link } from 'react-router-dom'; -import { FormattedMessage, FormattedNumber } from 'react-intl'; +import { FormattedMessage } from 'react-intl'; import ImmutablePropTypes from 'react-immutable-proptypes'; - -const shortNumberFormat = number => { - if (number < 1000) { - return ; - } else { - return K; - } -}; +import { shortNumberFormat } from '../utils/numbers'; const Hashtag = ({ hashtag }) => (
diff --git a/app/javascript/mastodon/features/account/components/action_bar.js b/app/javascript/mastodon/features/account/components/action_bar.js index 3a1f92811e..2d0f72be24 100644 --- a/app/javascript/mastodon/features/account/components/action_bar.js +++ b/app/javascript/mastodon/features/account/components/action_bar.js @@ -3,8 +3,9 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import PropTypes from 'prop-types'; import DropdownMenuContainer from '../../../containers/dropdown_menu_container'; import { Link } from 'react-router-dom'; -import { defineMessages, injectIntl, FormattedMessage, FormattedNumber } from 'react-intl'; +import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { me } from '../../../initial_state'; +import { shortNumberFormat } from '../../../utils/numbers'; const messages = defineMessages({ mention: { id: 'account.mention', defaultMessage: 'Mention @{name}' }, @@ -146,17 +147,17 @@ export default class ActionBar extends React.PureComponent {
- + {shortNumberFormat(account.get('statuses_count'))} - + {shortNumberFormat(account.get('following_count'))} - + {shortNumberFormat(account.get('followers_count'))}
diff --git a/app/javascript/mastodon/utils/numbers.js b/app/javascript/mastodon/utils/numbers.js new file mode 100644 index 0000000000..fdd8269ae2 --- /dev/null +++ b/app/javascript/mastodon/utils/numbers.js @@ -0,0 +1,10 @@ +import React, { Fragment } from 'react'; +import { FormattedNumber } from 'react-intl'; + +export const shortNumberFormat = number => { + if (number < 1000) { + return ; + } else { + return K; + } +};