Skip to content

Commit

Permalink
fix subscriber count (#735)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkasdorf committed Jul 17, 2023
1 parent dabf3f1 commit 7afe1b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/components/screens/Feed/CommunityFeedScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import CustomButton from "../../common/Buttons/CustomButton";
import FeedView from "./components/FeedView";
import LoadingErrorView from "../../common/Loading/LoadingErrorView";
import NotFoundView from "../../common/Loading/NotFoundView";
import { shortenNumber } from "../../../helpers/NumberHelper";

function FeedsCommunityScreen({
route,
Expand Down Expand Up @@ -88,7 +89,9 @@ function FeedsCommunityScreen({
size={20}
/>
<Text color={theme.colors.app.textSecondary}>
{communityFeed.feed.community.counts.subscribers}
{shortenNumber(
communityFeed.feed.community.counts.subscribers
)}
</Text>
</HStack>
<HStack space={1}>
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/NumberHelper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export function shortenNumber(number) {
number += 3000;
const suffixes = ["", "k", "M", "B", "T"];
const magnitude = Math.floor(Math.log10(number) / 3);
const suffix = suffixes[magnitude];
const shortened = (number / 10 ** (magnitude * 3)).toFixed(1);
const shortened = (number / 10 ** (magnitude * 3)).toFixed(0);
return String(shortened) + suffix;
}

0 comments on commit 7afe1b9

Please sign in to comment.