"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/no-empty-function": 0,
+ "@typescript-eslint/no-non-null-assertion": 0,
"arrow-body-style": 0,
"curly": 0,
"eol-last": 0,
- "eqeqeq": 0,
+ "eqeqeq": "error",
"func-style": 0,
"import/no-duplicates": 0,
"max-statements": 0,
"no-useless-constructor": 0,
"no-useless-escape": 0,
"no-var": 0,
- "prefer-const": 1,
+ "prefer-const": "error",
"prefer-rest-params": 0,
"prettier/prettier": "error",
"quote-props": 0,
let errorPageData: ErrorPageData | undefined = undefined;
let try_site = await client.getSite(getSiteForm);
- if (try_site.state === "failed" && try_site.msg == "not_logged_in") {
+ if (try_site.state === "failed" && try_site.msg === "not_logged_in") {
console.error(
"Incorrect JWT token, skipping auth so frontend can remove jwt cookie"
);
}
get unreadInboxCount(): number {
- if (this.state.unreadInboxCountRes.state == "success") {
+ if (this.state.unreadInboxCountRes.state === "success") {
const data = this.state.unreadInboxCountRes.data;
return data.replies + data.mentions + data.private_messages;
} else {
}
get unreadReportCount(): number {
- if (this.state.unreadReportCountRes.state == "success") {
+ if (this.state.unreadReportCountRes.state === "success") {
const data = this.state.unreadReportCountRes.data;
return (
data.post_reports +
}
get unreadApplicationCount(): number {
- if (this.state.unreadApplicationCountRes.state == "success") {
+ if (this.state.unreadApplicationCountRes.state === "success") {
const data = this.state.unreadApplicationCountRes.data;
return data.registration_applications;
} else {
</Helmet>
);
} else if (
- this.props.defaultTheme != "browser" &&
- this.props.defaultTheme != "browser-compact"
+ this.props.defaultTheme !== "browser" &&
+ this.props.defaultTheme !== "browser-compact"
) {
return (
<Helmet>
/>
</Helmet>
);
- } else if (this.props.defaultTheme == "browser-compact") {
+ } else if (this.props.defaultTheme === "browser-compact") {
return (
<Helmet>
<link
const cv = this.commentView;
const purgeTypeText =
- this.state.purgeType == PurgeType.Comment
+ this.state.purgeType === PurgeType.Comment
? I18NextService.i18n.t("purge_comment")
: `${I18NextService.i18n.t("purge")} ${cv.creator.name}`;
: colorList[0];
const showMoreChildren =
- this.props.viewType == CommentViewType.Tree &&
+ this.props.viewType === CommentViewType.Tree &&
!this.state.collapsed &&
- node.children.length == 0 &&
+ node.children.length === 0 &&
node.comment_view.counts.child_count > 0;
return (
get myComment(): boolean {
return (
- UserService.Instance.myUserInfo?.local_user_view.person.id ==
+ UserService.Instance.myUserInfo?.local_user_view.person.id ===
this.commentView.creator.id
);
}
get isPostCreator(): boolean {
- return this.commentView.creator.id == this.commentView.post.creator_id;
+ return this.commentView.creator.id === this.commentView.post.creator_id;
}
get scoreColor() {
- if (this.commentView.my_vote == 1) {
+ if (this.commentView.my_vote === 1) {
return "text-info";
- } else if (this.commentView.my_vote == -1) {
+ } else if (this.commentView.my_vote === -1) {
return "text-danger";
} else {
return "text-muted";
handleModBanBothSubmit(i: CommentNode, event: any) {
event.preventDefault();
- if (i.state.banType == BanType.Community) {
+ if (i.state.banType === BanType.Community) {
i.handleBanPersonFromCommunity(i);
} else {
i.handleBanPerson(i);
event.preventDefault();
i.setState({ purgeLoading: true });
- if (i.state.purgeType == PurgeType.Person) {
+ if (i.state.purgeType === PurgeType.Person) {
i.props.onPurgePerson({
person_id: i.commentView.creator.id,
reason: i.state.purgeReason,
componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & CommentReportProps>
): void {
- if (this.props != nextProps) {
+ if (this.props !== nextProps) {
this.setState({ loading: false });
}
}
handleEmoji(i: MarkdownTextArea, e: any) {
let value = e.native;
- if (value == null) {
+ if (value === null) {
const emoji = customEmojisLookup.get(e.id)?.custom_emoji;
if (emoji) {
value = `![${emoji.alt_text}](${emoji.image_url} "${emoji.shortcode}")`;
<div className="paginator my-2">
<button
className="btn btn-secondary me-2"
- disabled={this.props.page == 1}
+ disabled={this.props.page === 1}
onClick={linkEvent(this, this.handlePrev)}
>
{I18NextService.i18n.t("prev")}
if (strength && ["weak", "medium"].includes(strength)) {
return "text-warning";
- } else if (strength == "strong") {
+ } else if (strength === "strong") {
return "text-success";
} else {
return "text-danger";
const split = this.props.src.split("/pictrs/image/");
// If theres not multiple, then its not a pictrs image
- if (split.length == 1) {
+ if (split.length === 1) {
return this.props.src;
}
{ children?: InfernoNode } & RegistrationApplicationProps
>
): void {
- if (this.props != nextProps) {
+ if (this.props !== nextProps) {
this.setState({
denyExpanded: false,
approveLoading: false,
<button
type="button"
className={`btn-animate btn btn-link p-0 ${
- this.props.my_vote == 1 ? "text-info" : "text-muted"
+ this.props.my_vote === 1 ? "text-info" : "text-muted"
}`}
onClick={linkEvent(this, handleUpvote)}
data-tippy-content={I18NextService.i18n.t("upvote")}
<button
type="button"
className={`btn-animate btn btn-link p-0 ${
- this.props.my_vote == -1 ? "text-danger" : "text-muted"
+ this.props.my_vote === -1 ? "text-danger" : "text-muted"
}`}
onClick={linkEvent(this, handleDownvote)}
data-tippy-content={I18NextService.i18n.t("downvote")}
{numToSI(cv.counts.comments)}
</td>
<td className="text-right">
- {cv.subscribed == "Subscribed" && (
+ {cv.subscribed === "Subscribed" && (
<button
className="btn btn-link d-inline-block"
onClick={linkEvent(
findAndUpdateCommunity(res: RequestState<CommunityResponse>) {
this.setState(s => {
if (
- s.listCommunitiesResponse.state == "success" &&
- res.state == "success"
+ s.listCommunitiesResponse.state === "success" &&
+ res.state === "success"
) {
s.listCommunitiesResponse.data.communities = editCommunity(
res.data.community_view,
render() {
const community = this.props.community;
let name_: string, title: string, link: string;
- const local = community.local == null ? true : community.local;
+ const local = community.local === null ? true : community.local;
if (local) {
name_ = community.name;
title = community.title;
get documentTitle(): string {
const cRes = this.state.communityRes;
- return cRes.state == "success"
+ return cRes.state === "success"
? `${cRes.data.community_view.community.title} - ${this.isoData.site_res.site_view.site.name}`
: "";
}
this.updateCommunity(followCommunityRes);
// Update myUserInfo
- if (followCommunityRes.state == "success") {
+ if (followCommunityRes.state === "success") {
const communityId = followCommunityRes.data.community_view.community.id;
const mui = UserService.Instance.myUserInfo;
if (mui) {
- mui.follows = mui.follows.filter(i => i.community.id != communityId);
+ mui.follows = mui.follows.filter(i => i.community.id !== communityId);
}
}
}
async handleBlockCommunity(form: BlockCommunity) {
const blockCommunityRes = await HttpService.client.blockCommunity(form);
- if (blockCommunityRes.state == "success") {
+ if (blockCommunityRes.state === "success") {
updateCommunityBlock(blockCommunityRes.data);
this.setState(s => {
- if (s.communityRes.state == "success") {
+ if (s.communityRes.state === "success") {
s.communityRes.data.community_view.blocked =
blockCommunityRes.data.blocked;
}
async handleBlockPerson(form: BlockPerson) {
const blockPersonRes = await HttpService.client.blockPerson(form);
- if (blockPersonRes.state == "success") {
+ if (blockPersonRes.state === "success") {
updatePersonBlock(blockPersonRes.data);
}
}
async handleCommentReport(form: CreateCommentReport) {
const reportRes = await HttpService.client.createCommentReport(form);
- if (reportRes.state == "success") {
+ if (reportRes.state === "success") {
toast(I18NextService.i18n.t("report_created"));
}
}
async handlePostReport(form: CreatePostReport) {
const reportRes = await HttpService.client.createPostReport(form);
- if (reportRes.state == "success") {
+ if (reportRes.state === "success") {
toast(I18NextService.i18n.t("report_created"));
}
}
async handleAddAdmin(form: AddAdmin) {
const addAdminRes = await HttpService.client.addAdmin(form);
- if (addAdminRes.state == "success") {
+ if (addAdminRes.state === "success") {
this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s));
}
}
updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
// Maybe not necessary
- if (banRes.state == "success") {
+ if (banRes.state === "success") {
this.setState(s => {
- if (s.postsRes.state == "success") {
+ if (s.postsRes.state === "success") {
s.postsRes.data.posts
- .filter(c => c.creator.id == banRes.data.person_view.person.id)
+ .filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(
c => (c.creator_banned_from_community = banRes.data.banned)
);
}
- if (s.commentsRes.state == "success") {
+ if (s.commentsRes.state === "success") {
s.commentsRes.data.comments
- .filter(c => c.creator.id == banRes.data.person_view.person.id)
+ .filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(
c => (c.creator_banned_from_community = banRes.data.banned)
);
updateBan(banRes: RequestState<BanPersonResponse>) {
// Maybe not necessary
- if (banRes.state == "success") {
+ if (banRes.state === "success") {
this.setState(s => {
- if (s.postsRes.state == "success") {
+ if (s.postsRes.state === "success") {
s.postsRes.data.posts
- .filter(c => c.creator.id == banRes.data.person_view.person.id)
+ .filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(c => (c.creator.banned = banRes.data.banned));
}
- if (s.commentsRes.state == "success") {
+ if (s.commentsRes.state === "success") {
s.commentsRes.data.comments
- .filter(c => c.creator.id == banRes.data.person_view.person.id)
+ .filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(c => (c.creator.banned = banRes.data.banned));
}
return s;
updateCommunity(res: RequestState<CommunityResponse>) {
this.setState(s => {
- if (s.communityRes.state == "success" && res.state == "success") {
+ if (s.communityRes.state === "success" && res.state === "success") {
s.communityRes.data.community_view = res.data.community_view;
s.communityRes.data.discussion_languages =
res.data.discussion_languages;
updateCommunityFull(res: RequestState<GetCommunityResponse>) {
this.setState(s => {
- if (s.communityRes.state == "success" && res.state == "success") {
+ if (s.communityRes.state === "success" && res.state === "success") {
s.communityRes.data.community_view = res.data.community_view;
s.communityRes.data.moderators = res.data.moderators;
}
}
purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
- if (purgeRes.state == "success") {
+ if (purgeRes.state === "success") {
toast(I18NextService.i18n.t("purge_success"));
this.context.router.history.push(`/`);
}
findAndUpdateComment(res: RequestState<CommentResponse>) {
this.setState(s => {
- if (s.commentsRes.state == "success" && res.state == "success") {
+ if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editComment(
res.data.comment_view,
s.commentsRes.data.comments
createAndUpdateComments(res: RequestState<CommentResponse>) {
this.setState(s => {
- if (s.commentsRes.state == "success" && res.state == "success") {
+ if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments.unshift(res.data.comment_view);
// Set finished for the parent
findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
this.setState(s => {
- if (s.commentsRes.state == "success" && res.state == "success") {
+ if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editWith(
res.data.comment_reply_view,
s.commentsRes.data.comments
findAndUpdatePost(res: RequestState<PostResponse>) {
this.setState(s => {
- if (s.postsRes.state == "success" && res.state == "success") {
+ if (s.postsRes.state === "success" && res.state === "success") {
s.postsRes.data.posts = editPost(
res.data.post_view,
s.postsRes.data.posts
updateModerators(res: RequestState<AddModToCommunityResponse>) {
// Update the moderators
this.setState(s => {
- if (s.communityRes.state == "success" && res.state == "success") {
+ if (s.communityRes.state === "success" && res.state === "success") {
s.communityRes.data.moderators = res.data.moderators;
}
return s;
componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & SidebarProps>
): void {
- if (this.props.moderators != nextProps.moderators) {
+ if (this.props.moderators !== nextProps.moderators) {
this.setState({
showConfirmLeaveModTeam: false,
});
}
- if (this.props.community_view != nextProps.community_view) {
+ if (this.props.community_view !== nextProps.community_view) {
this.setState({
showEdit: false,
showPurgeDialog: false,
onClick={linkEvent(this, this.handleLeaveAdminTeam)}
className="btn btn-danger mb-2"
>
- {this.state.leaveAdminTeamRes.state == "loading" ? (
+ {this.state.leaveAdminTeamRes.state === "loading" ? (
<Spinner />
) : (
I18NextService.i18n.t("leave_admin_team")
cv.shortcode.length > 0;
const noDuplicateShortCodes =
this.state.customEmojis.filter(
- x => x.shortcode == cv.shortcode && x.id != cv.id
- ).length == 0;
+ x => x.shortcode === cv.shortcode && x.id !== cv.id
+ ).length === 0;
return noEmptyFields && noDuplicateShortCodes && !cv.loading && cv.changed;
}
const view = customEmojisLookup.get(e.id);
if (view) {
const page = this.state.customEmojis.find(
- x => x.id == view.custom_emoji.id
+ x => x.id === view.custom_emoji.id
)?.page;
if (page) {
this.setState({ page: page });
cv: CustomEmojiViewForm;
}) {
const pagedIndex = (d.i.state.page - 1) * d.i.itemsPerPage + d.index;
- if (d.cv.id != 0) {
+ if (d.cv.id !== 0) {
d.i.props.onDelete({
id: d.cv.id,
auth: myAuthRequired(),
async handleBlockPerson(form: BlockPerson) {
const blockPersonRes = await HttpService.client.blockPerson(form);
- if (blockPersonRes.state == "success") {
+ if (blockPersonRes.state === "success") {
updatePersonBlock(blockPersonRes.data);
}
}
async handleCommentReport(form: CreateCommentReport) {
const reportRes = await HttpService.client.createCommentReport(form);
- if (reportRes.state == "success") {
+ if (reportRes.state === "success") {
toast(I18NextService.i18n.t("report_created"));
}
}
async handlePostReport(form: CreatePostReport) {
const reportRes = await HttpService.client.createPostReport(form);
- if (reportRes.state == "success") {
+ if (reportRes.state === "success") {
toast(I18NextService.i18n.t("report_created"));
}
}
async handleAddAdmin(form: AddAdmin) {
const addAdminRes = await HttpService.client.addAdmin(form);
- if (addAdminRes.state == "success") {
+ if (addAdminRes.state === "success") {
this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s));
}
}
updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
// Maybe not necessary
- if (banRes.state == "success") {
+ if (banRes.state === "success") {
this.setState(s => {
- if (s.postsRes.state == "success") {
+ if (s.postsRes.state === "success") {
s.postsRes.data.posts
- .filter(c => c.creator.id == banRes.data.person_view.person.id)
+ .filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(
c => (c.creator_banned_from_community = banRes.data.banned)
);
}
- if (s.commentsRes.state == "success") {
+ if (s.commentsRes.state === "success") {
s.commentsRes.data.comments
- .filter(c => c.creator.id == banRes.data.person_view.person.id)
+ .filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(
c => (c.creator_banned_from_community = banRes.data.banned)
);
updateBan(banRes: RequestState<BanPersonResponse>) {
// Maybe not necessary
- if (banRes.state == "success") {
+ if (banRes.state === "success") {
this.setState(s => {
- if (s.postsRes.state == "success") {
+ if (s.postsRes.state === "success") {
s.postsRes.data.posts
- .filter(c => c.creator.id == banRes.data.person_view.person.id)
+ .filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(c => (c.creator.banned = banRes.data.banned));
}
- if (s.commentsRes.state == "success") {
+ if (s.commentsRes.state === "success") {
s.commentsRes.data.comments
- .filter(c => c.creator.id == banRes.data.person_view.person.id)
+ .filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(c => (c.creator.banned = banRes.data.banned));
}
return s;
}
purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
- if (purgeRes.state == "success") {
+ if (purgeRes.state === "success") {
toast(I18NextService.i18n.t("purge_success"));
this.context.router.history.push(`/`);
}
findAndUpdateComment(res: RequestState<CommentResponse>) {
this.setState(s => {
- if (s.commentsRes.state == "success" && res.state == "success") {
+ if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editComment(
res.data.comment_view,
s.commentsRes.data.comments
createAndUpdateComments(res: RequestState<CommentResponse>) {
this.setState(s => {
- if (s.commentsRes.state == "success" && res.state == "success") {
+ if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments.unshift(res.data.comment_view);
// Set finished for the parent
findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
this.setState(s => {
- if (s.commentsRes.state == "success" && res.state == "success") {
+ if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editWith(
res.data.comment_reply_view,
s.commentsRes.data.comments
findAndUpdatePost(res: RequestState<PostResponse>) {
this.setState(s => {
- if (s.postsRes.state == "success" && res.state == "success") {
+ if (s.postsRes.state === "success" && res.state === "success") {
s.postsRes.data.posts = editPost(
res.data.post_view,
s.postsRes.data.posts
const res = await HttpService.client.passwordReset({ email });
- if (res.state == "success") {
+ if (res.state === "success") {
toast(I18NextService.i18n.t("reset_password_mail_sent"));
i.context.router.history.push("/login");
}
}
get isLemmyMl(): boolean {
- return isBrowser() && window.location.hostname == "lemmy.ml";
+ return isBrowser() && window.location.hostname === "lemmy.ml";
}
render() {
<div className="mb-3 row">
<div className="col-sm-10">
<button type="submit" className="btn btn-secondary">
- {this.state.loginRes.state == "loading" ? (
+ {this.state.loginRes.state === "loading" ? (
<Spinner />
) : (
I18NextService.i18n.t("login")
<div className="mb-3 row">
<div className="col-sm-10">
<button type="submit" className="btn btn-secondary">
- {this.state.registerRes.state == "loading" ? (
+ {this.state.registerRes.state === "loading" ? (
<Spinner />
) : (
I18NextService.i18n.t("sign_up")
registerRes: await HttpService.client.register(form),
});
- if (i.state.registerRes.state == "success") {
+ if (i.state.registerRes.state === "success") {
const data = i.state.registerRes.data;
UserService.Instance.login({ res: data });
});
this.setState(s => {
- if (s.captchaRes.state == "success") {
+ if (s.captchaRes.state === "success") {
s.form.captcha_uuid = s.captchaRes.data.ok?.uuid;
}
return s;
}
get isLemmyMl(): boolean {
- return isBrowser() && window.location.hostname == "lemmy.ml";
+ return isBrowser() && window.location.hostname === "lemmy.ml";
}
render() {
<div className="mb-3 row">
<div className="col-sm-10">
<button type="submit" className="btn btn-secondary">
- {this.state.registerRes.state == "loading" ? (
+ {this.state.registerRes.state === "loading" ? (
<Spinner />
) : (
this.titleName(siteView)
handleRegisterEmailChange(i: Signup, event: any) {
i.state.form.email = event.target.value;
- if (i.state.form.email == "") {
+ if (i.state.form.email === "") {
i.state.form.email = undefined;
}
i.setState(i.state);
// This was a bad bug, it should only build the new audio on a new file.
// Replays would stop prematurely if this was rebuilt every time.
- if (i.state.captchaRes.state == "success" && i.state.captchaRes.data.ok) {
+ if (i.state.captchaRes.state === "success" && i.state.captchaRes.data.ok) {
const captchaRes = i.state.captchaRes.data.ok;
if (!i.audio) {
const base64 = `data:audio/wav;base64,${captchaRes.wav}`;
</select>
</div>
</div>
- {this.state.siteForm.registration_mode == "RequireApplication" && (
+ {this.state.siteForm.registration_mode === "RequireApplication" && (
<div className="mb-3 row">
<label className="col-12 col-form-label">
{I18NextService.i18n.t("application_questionnaire")}
{this.state.taglines.map((cv, index) => (
<tr key={index}>
<td>
- {this.state.editingRow == index && (
+ {this.state.editingRow === index && (
<MarkdownTextArea
initialContent={cv}
onContentChange={s =>
siteLanguages={[]}
/>
)}
- {this.state.editingRow != index && <div>{cv}</div>}
+ {this.state.editingRow !== index && <div>{cv}</div>}
</td>
<td className="text-right">
<button
handleEditTaglineClick(d: { i: TaglineForm; index: number }, event: any) {
event.preventDefault();
- if (d.i.state.editingRow == d.index) {
+ if (d.i.state.editingRow === d.index) {
d.i.setState({ editingRow: undefined });
} else {
d.i.setState({ editingRow: d.index });
get combined() {
const res = this.state.res;
- const combined = res.state == "success" ? buildCombined(res.data) : [];
+ const combined = res.state === "success" ? buildCombined(res.data) : [];
return (
<tbody>
get amAdminOrMod(): boolean {
const amMod_ =
- this.state.communityRes.state == "success" &&
+ this.state.communityRes.state === "success" &&
amMod(this.state.communityRes.data.moderators);
return amAdmin() || amMod_;
}
}
get hasUnreads(): boolean {
- if (this.state.unreadOrAll == UnreadOrAll.Unread) {
+ if (this.state.unreadOrAll === UnreadOrAll.Unread) {
const { repliesRes, mentionsRes, messagesRes } = this.state;
const replyCount =
- repliesRes.state == "success" ? repliesRes.data.replies.length : 0;
+ repliesRes.state === "success" ? repliesRes.data.replies.length : 0;
const mentionCount =
- mentionsRes.state == "success" ? mentionsRes.data.mentions.length : 0;
+ mentionsRes.state === "success" ? mentionsRes.data.mentions.length : 0;
const messageCount =
- messagesRes.state == "success"
+ messagesRes.state === "success"
? messagesRes.data.private_messages.length
: 0;
className="btn btn-secondary mb-2 mb-sm-3"
onClick={linkEvent(this, this.handleMarkAllAsRead)}
>
- {this.state.markAllAsReadRes.state == "loading" ? (
+ {this.state.markAllAsReadRes.state === "loading" ? (
<Spinner />
) : (
capitalizeFirstLetter(
buildCombined(): ReplyType[] {
const replies: ReplyType[] =
- this.state.repliesRes.state == "success"
+ this.state.repliesRes.state === "success"
? this.state.repliesRes.data.replies.map(this.replyToReplyType)
: [];
const mentions: ReplyType[] =
- this.state.mentionsRes.state == "success"
+ this.state.mentionsRes.state === "success"
? this.state.mentionsRes.data.mentions.map(this.mentionToReplyType)
: [];
const messages: ReplyType[] =
- this.state.messagesRes.state == "success"
+ this.state.messagesRes.state === "success"
? this.state.messagesRes.data.private_messages.map(
this.messageToReplyType
)
all() {
if (
- this.state.repliesRes.state == "loading" ||
- this.state.mentionsRes.state == "loading" ||
- this.state.messagesRes.state == "loading"
+ this.state.repliesRes.state === "loading" ||
+ this.state.mentionsRes.state === "loading" ||
+ this.state.messagesRes.state === "loading"
) {
return (
<h1 className="h4">
async refetch() {
const sort = this.state.sort;
- const unread_only = this.state.unreadOrAll == UnreadOrAll.Unread;
+ const unread_only = this.state.unreadOrAll === UnreadOrAll.Unread;
const page = this.state.page;
const limit = fetchLimit;
const auth = myAuthRequired();
}),
});
- if (i.state.markAllAsReadRes.state == "success") {
+ if (i.state.markAllAsReadRes.state === "success") {
i.setState({
repliesRes: { state: "empty" },
mentionsRes: { state: "empty" },
async handleBlockPerson(form: BlockPerson) {
const blockPersonRes = await HttpService.client.blockPerson(form);
- if (blockPersonRes.state == "success") {
+ if (blockPersonRes.state === "success") {
updatePersonBlock(blockPersonRes.data);
}
}
async handleDeleteComment(form: DeleteComment) {
const res = await HttpService.client.deleteComment(form);
- if (res.state == "success") {
+ if (res.state === "success") {
toast(I18NextService.i18n.t("deleted"));
this.findAndUpdateComment(res);
}
async handleRemoveComment(form: RemoveComment) {
const res = await HttpService.client.removeComment(form);
- if (res.state == "success") {
+ if (res.state === "success") {
toast(I18NextService.i18n.t("remove_comment"));
this.findAndUpdateComment(res);
}
async handleCreateMessage(form: CreatePrivateMessage) {
const res = await HttpService.client.createPrivateMessage(form);
this.setState(s => {
- if (s.messagesRes.state == "success" && res.state == "success") {
+ if (s.messagesRes.state === "success" && res.state === "success") {
s.messagesRes.data.private_messages.unshift(
res.data.private_message_view
);
updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
// Maybe not necessary
- if (banRes.state == "success") {
+ if (banRes.state === "success") {
this.setState(s => {
- if (s.repliesRes.state == "success") {
+ if (s.repliesRes.state === "success") {
s.repliesRes.data.replies
- .filter(c => c.creator.id == banRes.data.person_view.person.id)
+ .filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(
c => (c.creator_banned_from_community = banRes.data.banned)
);
}
- if (s.mentionsRes.state == "success") {
+ if (s.mentionsRes.state === "success") {
s.mentionsRes.data.mentions
- .filter(c => c.creator.id == banRes.data.person_view.person.id)
+ .filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(
c => (c.creator_banned_from_community = banRes.data.banned)
);
updateBan(banRes: RequestState<BanPersonResponse>) {
// Maybe not necessary
- if (banRes.state == "success") {
+ if (banRes.state === "success") {
this.setState(s => {
- if (s.repliesRes.state == "success") {
+ if (s.repliesRes.state === "success") {
s.repliesRes.data.replies
- .filter(c => c.creator.id == banRes.data.person_view.person.id)
+ .filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(c => (c.creator.banned = banRes.data.banned));
}
- if (s.mentionsRes.state == "success") {
+ if (s.mentionsRes.state === "success") {
s.mentionsRes.data.mentions
- .filter(c => c.creator.id == banRes.data.person_view.person.id)
+ .filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(c => (c.creator.banned = banRes.data.banned));
}
return s;
}
purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
- if (purgeRes.state == "success") {
+ if (purgeRes.state === "success") {
toast(I18NextService.i18n.t("purge_success"));
this.context.router.history.push(`/`);
}
reportToast(
res: RequestState<PrivateMessageReportResponse | CommentReportResponse>
) {
- if (res.state == "success") {
+ if (res.state === "success") {
toast(I18NextService.i18n.t("report_created"));
}
}
// A weird case, since you have only replies and mentions, not comment responses
findAndUpdateComment(res: RequestState<CommentResponse>) {
- if (res.state == "success") {
+ if (res.state === "success") {
this.setState(s => {
- if (s.repliesRes.state == "success") {
+ if (s.repliesRes.state === "success") {
s.repliesRes.data.replies = editWith(
res.data.comment_view,
s.repliesRes.data.replies
);
}
- if (s.mentionsRes.state == "success") {
+ if (s.mentionsRes.state === "success") {
s.mentionsRes.data.mentions = editWith(
res.data.comment_view,
s.mentionsRes.data.mentions
findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
this.setState(s => {
- if (s.repliesRes.state == "success" && res.state == "success") {
+ if (s.repliesRes.state === "success" && res.state === "success") {
s.repliesRes.data.replies = editCommentReply(
res.data.comment_reply_view,
s.repliesRes.data.replies
findAndUpdateMention(res: RequestState<PersonMentionResponse>) {
this.setState(s => {
- if (s.mentionsRes.state == "success" && res.state == "success") {
+ if (s.mentionsRes.state === "success" && res.state === "success") {
s.mentionsRes.data.mentions = editMention(
res.data.person_mention_view,
s.mentionsRes.data.mentions
<div className="mb-3 row">
<div className="col-sm-10">
<button type="submit" className="btn btn-secondary">
- {this.state.passwordChangeRes.state == "loading" ? (
+ {this.state.passwordChangeRes.state === "loading" ? (
<Spinner />
) : (
capitalizeFirstLetter(I18NextService.i18n.t("save"))
get documentTitle(): string {
const siteName = this.state.siteRes.site_view.site.name;
const res = this.state.personRes;
- return res.state == "success"
+ return res.state === "success"
? `@${res.data.person_view.person.name} - ${siteName}`
: siteName;
}
const personRes = i.state.personRes;
- if (personRes.state == "success") {
+ if (personRes.state === "success") {
const person = personRes.data.person_view.person;
const ban = !person.banned;
block,
auth: myAuthRequired(),
});
- if (res.state == "success") {
+ if (res.state === "success") {
updatePersonBlock(res.data);
}
}
async handleAddAdmin(form: AddAdmin) {
const addAdminRes = await HttpService.client.addAdmin(form);
- if (addAdminRes.state == "success") {
+ if (addAdminRes.state === "success") {
this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s));
}
}
// Maybe not necessary
if (banRes.state === "success") {
this.setState(s => {
- if (s.personRes.state == "success") {
+ if (s.personRes.state === "success") {
s.personRes.data.posts
.filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(
updateBan(banRes: RequestState<BanPersonResponse>) {
// Maybe not necessary
- if (banRes.state == "success") {
+ if (banRes.state === "success") {
this.setState(s => {
- if (s.personRes.state == "success") {
+ if (s.personRes.state === "success") {
s.personRes.data.posts
- .filter(c => c.creator.id == banRes.data.person_view.person.id)
+ .filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(c => (c.creator.banned = banRes.data.banned));
s.personRes.data.comments
- .filter(c => c.creator.id == banRes.data.person_view.person.id)
+ .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;
}
}
purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
- if (purgeRes.state == "success") {
+ if (purgeRes.state === "success") {
toast(I18NextService.i18n.t("purge_success"));
this.context.router.history.push(`/`);
}
findAndUpdateComment(res: RequestState<CommentResponse>) {
this.setState(s => {
- if (s.personRes.state == "success" && res.state == "success") {
+ if (s.personRes.state === "success" && res.state === "success") {
s.personRes.data.comments = editComment(
res.data.comment_view,
s.personRes.data.comments
createAndUpdateComments(res: RequestState<CommentResponse>) {
this.setState(s => {
- if (s.personRes.state == "success" && res.state == "success") {
+ if (s.personRes.state === "success" && res.state === "success") {
s.personRes.data.comments.unshift(res.data.comment_view);
// Set finished for the parent
s.finished.set(
findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
this.setState(s => {
- if (s.personRes.state == "success" && res.state == "success") {
+ if (s.personRes.state === "success" && res.state === "success") {
s.personRes.data.comments = editWith(
res.data.comment_reply_view,
s.personRes.data.comments
findAndUpdatePost(res: RequestState<PostResponse>) {
this.setState(s => {
- if (s.personRes.state == "success" && res.state == "success") {
+ if (s.personRes.state === "success" && res.state === "success") {
s.personRes.data.posts = editPost(
res.data.post_view,
s.personRes.data.posts
}
async refetch() {
- const unread_only = this.state.unreadOrAll == UnreadOrAll.Unread;
+ const unread_only = this.state.unreadOrAll === UnreadOrAll.Unread;
this.setState({
appsRes: { state: "loading" },
});
form
);
this.setState(s => {
- if (s.appsRes.state == "success" && approveRes.state == "success") {
+ if (s.appsRes.state === "success" && approveRes.state === "success") {
s.appsRes.data.registration_applications = editRegistrationApplication(
approveRes.data.registration_application,
s.appsRes.data.registration_applications
get buildCombined(): ItemType[] {
const commentRes = this.state.commentReportsRes;
const comments =
- commentRes.state == "success"
+ commentRes.state === "success"
? commentRes.data.comment_reports.map(this.commentReportToItemType)
: [];
const postRes = this.state.postReportsRes;
const posts =
- postRes.state == "success"
+ postRes.state === "success"
? postRes.data.post_reports.map(this.postReportToItemType)
: [];
const pmRes = this.state.messageReportsRes;
const privateMessages =
- pmRes.state == "success"
+ pmRes.state === "success"
? pmRes.data.private_message_reports.map(
this.privateMessageReportToItemType
)
}
async refetch() {
- const unresolved_only = this.state.unreadOrAll == UnreadOrAll.Unread;
+ const unresolved_only = this.state.unreadOrAll === UnreadOrAll.Unread;
const page = this.state.page;
const limit = fetchLimit;
const auth = myAuthRequired();
findAndUpdateCommentReport(res: RequestState<CommentReportResponse>) {
this.setState(s => {
- if (s.commentReportsRes.state == "success" && res.state == "success") {
+ if (s.commentReportsRes.state === "success" && res.state === "success") {
s.commentReportsRes.data.comment_reports = editCommentReport(
res.data.comment_report_view,
s.commentReportsRes.data.comment_reports
findAndUpdatePostReport(res: RequestState<PostReportResponse>) {
this.setState(s => {
- if (s.postReportsRes.state == "success" && res.state == "success") {
+ if (s.postReportsRes.state === "success" && res.state === "success") {
s.postReportsRes.data.post_reports = editPostReport(
res.data.post_report_view,
s.postReportsRes.data.post_reports
res: RequestState<PrivateMessageReportResponse>
) {
this.setState(s => {
- if (s.messageReportsRes.state == "success" && res.state == "success") {
+ if (s.messageReportsRes.state === "success" && res.state === "success") {
s.messageReportsRes.data.private_message_reports =
editPrivateMessageReport(
res.data.private_message_report_view,
id="user-remove-totp"
type="checkbox"
checked={
- this.state.saveUserSettingsForm.generate_totp_2fa == false
+ this.state.saveUserSettingsForm.generate_totp_2fa === false
}
onChange={linkEvent(this, this.handleRemoveTotp)}
/>
handleNewPasswordChange(i: Settings, event: any) {
const newPass: string | undefined =
- event.target.value == "" ? undefined : event.target.value;
+ event.target.value === "" ? undefined : event.target.value;
i.setState(s => ((s.changePasswordForm.new_password = newPass), s));
}
handleNewPasswordVerifyChange(i: Settings, event: any) {
const newPassVerify: string | undefined =
- event.target.value == "" ? undefined : event.target.value;
+ event.target.value === "" ? undefined : event.target.value;
i.setState(
s => ((s.changePasswordForm.new_password_verify = newPassVerify), s)
);
handleOldPasswordChange(i: Settings, event: any) {
const oldPass: string | undefined =
- event.target.value == "" ? undefined : event.target.value;
+ event.target.value === "" ? undefined : event.target.value;
i.setState(s => ((s.changePasswordForm.old_password = oldPass), s));
}
}),
});
- if (this.state.verifyRes.state == "success") {
+ if (this.state.verifyRes.state === "success") {
toast(I18NextService.i18n.t("email_verified"));
this.props.history.push("/login");
}
<div className="row">
<div className="col-12 col-lg-6 offset-lg-3 mb-4">
<h1 className="h4 mb-4">{I18NextService.i18n.t("verify_email")}</h1>
- {this.state.verifyRes.state == "loading" && (
+ {this.state.verifyRes.state === "loading" && (
<h5>
<Spinner large />
</h5>
componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & PostFormProps>
): void {
- if (this.props != nextProps) {
+ if (this.props !== nextProps) {
this.setState(
s => (
(s.form.community_id = getIdFromString(
get unreadCount(): number | undefined {
const pv = this.postView;
- return pv.unread_comments == pv.counts.comments || pv.unread_comments == 0
+ return pv.unread_comments === pv.counts.comments || pv.unread_comments === 0
? undefined
: pv.unread_comments;
}
removeAndBanDialogs() {
const post = this.postView;
const purgeTypeText =
- this.state.purgeType == PurgeType.Post
+ this.state.purgeType === PurgeType.Post
? I18NextService.i18n.t("purge_post")
: `${I18NextService.i18n.t("purge")} ${post.creator.name}`;
return (
private get myPost(): boolean {
return (
- this.postView.creator.id ==
+ this.postView.creator.id ===
UserService.Instance.myUserInfo?.local_user_view.person.id
);
}
const ban = !i.props.post_view.creator_banned_from_community;
// If its an unban, restore all their data
- if (ban == false) {
+ if (ban === false) {
i.setState({ removeData: false });
}
const person_id = i.props.post_view.creator.id;
const reason = i.state.banReason;
const expires = futureDaysToUnixTime(i.state.banExpireDays);
- if (i.state.banType == BanType.Community) {
+ if (i.state.banType === BanType.Community) {
const community_id = i.postView.community.id;
i.props.onBanPersonFromCommunity({
community_id,
// Sort by oldest
// Remove the ones that have no length
for (const e of urlMap.entries()) {
- if (e[1].length == 1) {
+ if (e[1].length === 1) {
urlMap.delete(e[0]);
} else {
e[1].sort((a, b) => a.post.published.localeCompare(b.post.published));
const found = urlMap.get(url);
if (found) {
// If its the oldest, add
- if (pv.post.id == found[0].post.id) {
+ if (pv.post.id === found[0].post.id) {
this.duplicatesMap.set(pv.post.id, found.slice(1));
}
// Otherwise, delete it
componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & PostReportProps>
): void {
- if (this.props != nextProps) {
+ if (this.props !== nextProps) {
this.setState({ loading: false });
}
}
const wrappedElement = document.getElementsByClassName("comments")[0];
if (wrappedElement && this.isBottom(wrappedElement)) {
const commentCount =
- this.state.commentsRes.state == "success"
+ this.state.commentsRes.state === "success"
? this.state.commentsRes.data.comments.length
: 0;
get documentTitle(): string {
const siteName = this.state.siteRes.site_view.site.name;
- return this.state.postRes.state == "success"
+ return this.state.postRes.state === "success"
? `${this.state.postRes.data.post_view.post.name} - ${siteName}`
: siteName;
}
get imageTag(): string | undefined {
- if (this.state.postRes.state == "success") {
+ if (this.state.postRes.state === "success") {
const post = this.state.postRes.data.post_view.post;
const thumbnail = post.thumbnail_url;
const url = post.url;
{this.state.showSidebarMobile && this.sidebar()}
</div>
{this.sortRadios()}
- {this.state.commentViewType == CommentViewType.Tree &&
+ {this.state.commentViewType === CommentViewType.Tree &&
this.commentsTree()}
- {this.state.commentViewType == CommentViewType.Flat &&
+ {this.state.commentViewType === CommentViewType.Flat &&
this.commentsFlat()}
</main>
<aside className="d-none d-md-block col-md-4 col-lg-3">
const commentsRes = this.state.commentsRes;
const postRes = this.state.postRes;
- if (commentsRes.state == "success" && postRes.state == "success") {
+ if (commentsRes.state === "success" && postRes.state === "success") {
return (
<div>
<CommentNodes
const showContextButton = depth ? depth > 0 : false;
return (
- res.state == "success" && (
+ res.state === "success" && (
<div>
{!!this.state.commentId && (
<>
}
commentTree(): CommentNodeI[] {
- if (this.state.commentsRes.state == "success") {
+ if (this.state.commentsRes.state === "success") {
return buildCommentsTree(
this.state.commentsRes.data.comments,
!!this.state.commentId
}
handleViewPost(i: Post) {
- if (i.state.postRes.state == "success") {
+ if (i.state.postRes.state === "success") {
const id = i.state.postRes.data.post_view.post.id;
i.context.router.history.push(`/post/${id}`);
}
}
handleViewContext(i: Post) {
- if (i.state.commentsRes.state == "success") {
+ if (i.state.commentsRes.state === "success") {
const parentId = getCommentParentId(
i.state.commentsRes.data.comments.at(0)?.comment
);
const communityId = followCommunityRes.data.community_view.community.id;
const mui = UserService.Instance.myUserInfo;
if (mui) {
- mui.follows = mui.follows.filter(i => i.community.id != communityId);
+ mui.follows = mui.follows.filter(i => i.community.id !== communityId);
}
}
}
async handleBlockCommunity(form: BlockCommunity) {
const blockCommunityRes = await HttpService.client.blockCommunity(form);
- if (blockCommunityRes.state == "success") {
+ if (blockCommunityRes.state === "success") {
updateCommunityBlock(blockCommunityRes.data);
this.setState(s => {
- if (s.postRes.state == "success") {
+ if (s.postRes.state === "success") {
s.postRes.data.community_view.blocked =
blockCommunityRes.data.blocked;
}
async handleBlockPerson(form: BlockPerson) {
const blockPersonRes = await HttpService.client.blockPerson(form);
- if (blockPersonRes.state == "success") {
+ if (blockPersonRes.state === "success") {
updatePersonBlock(blockPersonRes.data);
}
}
async handleCommentReport(form: CreateCommentReport) {
const reportRes = await HttpService.client.createCommentReport(form);
- if (reportRes.state == "success") {
+ if (reportRes.state === "success") {
toast(I18NextService.i18n.t("report_created"));
}
}
async handlePostReport(form: CreatePostReport) {
const reportRes = await HttpService.client.createPostReport(form);
- if (reportRes.state == "success") {
+ if (reportRes.state === "success") {
toast(I18NextService.i18n.t("report_created"));
}
}
async handleFetchChildren(form: GetComments) {
const moreCommentsRes = await HttpService.client.getComments(form);
if (
- this.state.commentsRes.state == "success" &&
- moreCommentsRes.state == "success"
+ this.state.commentsRes.state === "success" &&
+ moreCommentsRes.state === "success"
) {
const newComments = moreCommentsRes.data.comments;
// Remove the first comment, since it is the parent
updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
// Maybe not necessary
- if (banRes.state == "success") {
+ if (banRes.state === "success") {
this.setState(s => {
if (
- s.postRes.state == "success" &&
- s.postRes.data.post_view.creator.id ==
+ s.postRes.state === "success" &&
+ s.postRes.data.post_view.creator.id ===
banRes.data.person_view.person.id
) {
s.postRes.data.post_view.creator_banned_from_community =
banRes.data.banned;
}
- if (s.commentsRes.state == "success") {
+ if (s.commentsRes.state === "success") {
s.commentsRes.data.comments
- .filter(c => c.creator.id == banRes.data.person_view.person.id)
+ .filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(
c => (c.creator_banned_from_community = banRes.data.banned)
);
updateBan(banRes: RequestState<BanPersonResponse>) {
// Maybe not necessary
- if (banRes.state == "success") {
+ if (banRes.state === "success") {
this.setState(s => {
if (
- s.postRes.state == "success" &&
- s.postRes.data.post_view.creator.id ==
+ s.postRes.state === "success" &&
+ s.postRes.data.post_view.creator.id ===
banRes.data.person_view.person.id
) {
s.postRes.data.post_view.creator.banned = banRes.data.banned;
}
- if (s.commentsRes.state == "success") {
+ if (s.commentsRes.state === "success") {
s.commentsRes.data.comments
- .filter(c => c.creator.id == banRes.data.person_view.person.id)
+ .filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(c => (c.creator.banned = banRes.data.banned));
}
return s;
updateCommunity(communityRes: RequestState<CommunityResponse>) {
this.setState(s => {
- if (s.postRes.state == "success" && communityRes.state == "success") {
+ if (s.postRes.state === "success" && communityRes.state === "success") {
s.postRes.data.community_view = communityRes.data.community_view;
}
return s;
updateCommunityFull(res: RequestState<GetCommunityResponse>) {
this.setState(s => {
- if (s.postRes.state == "success" && res.state == "success") {
+ if (s.postRes.state === "success" && res.state === "success") {
s.postRes.data.community_view = res.data.community_view;
s.postRes.data.moderators = res.data.moderators;
}
updatePost(post: RequestState<PostResponse>) {
this.setState(s => {
- if (s.postRes.state == "success" && post.state == "success") {
+ if (s.postRes.state === "success" && post.state === "success") {
s.postRes.data.post_view = post.data.post_view;
}
return s;
}
purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
- if (purgeRes.state == "success") {
+ if (purgeRes.state === "success") {
toast(I18NextService.i18n.t("purge_success"));
this.context.router.history.push(`/`);
}
findAndUpdateComment(res: RequestState<CommentResponse>) {
this.setState(s => {
- if (s.commentsRes.state == "success" && res.state == "success") {
+ if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editComment(
res.data.comment_view,
s.commentsRes.data.comments
findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
this.setState(s => {
- if (s.commentsRes.state == "success" && res.state == "success") {
+ if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editWith(
res.data.comment_reply_view,
s.commentsRes.data.comments
updateModerators(res: RequestState<AddModToCommunityResponse>) {
// Update the moderators
this.setState(s => {
- if (s.postRes.state == "success" && res.state == "success") {
+ if (s.postRes.state === "success" && res.state === "success") {
s.postRes.data.moderators = res.data.moderators;
}
return s;
}
get documentTitle(): string {
- if (this.state.recipientRes.state == "success") {
+ if (this.state.recipientRes.state === "success") {
const name_ = this.state.recipientRes.data.person_view.person.name;
return `${I18NextService.i18n.t("create_private_message")} - ${name_}`;
} else {
async handlePrivateMessageCreate(form: CreatePrivateMessageI) {
const res = await HttpService.client.createPrivateMessage(form);
- if (res.state == "success") {
+ if (res.state === "success") {
toast(I18NextService.i18n.t("message_sent"));
// Navigate to the front
componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & PrivateMessageFormProps>
): void {
- if (this.props != nextProps) {
+ if (this.props !== nextProps) {
this.setState({ loading: false, content: undefined, previewMode: false });
}
}
componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & Props>
): void {
- if (this.props != nextProps) {
+ if (this.props !== nextProps) {
this.setState({ loading: false });
}
}
get mine(): boolean {
return (
- UserService.Instance.myUserInfo?.local_user_view.person.id ==
+ UserService.Instance.myUserInfo?.local_user_view.person.id ===
this.props.private_message_view.creator.id
);
}
componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & PrivateMessageProps>
): void {
- if (this.props != nextProps) {
+ if (this.props !== nextProps) {
this.setState({
showReply: false,
showEdit: false,
} = this.state;
const hasCommunities =
- communitiesRes.state == "success" &&
+ communitiesRes.state === "success" &&
communitiesRes.data.communities.length > 0;
return (
} = this.state;
// Push the possible resolve / federated objects first
- if (resolveObjectResponse.state == "success") {
+ if (resolveObjectResponse.state === "success") {
const { comment, post, community, person } = resolveObjectResponse.data;
if (comment) {
const item = tokens[idx] as any;
const title = item.attrs.length >= 3 ? item.attrs[2][1] : "";
const customEmoji = customEmojisLookup.get(title);
- const isCustomEmoji = customEmoji != undefined;
+ const isCustomEmoji = customEmoji !== undefined;
if (!isCustomEmoji) {
return defaultRenderer?.(tokens, idx, options, env, self) ?? "";
}
skins: [{ src: custom_emoji_view.custom_emoji.image_url }],
};
const categoryIndex = customEmojis.findIndex(
- x => x.id == custom_emoji_view.custom_emoji.category
+ x => x.id === custom_emoji_view.custom_emoji.category
);
- if (categoryIndex == -1) {
+ if (categoryIndex === -1) {
customEmojis.push({
id: custom_emoji_view.custom_emoji.category,
name: custom_emoji_view.custom_emoji.category,
});
} else {
const emojiIndex = customEmojis[categoryIndex].emojis.findIndex(
- x => x.id == custom_emoji_view.custom_emoji.shortcode
+ x => x.id === custom_emoji_view.custom_emoji.shortcode
);
- if (emojiIndex == -1) {
+ if (emojiIndex === -1) {
customEmojis[categoryIndex].emojis.push(emoji);
} else {
customEmojis[categoryIndex].emojis[emojiIndex] = emoji;
}
if (!view) return;
const categoryIndex = customEmojis.findIndex(
- x => x.id == view?.custom_emoji.category
+ x => x.id === view?.custom_emoji.category
);
const emojiIndex = customEmojis[categoryIndex].emojis.findIndex(
- x => x.id == view?.custom_emoji.shortcode
+ x => x.id === view?.custom_emoji.shortcode
);
customEmojis[categoryIndex].emojis = customEmojis[
categoryIndex
const customEmoji = customEmojisLookup.get(
item.original.key
)?.custom_emoji;
- if (customEmoji == undefined) return `${item.original.val}`;
+ if (customEmoji === undefined) return `${item.original.val}`;
else
return `![${customEmoji.alt_text}](${customEmoji.image_url} "${customEmoji.shortcode}")`;
},
import { VoteType } from "../../interfaces";
export default function newVote(voteType: VoteType, myVote?: number): number {
- if (voteType == VoteType.Upvote) {
- return myVote == 1 ? 0 : 1;
+ if (voteType === VoteType.Upvote) {
+ return myVote === 1 ? 0 : 1;
} else {
- return myVote == -1 ? 0 : -1;
+ return myVote === -1 ? 0 : -1;
}
}
): Language[] {
const allLangIds = allLanguages.map(l => l.id);
let myLangs = myUserInfo?.discussion_languages ?? allLangIds;
- myLangs = myLangs.length == 0 ? allLangIds : myLangs;
- const siteLangs = siteLanguages.length == 0 ? allLangIds : siteLanguages;
+ myLangs = myLangs.length === 0 ? allLangIds : myLangs;
+ const siteLangs = siteLanguages.length === 0 ? allLangIds : siteLanguages;
if (showAll) {
return allLanguages;
return;
}
// This is only run on a force reload
- if (theme == "browser") {
+ if (theme === "browser") {
theme = "darkly";
}
? `${window.location.hostname}${
["1234", "1235"].includes(window.location.port)
? ":8536"
- : window.location.port == ""
+ : window.location.port === ""
? ""
: `:${window.location.port}`
}`
export default function getRandomFromList<T>(list: T[]): T | undefined {
- return list.length == 0
+ return list.length === 0
? undefined
: list.at(Math.floor(Math.random() * list.length));
}
): boolean {
const myId = myUserInfo?.local_user_view.person.id;
// Don't allow mod actions on yourself
- return myId == mods?.at(0)?.moderator.id && myId != creator_id;
+ return myId === mods?.at(0)?.moderator.id && myId !== creator_id;
}
myUserInfo = UserService.Instance.myUserInfo
): boolean {
const myId = myUserInfo?.local_user_view.person.id;
- return myId == admins?.at(0)?.person.id && myId != creator_id;
+ return myId === admins?.at(0)?.person.id && myId !== creator_id;
}
mods: CommunityModeratorView[],
myUserInfo = UserService.Instance.myUserInfo
): boolean {
- return mods.at(0)?.moderator.id == myUserInfo?.local_user_view.person.id;
+ return mods.at(0)?.moderator.id === myUserInfo?.local_user_view.person.id;
}
if (myUserInfo) {
const myIndex = adminsThenMods.findIndex(
- id => id == myUserInfo.local_user_view.person.id
+ id => id === myUserInfo.local_user_view.person.id
);
- if (myIndex == -1) {
+ if (myIndex === -1) {
return false;
} else {
// onSelf +1 on mod actions not for yourself, IE ban, remove, etc