X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fshared%2Fcomponents%2Fperson%2Fprofile.tsx;h=ec7538ba8a2cc2e6da05d7aff7a189b266e59dbf;hb=34f04e6758d53bfccbdda2cbb0adde21e9a0cffa;hp=763947e8e1b07f50e1fe78d158c34876588fe9b1;hpb=043b522ff1b0a395eda7d5e2b01fd035c5ec6b6e;p=lemmy-ui.git
diff --git a/src/shared/components/person/profile.tsx b/src/shared/components/person/profile.tsx
index 763947e..ec7538b 100644
--- a/src/shared/components/person/profile.tsx
+++ b/src/shared/components/person/profile.tsx
@@ -23,6 +23,8 @@ import { canMod, isAdmin, isBanned } from "@utils/roles";
import type { QueryParams } from "@utils/types";
import { RouteDataResponse } from "@utils/types";
import classNames from "classnames";
+import format from "date-fns/format";
+import parseISO from "date-fns/parseISO";
import { NoOptionI18nKeys } from "i18next";
import { Component, linkEvent } from "inferno";
import { Link } from "inferno-router";
@@ -70,13 +72,10 @@ import {
SortType,
TransferCommunity,
} from "lemmy-js-client";
-import moment from "moment";
import { fetchLimit, relTags } from "../../config";
-import { i18n } from "../../i18next";
import { InitialFetchRequest, PersonDetailsView } from "../../interfaces";
import { mdToHtml } from "../../markdown";
-import { UserService } from "../../services";
-import { FirstLoadService } from "../../services/FirstLoadService";
+import { FirstLoadService, I18NextService, UserService } from "../../services";
import { HttpService, RequestState } from "../../services/HttpService";
import { setupTippy } from "../../tippy";
import { toast } from "../../toast";
@@ -85,6 +84,7 @@ import { HtmlTags } from "../common/html-tags";
import { Icon, Spinner } from "../common/icon";
import { MomentTime } from "../common/moment-time";
import { SortSelect } from "../common/sort-select";
+import { UserBadges } from "../common/user-badges";
import { CommunityLink } from "../community/community-link";
import { PersonDetails } from "./person-details";
import { PersonListing } from "./person-listing";
@@ -137,7 +137,7 @@ const getCommunitiesListing = (
communityViews.length > 0 && (
-
{i18n.t(translationKey)}
+
{I18NextService.i18n.t(translationKey)}
{communityViews.map(({ community }) => (
-
@@ -206,6 +206,7 @@ export class Profile extends Component<
this.handleSavePost = this.handleSavePost.bind(this);
this.handlePurgePost = this.handlePurgePost.bind(this);
this.handleFeaturePost = this.handleFeaturePost.bind(this);
+ this.handleModBanSubmit = this.handleModBanSubmit.bind(this);
// Only fetch the data if coming from another route
if (FirstLoadService.isFirstLoad) {
@@ -422,7 +423,7 @@ export class Profile extends Component<
checked={active}
onChange={linkEvent(this, this.handleViewChange)}
/>
- {i18n.t(view.toLowerCase() as NoOptionI18nKeys)}
+ {I18NextService.i18n.t(view.toLowerCase() as NoOptionI18nKeys)}
);
}
@@ -471,7 +472,7 @@ export class Profile extends Component<
{pv.person.display_name && (
-
{pv.person.display_name}
+
{pv.person.display_name}
)}
-
@@ -483,26 +484,15 @@ export class Profile extends Component<
hideAvatar
/>
- {isBanned(pv.person) && (
- -
- {i18n.t("banned")}
-
- )}
- {pv.person.deleted && (
- -
- {i18n.t("deleted")}
-
- )}
- {pv.person.admin && (
- -
- {i18n.t("admin")}
-
- )}
- {pv.person.bot_account && (
- -
- {i18n.t("bot_account").toLowerCase()}
-
- )}
+ -
+
+
{this.banDialog(pv)}
@@ -516,7 +506,7 @@ export class Profile extends Component<
rel={relTags}
href={`https://matrix.to/#/${pv.person.matrix_user_id}`}
>
- {i18n.t("send_secure_message")}
+ {I18NextService.i18n.t("send_secure_message")}
- {i18n.t("send_message")}
+ {I18NextService.i18n.t("send_message")}
{personBlocked ? (
) : (
)}
>
@@ -563,9 +553,9 @@ export class Profile extends Component<
"d-flex align-self-start btn btn-secondary me-2"
}
onClick={linkEvent(this, this.handleModBanShow)}
- aria-label={i18n.t("ban")}
+ aria-label={I18NextService.i18n.t("ban")}
>
- {capitalizeFirstLetter(i18n.t("ban"))}
+ {capitalizeFirstLetter(I18NextService.i18n.t("ban"))}
) : (
))}
@@ -590,13 +580,13 @@ export class Profile extends Component<
-
- {i18n.t("number_of_posts", {
+ {I18NextService.i18n.t("number_of_posts", {
count: Number(pv.counts.post_count),
formattedCount: numToSI(pv.counts.post_count),
})}
-
- {i18n.t("number_of_comments", {
+ {I18NextService.i18n.t("number_of_comments", {
count: Number(pv.counts.comment_count),
formattedCount: numToSI(pv.counts.comment_count),
})}
@@ -604,7 +594,7 @@ export class Profile extends Component<
- {i18n.t("joined")}{" "}
+ {I18NextService.i18n.t("joined")}{" "}
- {i18n.t("cake_day_title")}{" "}
- {moment
- .utc(pv.person.published)
- .local()
- .format("MMM DD, YYYY")}
+ {I18NextService.i18n.t("cake_day_title")}{" "}
+ {format(parseISO(pv.person.published), "PPP")}
{!UserService.Instance.myUserInfo && (
- {i18n.t("profile_not_logged_in_alert")}
+ {I18NextService.i18n.t("profile_not_logged_in_alert")}
)}
@@ -641,24 +628,24 @@ export class Profile extends Component<
@@ -684,23 +671,25 @@ export class Profile extends Component<
{/* TODO hold off on expires until later */}
{/* */}
{/* */}
- {/* */}
+ {/* */}
{/*
*/}
+
+
@@ -904,14 +893,14 @@ export class Profile extends Component<
async handleCommentReport(form: CreateCommentReport) {
const reportRes = await HttpService.client.createCommentReport(form);
if (reportRes.state === "success") {
- toast(i18n.t("report_created"));
+ toast(I18NextService.i18n.t("report_created"));
}
}
async handlePostReport(form: CreatePostReport) {
const reportRes = await HttpService.client.createPostReport(form);
if (reportRes.state === "success") {
- toast(i18n.t("report_created"));
+ toast(I18NextService.i18n.t("report_created"));
}
}
@@ -935,7 +924,7 @@ export class Profile extends Component<
async handleTransferCommunity(form: TransferCommunity) {
await HttpService.client.transferCommunity(form);
- toast(i18n.t("transfer_community"));
+ toast(I18NextService.i18n.t("transfer_community"));
}
async handleCommentReplyRead(form: MarkCommentReplyAsRead) {
@@ -991,6 +980,7 @@ export class Profile extends Component<
s.personRes.data.comments
.filter(c => c.creator.id == banRes.data.person_view.person.id)
.forEach(c => (c.creator.banned = banRes.data.banned));
+ s.personRes.data.person_view.person.banned = banRes.data.banned;
}
return s;
});
@@ -999,7 +989,7 @@ export class Profile extends Component<
purgeItem(purgeRes: RequestState) {
if (purgeRes.state == "success") {
- toast(i18n.t("purge_success"));
+ toast(I18NextService.i18n.t("purge_success"));
this.context.router.history.push(`/`);
}
}