Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Si simplifier #418

Merged
merged 2 commits into from
Sep 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/shared/components/app/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
isBrowser,
notifyComment,
notifyPrivateMessage,
numToSI,
setTheme,
showAvatars,
supportLemmyUrl,
Expand Down Expand Up @@ -189,7 +190,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
"unread_messages"
)}`}
>
{this.state.unreadCount}
{numToSI(this.state.unreadCount)}
</span>
)}
</button>
Expand Down Expand Up @@ -309,7 +310,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
"unread_messages"
)}`}
>
{this.state.unreadCount}
{numToSI(this.state.unreadCount)}
</span>
)}
</Link>
Expand Down
15 changes: 12 additions & 3 deletions src/shared/components/comment/comment-node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
getUnixTime,
isMod,
mdToHtml,
numToSI,
setupTippy,
showScores,
wsClient,
Expand Down Expand Up @@ -217,9 +218,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
class="mr-1 font-weight-bold"
aria-label={i18n.t("number_of_points", {
count: this.state.score,
formattedCount: this.state.score,
})}
>
{this.state.score}
{numToSI(this.state.score)}
</span>
</a>
<span className="mr-1">•</span>
Expand Down Expand Up @@ -293,7 +295,9 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
<Icon icon="arrow-up1" classes="icon-inline" />
{showScores() &&
this.state.upvotes !== this.state.score && (
<span class="ml-1">{this.state.upvotes}</span>
<span class="ml-1">
{numToSI(this.state.upvotes)}
</span>
)}
</button>
{this.props.enableDownvotes && (
Expand All @@ -310,7 +314,9 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
<Icon icon="arrow-down1" classes="icon-inline" />
{showScores() &&
this.state.upvotes !== this.state.score && (
<span class="ml-1">{this.state.downvotes}</span>
<span class="ml-1">
{numToSI(this.state.downvotes)}
</span>
)}
</button>
)}
Expand Down Expand Up @@ -1289,14 +1295,17 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
get pointsTippy(): string {
let points = i18n.t("number_of_points", {
count: this.state.score,
formattedCount: this.state.score,
});

let upvotes = i18n.t("number_of_upvotes", {
count: this.state.upvotes,
formattedCount: this.state.upvotes,
});

let downvotes = i18n.t("number_of_downvotes", {
count: this.state.downvotes,
formattedCount: this.state.downvotes,
});

return `${points} • ${upvotes} • ${downvotes}`;
Expand Down
13 changes: 9 additions & 4 deletions src/shared/components/community/communities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
getListingTypeFromPropsNoDefault,
getPageFromProps,
isBrowser,
numToSI,
setIsoData,
setOptionalAuth,
showLocal,
Expand Down Expand Up @@ -160,13 +161,17 @@ export class Communities extends Component<any, CommunitiesState> {
<td>
<CommunityLink community={cv.community} />
</td>
<td class="text-right">{cv.counts.subscribers}</td>
<td class="text-right">{cv.counts.users_active_month}</td>
<td class="text-right">
{numToSI(cv.counts.subscribers)}
</td>
<td class="text-right">
{numToSI(cv.counts.users_active_month)}
</td>
<td class="text-right d-none d-lg-table-cell">
{cv.counts.posts}
{numToSI(cv.counts.posts)}
</td>
<td class="text-right d-none d-lg-table-cell">
{cv.counts.comments}
{numToSI(cv.counts.comments)}
</td>
<td class="text-right">
{cv.subscribed ? (
Expand Down
27 changes: 24 additions & 3 deletions src/shared/components/community/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ import {
} from "lemmy-js-client";
import { i18n } from "../../i18next";
import { UserService, WebSocketService } from "../../services";
import { authField, getUnixTime, mdToHtml, wsClient } from "../../utils";
import {
authField,
getUnixTime,
mdToHtml,
numToSI,
wsClient,
} from "../../utils";
import { BannerIconHeader } from "../common/banner-icon-header";
import { Icon } from "../common/icon";
import { CommunityForm } from "../community/community-form";
Expand Down Expand Up @@ -143,67 +149,82 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
return (
<ul class="my-1 list-inline">
<li className="list-inline-item badge badge-secondary">
{i18n.t("number_online", { count: this.props.online })}
{i18n.t("number_online", {
count: this.props.online,
formattedCount: numToSI(this.props.online),
})}
</li>
<li
className="list-inline-item badge badge-secondary pointer"
data-tippy-content={`${i18n.t("number_of_users", {
count: counts.users_active_day,
formattedCount: counts.users_active_day,
})} ${i18n.t("active_in_the_last")} ${i18n.t("day")}`}
>
{i18n.t("number_of_users", {
count: counts.users_active_day,
formattedCount: numToSI(counts.users_active_day),
})}{" "}
/ {i18n.t("day")}
</li>
<li
className="list-inline-item badge badge-secondary pointer"
data-tippy-content={`${i18n.t("number_of_users", {
count: counts.users_active_week,
formattedCount: counts.users_active_week,
})} ${i18n.t("active_in_the_last")} ${i18n.t("week")}`}
>
{i18n.t("number_of_users", {
count: counts.users_active_week,
formattedCount: numToSI(counts.users_active_week),
})}{" "}
/ {i18n.t("week")}
</li>
<li
className="list-inline-item badge badge-secondary pointer"
data-tippy-content={`${i18n.t("number_of_users", {
count: counts.users_active_month,
formattedCount: counts.users_active_month,
})} ${i18n.t("active_in_the_last")} ${i18n.t("month")}`}
>
{i18n.t("number_of_users", {
count: counts.users_active_month,
formattedCount: numToSI(counts.users_active_month),
})}{" "}
/ {i18n.t("month")}
</li>
<li
className="list-inline-item badge badge-secondary pointer"
data-tippy-content={`${i18n.t("number_of_users", {
count: counts.users_active_half_year,
formattedCount: counts.users_active_half_year,
})} ${i18n.t("active_in_the_last")} ${i18n.t("number_of_months", {
count: 6,
formattedCount: 6,
})}`}
>
{i18n.t("number_of_users", {
count: counts.users_active_half_year,
formattedCount: numToSI(counts.users_active_half_year),
})}{" "}
/ {i18n.t("number_of_months", { count: 6 })}
/ {i18n.t("number_of_months", { count: 6, formattedCount: 6 })}
</li>
<li className="list-inline-item badge badge-secondary">
{i18n.t("number_of_subscribers", {
count: counts.subscribers,
formattedCount: numToSI(counts.subscribers),
})}
</li>
<li className="list-inline-item badge badge-secondary">
{i18n.t("number_of_posts", {
count: counts.posts,
formattedCount: numToSI(counts.posts),
})}
</li>
<li className="list-inline-item badge badge-secondary">
{i18n.t("number_of_comments", {
count: counts.comments,
formattedCount: numToSI(counts.comments),
})}
</li>
<li className="list-inline-item">
Expand Down
21 changes: 19 additions & 2 deletions src/shared/components/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
getSortTypeFromProps,
mdToHtml,
notifyPost,
numToSI,
restoreScrollPosition,
saveCommentRes,
saveScrollPosition,
Expand Down Expand Up @@ -503,72 +504,88 @@ export class Home extends Component<any, HomeState> {
return (
<ul class="my-2 list-inline">
<li className="list-inline-item badge badge-secondary">
{i18n.t("number_online", { count: this.state.siteRes.online })}
{i18n.t("number_online", {
count: this.state.siteRes.online,
formattedCount: numToSI(this.state.siteRes.online),
})}
</li>
<li
className="list-inline-item badge badge-secondary pointer"
data-tippy-content={`${i18n.t("number_of_users", {
count: counts.users_active_day,
formattedCount: counts.users_active_day,
})} ${i18n.t("active_in_the_last")} ${i18n.t("day")}`}
>
{i18n.t("number_of_users", {
count: counts.users_active_day,
formattedCount: numToSI(counts.users_active_day),
})}{" "}
/ {i18n.t("day")}
</li>
<li
className="list-inline-item badge badge-secondary pointer"
data-tippy-content={`${i18n.t("number_of_users", {
count: counts.users_active_week,
formattedCount: counts.users_active_week,
})} ${i18n.t("active_in_the_last")} ${i18n.t("week")}`}
>
{i18n.t("number_of_users", {
count: counts.users_active_week,
formattedCount: numToSI(counts.users_active_week),
})}{" "}
/ {i18n.t("week")}
</li>
<li
className="list-inline-item badge badge-secondary pointer"
data-tippy-content={`${i18n.t("number_of_users", {
count: counts.users_active_month,
formattedCount: counts.users_active_month,
})} ${i18n.t("active_in_the_last")} ${i18n.t("month")}`}
>
{i18n.t("number_of_users", {
count: counts.users_active_month,
formattedCount: numToSI(counts.users_active_month),
})}{" "}
/ {i18n.t("month")}
</li>
<li
className="list-inline-item badge badge-secondary pointer"
data-tippy-content={`${i18n.t("number_of_users", {
count: counts.users_active_half_year,
formattedCount: counts.users_active_half_year,
})} ${i18n.t("active_in_the_last")} ${i18n.t("number_of_months", {
count: 6,
formattedCount: 6,
})}`}
>
{i18n.t("number_of_users", {
count: counts.users_active_half_year,
formattedCount: numToSI(counts.users_active_half_year),
})}{" "}
/ {i18n.t("number_of_months", { count: 6 })}
/ {i18n.t("number_of_months", { count: 6, formattedCount: 6 })}
</li>
<li className="list-inline-item badge badge-secondary">
{i18n.t("number_of_users", {
count: counts.users,
formattedCount: numToSI(counts.users),
})}
</li>
<li className="list-inline-item badge badge-secondary">
{i18n.t("number_of_communities", {
count: counts.communities,
formattedCount: numToSI(counts.communities),
})}
</li>
<li className="list-inline-item badge badge-secondary">
{i18n.t("number_of_posts", {
count: counts.posts,
formattedCount: numToSI(counts.posts),
})}
</li>
<li className="list-inline-item badge badge-secondary">
{i18n.t("number_of_comments", {
count: counts.comments,
formattedCount: numToSI(counts.comments),
})}
</li>
<li className="list-inline-item">
Expand Down
7 changes: 6 additions & 1 deletion src/shared/components/person/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
fetchLimit,
getUsernameFromProps,
mdToHtml,
numToSI,
previewLines,
restoreScrollPosition,
routeSortTypeToEnum,
Expand Down Expand Up @@ -403,11 +404,15 @@ export class Profile extends Component<any, ProfileState> {
<div>
<ul class="list-inline mb-2">
<li className="list-inline-item badge badge-light">
{i18n.t("number_of_posts", { count: pv.counts.post_count })}
{i18n.t("number_of_posts", {
count: pv.counts.post_count,
formattedCount: numToSI(pv.counts.post_count),
})}
</li>
<li className="list-inline-item badge badge-light">
{i18n.t("number_of_comments", {
count: pv.counts.comment_count,
formattedCount: numToSI(pv.counts.comment_count),
})}
</li>
</ul>
Expand Down
Loading