diff --git a/src/shared/components/common/badges.tsx b/src/shared/components/common/badges.tsx new file mode 100644 index 00000000..49c0888b --- /dev/null +++ b/src/shared/components/common/badges.tsx @@ -0,0 +1,128 @@ +import { Link } from "inferno-router"; +import { + CommunityAggregates, + CommunityId, + SiteAggregates, +} from "lemmy-js-client"; +import { i18n } from "../../i18next"; +import { numToSI } from "../../utils"; + +interface BadgesProps { + counts: CommunityAggregates | SiteAggregates; + communityId?: CommunityId; +} + +const isCommunityAggregates = ( + counts: CommunityAggregates | SiteAggregates +): counts is CommunityAggregates => { + return "subscribers" in counts; +}; + +const isSiteAggregates = ( + counts: CommunityAggregates | SiteAggregates +): counts is SiteAggregates => { + return "communities" in counts; +}; + +export const Badges = ({ counts, communityId }: BadgesProps) => { + return ( + + ); +}; diff --git a/src/shared/components/community/sidebar.tsx b/src/shared/components/community/sidebar.tsx index f4c74528..720e596f 100644 --- a/src/shared/components/community/sidebar.tsx +++ b/src/shared/components/community/sidebar.tsx @@ -24,8 +24,8 @@ import { hostname, mdToHtml, myAuthRequired, - numToSI, } from "../../utils"; +import { Badges } from "../common/badges"; import { BannerIconHeader } from "../common/banner-icon-header"; import { Icon, PurgeWarning, Spinner } from "../common/icon"; import { CommunityForm } from "../community/community-form"; @@ -158,7 +158,10 @@ export class Sidebar extends Component {
{this.description()} - {this.badges()} + {this.mods()}
@@ -233,93 +236,6 @@ export class Sidebar extends Component { ); } - badges() { - const community_view = this.props.community_view; - const counts = community_view.counts; - return ( - - ); - } - mods() { return (