-import { Component, linkEvent } from 'inferno';
-import { Link } from 'inferno-router';
-import { Subscription } from 'rxjs';
+import { Component, linkEvent } from "inferno";
+import { Link } from "inferno-router";
+import { Subscription } from "rxjs";
import {
UserOperation,
SortType,
CommentResponse,
PostResponse,
BanUserResponse,
-} from 'lemmy-js-client';
-import { InitialFetchRequest, UserDetailsView } from '../interfaces';
-import { WebSocketService, UserService } from '../services';
+} from "lemmy-js-client";
+import { InitialFetchRequest, UserDetailsView } from "../interfaces";
+import { WebSocketService, UserService } from "../services";
import {
wsJsonToRes,
fetchLimit,
setOptionalAuth,
saveScrollPosition,
restoreScrollPosition,
-} from '../utils';
-import { UserListing } from './user-listing';
-import { HtmlTags } from './html-tags';
-import { SortSelect } from './sort-select';
-import { ListingTypeSelect } from './listing-type-select';
-import { MomentTime } from './moment-time';
-import { i18n } from '../i18next';
-import moment from 'moment';
-import { UserDetails } from './user-details';
-import { MarkdownTextArea } from './markdown-textarea';
-import { Icon, Spinner } from './icon';
-import { ImageUploadForm } from './image-upload-form';
-import { BannerIconHeader } from './banner-icon-header';
-import { CommunityLink } from './community-link';
+} from "../utils";
+import { UserListing } from "./user-listing";
+import { HtmlTags } from "./html-tags";
+import { SortSelect } from "./sort-select";
+import { ListingTypeSelect } from "./listing-type-select";
+import { MomentTime } from "./moment-time";
+import { i18n } from "../i18next";
+import moment from "moment";
+import { UserDetails } from "./user-details";
+import { MarkdownTextArea } from "./markdown-textarea";
+import { Icon, Spinner } from "./icon";
+import { ImageUploadForm } from "./image-upload-form";
+import { BannerIconHeader } from "./banner-icon-header";
+import { CommunityLink } from "./community-link";
interface UserState {
userRes: GetUserDetailsResponse;
}
static fetchInitialData(req: InitialFetchRequest): Promise<any>[] {
- let pathSplit = req.path.split('/');
+ let pathSplit = req.path.split("/");
let promises: Promise<any>[] = [];
// It can be /u/me, or /username/1
componentDidUpdate(lastProps: any) {
// Necessary if you are on a post and you click another post (same route)
if (
- lastProps.location.pathname.split('/')[2] !==
- lastProps.history.location.pathname.split('/')[2]
+ lastProps.location.pathname.split("/")[2] !==
+ lastProps.history.location.pathname.split("/")[2]
) {
// Couldnt get a refresh working. This does for now.
location.reload();
<div class="btn-group btn-group-toggle flex-wrap mb-2">
<label
className={`btn btn-outline-secondary pointer
- ${this.state.view == UserDetailsView.Overview && 'active'}
+ ${this.state.view == UserDetailsView.Overview && "active"}
`}
>
<input
checked={this.state.view === UserDetailsView.Overview}
onChange={linkEvent(this, this.handleViewChange)}
/>
- {i18n.t('overview')}
+ {i18n.t("overview")}
</label>
<label
className={`btn btn-outline-secondary pointer
- ${this.state.view == UserDetailsView.Comments && 'active'}
+ ${this.state.view == UserDetailsView.Comments && "active"}
`}
>
<input
checked={this.state.view == UserDetailsView.Comments}
onChange={linkEvent(this, this.handleViewChange)}
/>
- {i18n.t('comments')}
+ {i18n.t("comments")}
</label>
<label
className={`btn btn-outline-secondary pointer
- ${this.state.view == UserDetailsView.Posts && 'active'}
+ ${this.state.view == UserDetailsView.Posts && "active"}
`}
>
<input
checked={this.state.view == UserDetailsView.Posts}
onChange={linkEvent(this, this.handleViewChange)}
/>
- {i18n.t('posts')}
+ {i18n.t("posts")}
</label>
<label
className={`btn btn-outline-secondary pointer
- ${this.state.view == UserDetailsView.Saved && 'active'}
+ ${this.state.view == UserDetailsView.Saved && "active"}
`}
>
<input
checked={this.state.view == UserDetailsView.Saved}
onChange={linkEvent(this, this.handleViewChange)}
/>
- {i18n.t('saved')}
+ {i18n.t("saved")}
</label>
</div>
);
</li>
{uv.user.banned && (
<li className="list-inline-item badge badge-danger">
- {i18n.t('banned')}
+ {i18n.t("banned")}
</li>
)}
</ul>
class="d-flex align-self-start btn btn-secondary mr-2"
onClick={linkEvent(this, this.handleLogoutClick)}
>
- {i18n.t('logout')}
+ {i18n.t("logout")}
</button>
) : (
<>
<a
className={`d-flex align-self-start btn btn-secondary mr-2 ${
- !uv.user.matrix_user_id && 'invisible'
+ !uv.user.matrix_user_id && "invisible"
}`}
rel="noopener"
href={`https://matrix.to/#/${uv.user.matrix_user_id}`}
>
- {i18n.t('send_secure_message')}
+ {i18n.t("send_secure_message")}
</a>
<Link
- className={'d-flex align-self-start btn btn-secondary'}
+ className={"d-flex align-self-start btn btn-secondary"}
to={`/create_private_message/recipient/${uv.user.id}`}
>
- {i18n.t('send_message')}
+ {i18n.t("send_message")}
</Link>
</>
)}
<div>
<ul class="list-inline mb-2">
<li className="list-inline-item badge badge-light">
- {i18n.t('number_of_posts', { count: uv.counts.post_count })}
+ {i18n.t("number_of_posts", { count: uv.counts.post_count })}
</li>
<li className="list-inline-item badge badge-light">
- {i18n.t('number_of_comments', {
+ {i18n.t("number_of_comments", {
count: uv.counts.comment_count,
})}
</li>
</ul>
</div>
<div class="text-muted">
- {i18n.t('joined')}{' '}
+ {i18n.t("joined")}{" "}
<MomentTime data={uv.user} showAgo ignoreUpdated />
</div>
<div className="d-flex align-items-center text-muted mb-2">
<Icon icon="cake" />
<span className="ml-2">
- {i18n.t('cake_day_title')}{' '}
- {moment.utc(uv.user.published).local().format('MMM DD, YYYY')}
+ {i18n.t("cake_day_title")}{" "}
+ {moment.utc(uv.user.published).local().format("MMM DD, YYYY")}
</span>
</div>
</div>
<div>
<div class="card border-secondary mb-3">
<div class="card-body">
- <h5>{i18n.t('settings')}</h5>
+ <h5>{i18n.t("settings")}</h5>
<form onSubmit={linkEvent(this, this.handleUserSettingsSubmit)}>
<div class="form-group">
- <label>{i18n.t('avatar')}</label>
+ <label>{i18n.t("avatar")}</label>
<ImageUploadForm
- uploadTitle={i18n.t('upload_avatar')}
+ uploadTitle={i18n.t("upload_avatar")}
imageSrc={this.state.userSettingsForm.avatar}
onUpload={this.handleAvatarUpload}
onRemove={this.handleAvatarRemove}
/>
</div>
<div class="form-group">
- <label>{i18n.t('banner')}</label>
+ <label>{i18n.t("banner")}</label>
<ImageUploadForm
- uploadTitle={i18n.t('upload_banner')}
+ uploadTitle={i18n.t("upload_banner")}
imageSrc={this.state.userSettingsForm.banner}
onUpload={this.handleBannerUpload}
onRemove={this.handleBannerRemove}
/>
</div>
<div class="form-group">
- <label htmlFor="user-language">{i18n.t('language')}</label>
+ <label htmlFor="user-language">{i18n.t("language")}</label>
<select
id="user-language"
value={this.state.userSettingsForm.lang}
class="ml-2 custom-select w-auto"
>
<option disabled aria-hidden="true">
- {i18n.t('language')}
+ {i18n.t("language")}
</option>
- <option value="browser">{i18n.t('browser_default')}</option>
+ <option value="browser">{i18n.t("browser_default")}</option>
<option disabled aria-hidden="true">
──
</option>
</select>
</div>
<div class="form-group">
- <label htmlFor="user-theme">{i18n.t('theme')}</label>
+ <label htmlFor="user-theme">{i18n.t("theme")}</label>
<select
id="user-theme"
value={this.state.userSettingsForm.theme}
class="ml-2 custom-select w-auto"
>
<option disabled aria-hidden="true">
- {i18n.t('theme')}
+ {i18n.t("theme")}
</option>
- <option value="browser">{i18n.t('browser_default')}</option>
+ <option value="browser">{i18n.t("browser_default")}</option>
{themes.map(theme => (
<option value={theme}>{theme}</option>
))}
</div>
<form className="form-group">
<label>
- <div class="mr-2">{i18n.t('sort_type')}</div>
+ <div class="mr-2">{i18n.t("sort_type")}</div>
</label>
<ListingTypeSelect
type_={
</form>
<form className="form-group">
<label>
- <div class="mr-2">{i18n.t('type')}</div>
+ <div class="mr-2">{i18n.t("type")}</div>
</label>
<SortSelect
sort={
</form>
<div class="form-group row">
<label class="col-lg-5 col-form-label" htmlFor="display-name">
- {i18n.t('display_name')}
+ {i18n.t("display_name")}
</label>
<div class="col-lg-7">
<input
id="display-name"
type="text"
class="form-control"
- placeholder={i18n.t('optional')}
+ placeholder={i18n.t("optional")}
value={this.state.userSettingsForm.preferred_username}
onInput={linkEvent(
this,
</div>
<div class="form-group row">
<label class="col-lg-3 col-form-label" htmlFor="user-bio">
- {i18n.t('bio')}
+ {i18n.t("bio")}
</label>
<div class="col-lg-9">
<MarkdownTextArea
</div>
<div class="form-group row">
<label class="col-lg-3 col-form-label" htmlFor="user-email">
- {i18n.t('email')}
+ {i18n.t("email")}
</label>
<div class="col-lg-9">
<input
type="email"
id="user-email"
class="form-control"
- placeholder={i18n.t('optional')}
+ placeholder={i18n.t("optional")}
value={this.state.userSettingsForm.email}
onInput={linkEvent(
this,
<div class="form-group row">
<label class="col-lg-5 col-form-label" htmlFor="matrix-user-id">
<a href={elementUrl} rel="noopener">
- {i18n.t('matrix_user_id')}
+ {i18n.t("matrix_user_id")}
</a>
</label>
<div class="col-lg-7">
</div>
<div class="form-group row">
<label class="col-lg-5 col-form-label" htmlFor="user-password">
- {i18n.t('new_password')}
+ {i18n.t("new_password")}
</label>
<div class="col-lg-7">
<input
class="col-lg-5 col-form-label"
htmlFor="user-verify-password"
>
- {i18n.t('verify_password')}
+ {i18n.t("verify_password")}
</label>
<div class="col-lg-7">
<input
class="col-lg-5 col-form-label"
htmlFor="user-old-password"
>
- {i18n.t('old_password')}
+ {i18n.t("old_password")}
</label>
<div class="col-lg-7">
<input
)}
/>
<label class="form-check-label" htmlFor="user-show-nsfw">
- {i18n.t('show_nsfw')}
+ {i18n.t("show_nsfw")}
</label>
</div>
</div>
)}
/>
<label class="form-check-label" htmlFor="user-show-avatars">
- {i18n.t('show_avatars')}
+ {i18n.t("show_avatars")}
</label>
</div>
</div>
class="form-check-label"
htmlFor="user-send-notifications-to-email"
>
- {i18n.t('send_notifications_to_email')}
+ {i18n.t("send_notifications_to_email")}
</label>
</div>
</div>
{this.state.userSettingsLoading ? (
<Spinner />
) : (
- capitalizeFirstLetter(i18n.t('save'))
+ capitalizeFirstLetter(i18n.t("save"))
)}
</button>
</div>
this.handleDeleteAccountShowConfirmToggle
)}
>
- {i18n.t('delete_account')}
+ {i18n.t("delete_account")}
</button>
{this.state.deleteAccountShowConfirm && (
<>
<div class="my-2 alert alert-danger" role="alert">
- {i18n.t('delete_account_confirm')}
+ {i18n.t("delete_account_confirm")}
</div>
<input
type="password"
{this.state.deleteAccountLoading ? (
<Spinner />
) : (
- capitalizeFirstLetter(i18n.t('delete'))
+ capitalizeFirstLetter(i18n.t("delete"))
)}
</button>
<button
this.handleDeleteAccountShowConfirmToggle
)}
>
- {i18n.t('cancel')}
+ {i18n.t("cancel")}
</button>
</>
)}
{this.state.userRes.moderates.length > 0 && (
<div class="card border-secondary mb-3">
<div class="card-body">
- <h5>{i18n.t('moderates')}</h5>
+ <h5>{i18n.t("moderates")}</h5>
<ul class="list-unstyled mb-0">
{this.state.userRes.moderates.map(cmv => (
<li>
{this.state.userRes.follows.length > 0 && (
<div class="card border-secondary mb-3">
<div class="card-body">
- <h5>{i18n.t('subscribed')}</h5>
+ <h5>{i18n.t("subscribed")}</h5>
<ul class="list-unstyled mb-0">
{this.state.userRes.follows.map(cfv => (
<li>
}
handleAvatarRemove() {
- this.state.userSettingsForm.avatar = '';
+ this.state.userSettingsForm.avatar = "";
this.setState(this.state);
}
}
handleBannerRemove() {
- this.state.userSettingsForm.banner = '';
+ this.state.userSettingsForm.banner = "";
this.setState(this.state);
}
handleUserSettingsMatrixUserIdChange(i: User, event: any) {
i.state.userSettingsForm.matrix_user_id = event.target.value;
if (
- i.state.userSettingsForm.matrix_user_id == '' &&
+ i.state.userSettingsForm.matrix_user_id == "" &&
!i.state.userRes.user_view.user.matrix_user_id
) {
i.state.userSettingsForm.matrix_user_id = undefined;
handleUserSettingsNewPasswordChange(i: User, event: any) {
i.state.userSettingsForm.new_password = event.target.value;
- if (i.state.userSettingsForm.new_password == '') {
+ if (i.state.userSettingsForm.new_password == "") {
i.state.userSettingsForm.new_password = undefined;
}
i.setState(i.state);
handleUserSettingsNewPasswordVerifyChange(i: User, event: any) {
i.state.userSettingsForm.new_password_verify = event.target.value;
- if (i.state.userSettingsForm.new_password_verify == '') {
+ if (i.state.userSettingsForm.new_password_verify == "") {
i.state.userSettingsForm.new_password_verify = undefined;
}
i.setState(i.state);
handleUserSettingsOldPasswordChange(i: User, event: any) {
i.state.userSettingsForm.old_password = event.target.value;
- if (i.state.userSettingsForm.old_password == '') {
+ if (i.state.userSettingsForm.old_password == "") {
i.state.userSettingsForm.old_password = undefined;
}
i.setState(i.state);
handleLogoutClick(i: User) {
UserService.Instance.logout();
- i.context.router.history.push('/');
+ i.context.router.history.push("/");
}
handleDeleteAccount(i: User, event: any) {
UserService.Instance.user.show_nsfw;
this.state.userSettingsForm.theme = UserService.Instance.user.theme
? UserService.Instance.user.theme
- : 'browser';
+ : "browser";
this.state.userSettingsForm.default_sort_type =
UserService.Instance.user.default_sort_type;
this.state.userSettingsForm.default_listing_type =
parseMessage(msg: any) {
let op = wsUserOp(msg);
if (msg.error) {
- toast(i18n.t(msg.error), 'danger');
- if (msg.error == 'couldnt_find_that_username_or_email') {
- this.context.router.history.push('/');
+ toast(i18n.t(msg.error), "danger");
+ if (msg.error == "couldnt_find_that_username_or_email") {
+ this.context.router.history.push("/");
}
this.setState({
deleteAccountLoading: false,
deleteAccountLoading: false,
deleteAccountShowConfirm: false,
});
- this.context.router.history.push('/');
+ this.context.router.history.push("/");
} else if (op == UserOperation.AddAdmin) {
let data = wsJsonToRes<AddAdminResponse>(msg).data;
this.state.siteRes.admins = data.admins;
UserService.Instance.user &&
data.comment_view.creator.id == UserService.Instance.user.id
) {
- toast(i18n.t('reply_sent'));
+ toast(i18n.t("reply_sent"));
}
} else if (op == UserOperation.SaveComment) {
let data = wsJsonToRes<CommentResponse>(msg).data;