X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fshared%2Fcomponents%2Fperson%2Fprofile.tsx;h=d493f787d5602240ef2b0bfc339315da72863a10;hb=53c3cfeade90150b07431386745a24aa699a25ec;hp=6f6ede3e7370970fcdef760fd9b4d4a807720a74;hpb=4da34c13706f92069c3333afc3b1481a3f040edd;p=lemmy-ui.git
diff --git a/src/shared/components/person/profile.tsx b/src/shared/components/person/profile.tsx
index 6f6ede3..d493f78 100644
--- a/src/shared/components/person/profile.tsx
+++ b/src/shared/components/person/profile.tsx
@@ -1,7 +1,31 @@
-import { getQueryParams, getQueryString } from "@utils/helpers";
+import {
+ editComment,
+ editPost,
+ editWith,
+ enableDownvotes,
+ enableNsfw,
+ getCommentParentId,
+ myAuth,
+ myAuthRequired,
+ setIsoData,
+ updatePersonBlock,
+} from "@utils/app";
+import { restoreScrollPosition, saveScrollPosition } from "@utils/browser";
+import {
+ capitalizeFirstLetter,
+ futureDaysToUnixTime,
+ getPageFromString,
+ getQueryParams,
+ getQueryString,
+ numToSI,
+ randomStr,
+} from "@utils/helpers";
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";
@@ -49,41 +73,19 @@ import {
SortType,
TransferCommunity,
} from "lemmy-js-client";
-import moment from "moment";
-import { i18n } from "../../i18next";
+import { fetchLimit, relTags } from "../../config";
import { InitialFetchRequest, PersonDetailsView } from "../../interfaces";
-import { UserService } from "../../services";
-import { FirstLoadService } from "../../services/FirstLoadService";
+import { mdToHtml } from "../../markdown";
+import { FirstLoadService, I18NextService, UserService } from "../../services";
import { HttpService, RequestState } from "../../services/HttpService";
-import {
- RouteDataResponse,
- capitalizeFirstLetter,
- editComment,
- editPost,
- editWith,
- enableDownvotes,
- enableNsfw,
- fetchLimit,
- futureDaysToUnixTime,
- getCommentParentId,
- getPageFromString,
- mdToHtml,
- myAuth,
- myAuthRequired,
- numToSI,
- relTags,
- restoreScrollPosition,
- saveScrollPosition,
- setIsoData,
- setupTippy,
- toast,
- updatePersonBlock,
-} from "../../utils";
+import { setupTippy } from "../../tippy";
+import { toast } from "../../toast";
import { BannerIconHeader } from "../common/banner-icon-header";
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";
@@ -136,7 +138,7 @@ const getCommunitiesListing = (
communityViews.length > 0 && (
-
{i18n.t(translationKey)}
+
{I18NextService.i18n.t(translationKey)}
{communityViews.map(({ community }) => (
-
@@ -205,6 +207,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) {
@@ -230,7 +233,7 @@ export class Profile extends Component<
async fetchUserData() {
const { page, sort, view } = getProfileQueryParams();
- this.setState({ personRes: { state: "empty" } });
+ this.setState({ personRes: { state: "loading" } });
this.setState({
personRes: await HttpService.client.getPersonDetails({
username: this.props.match.params.username,
@@ -321,6 +324,7 @@ export class Profile extends Component<
@@ -395,7 +399,7 @@ export class Profile extends Component<
get viewRadios() {
return (
-
+
{this.getRadio(PersonDetailsView.Overview)}
{this.getRadio(PersonDetailsView.Comments)}
{this.getRadio(PersonDetailsView.Posts)}
@@ -407,22 +411,27 @@ export class Profile extends Component<
getRadio(view: PersonDetailsView) {
const { view: urlView } = getProfileQueryParams();
const active = view === urlView;
+ const radioId = randomStr();
return (
-
+
+ >
);
}
@@ -470,7 +479,7 @@ export class Profile extends Component<
{pv.person.display_name && (
-
{pv.person.display_name}
+
{pv.person.display_name}
)}
-
@@ -482,26 +491,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)}
@@ -515,7 +513,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 ? (
) : (
)}
>
@@ -562,9 +560,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"))}
) : (
))}
@@ -589,13 +587,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),
})}
@@ -603,7 +601,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")}
)}
@@ -640,24 +635,24 @@ export class Profile extends Component<
@@ -683,23 +678,25 @@ export class Profile extends Component<
{/* TODO hold off on expires until later */}
{/* */}
{/* */}
- {/* */}
+ {/* */}
{/*
*/}
+
+
@@ -903,14 +900,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"));
}
}
@@ -934,7 +931,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) {
@@ -990,6 +987,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;
});
@@ -998,7 +996,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(`/`);
}
}