ES-Lint tweak (#2001)

This commit is contained in:
SleeplessOne1917 2023-07-28 20:07:16 +00:00 committed by GitHub
parent 908b7c5bb1
commit dd42bc2a3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 237 additions and 236 deletions

View file

@ -20,10 +20,11 @@
"@typescript-eslint/no-explicit-any": 0, "@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/explicit-module-boundary-types": 0, "@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/no-empty-function": 0, "@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-non-null-assertion": 0,
"arrow-body-style": 0, "arrow-body-style": 0,
"curly": 0, "curly": 0,
"eol-last": 0, "eol-last": 0,
"eqeqeq": 0, "eqeqeq": "error",
"func-style": 0, "func-style": 0,
"import/no-duplicates": 0, "import/no-duplicates": 0,
"max-statements": 0, "max-statements": 0,
@ -39,7 +40,7 @@
"no-useless-constructor": 0, "no-useless-constructor": 0,
"no-useless-escape": 0, "no-useless-escape": 0,
"no-var": 0, "no-var": 0,
"prefer-const": 1, "prefer-const": "error",
"prefer-rest-params": 0, "prefer-rest-params": 0,
"prettier/prettier": "error", "prettier/prettier": "error",
"quote-props": 0, "quote-props": 0,

View file

@ -48,7 +48,7 @@ export default async (req: Request, res: Response) => {
let errorPageData: ErrorPageData | undefined = undefined; let errorPageData: ErrorPageData | undefined = undefined;
let try_site = await client.getSite(getSiteForm); 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( console.error(
"Incorrect JWT token, skipping auth so frontend can remove jwt cookie" "Incorrect JWT token, skipping auth so frontend can remove jwt cookie"
); );

View file

@ -480,7 +480,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
} }
get unreadInboxCount(): number { get unreadInboxCount(): number {
if (this.state.unreadInboxCountRes.state == "success") { if (this.state.unreadInboxCountRes.state === "success") {
const data = this.state.unreadInboxCountRes.data; const data = this.state.unreadInboxCountRes.data;
return data.replies + data.mentions + data.private_messages; return data.replies + data.mentions + data.private_messages;
} else { } else {
@ -489,7 +489,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
} }
get unreadReportCount(): number { get unreadReportCount(): number {
if (this.state.unreadReportCountRes.state == "success") { if (this.state.unreadReportCountRes.state === "success") {
const data = this.state.unreadReportCountRes.data; const data = this.state.unreadReportCountRes.data;
return ( return (
data.post_reports + data.post_reports +
@ -502,7 +502,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
} }
get unreadApplicationCount(): number { get unreadApplicationCount(): number {
if (this.state.unreadApplicationCountRes.state == "success") { if (this.state.unreadApplicationCountRes.state === "success") {
const data = this.state.unreadApplicationCountRes.data; const data = this.state.unreadApplicationCountRes.data;
return data.registration_applications; return data.registration_applications;
} else { } else {

View file

@ -22,8 +22,8 @@ export class Theme extends Component<Props> {
</Helmet> </Helmet>
); );
} else if ( } else if (
this.props.defaultTheme != "browser" && this.props.defaultTheme !== "browser" &&
this.props.defaultTheme != "browser-compact" this.props.defaultTheme !== "browser-compact"
) { ) {
return ( return (
<Helmet> <Helmet>
@ -34,7 +34,7 @@ export class Theme extends Component<Props> {
/> />
</Helmet> </Helmet>
); );
} else if (this.props.defaultTheme == "browser-compact") { } else if (this.props.defaultTheme === "browser-compact") {
return ( return (
<Helmet> <Helmet>
<link <link

View file

@ -243,7 +243,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
const cv = this.commentView; const cv = this.commentView;
const purgeTypeText = const purgeTypeText =
this.state.purgeType == PurgeType.Comment this.state.purgeType === PurgeType.Comment
? I18NextService.i18n.t("purge_comment") ? I18NextService.i18n.t("purge_comment")
: `${I18NextService.i18n.t("purge")} ${cv.creator.name}`; : `${I18NextService.i18n.t("purge")} ${cv.creator.name}`;
@ -278,9 +278,9 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
: colorList[0]; : colorList[0];
const showMoreChildren = const showMoreChildren =
this.props.viewType == CommentViewType.Tree && this.props.viewType === CommentViewType.Tree &&
!this.state.collapsed && !this.state.collapsed &&
node.children.length == 0 && node.children.length === 0 &&
node.comment_view.counts.child_count > 0; node.comment_view.counts.child_count > 0;
return ( return (
@ -1210,19 +1210,19 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
get myComment(): boolean { get myComment(): boolean {
return ( return (
UserService.Instance.myUserInfo?.local_user_view.person.id == UserService.Instance.myUserInfo?.local_user_view.person.id ===
this.commentView.creator.id this.commentView.creator.id
); );
} }
get isPostCreator(): boolean { 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() { get scoreColor() {
if (this.commentView.my_vote == 1) { if (this.commentView.my_vote === 1) {
return "text-info"; return "text-info";
} else if (this.commentView.my_vote == -1) { } else if (this.commentView.my_vote === -1) {
return "text-danger"; return "text-danger";
} else { } else {
return "text-muted"; return "text-muted";
@ -1499,7 +1499,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
handleModBanBothSubmit(i: CommentNode, event: any) { handleModBanBothSubmit(i: CommentNode, event: any) {
event.preventDefault(); event.preventDefault();
if (i.state.banType == BanType.Community) { if (i.state.banType === BanType.Community) {
i.handleBanPersonFromCommunity(i); i.handleBanPersonFromCommunity(i);
} else { } else {
i.handleBanPerson(i); i.handleBanPerson(i);
@ -1552,7 +1552,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
event.preventDefault(); event.preventDefault();
i.setState({ purgeLoading: true }); i.setState({ purgeLoading: true });
if (i.state.purgeType == PurgeType.Person) { if (i.state.purgeType === PurgeType.Person) {
i.props.onPurgePerson({ i.props.onPurgePerson({
person_id: i.commentView.creator.id, person_id: i.commentView.creator.id,
reason: i.state.purgeReason, reason: i.state.purgeReason,

View file

@ -35,7 +35,7 @@ export class CommentReport extends Component<
componentWillReceiveProps( componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & CommentReportProps> nextProps: Readonly<{ children?: InfernoNode } & CommentReportProps>
): void { ): void {
if (this.props != nextProps) { if (this.props !== nextProps) {
this.setState({ loading: false }); this.setState({ loading: false });
} }
} }

View file

@ -360,7 +360,7 @@ export class MarkdownTextArea extends Component<
handleEmoji(i: MarkdownTextArea, e: any) { handleEmoji(i: MarkdownTextArea, e: any) {
let value = e.native; let value = e.native;
if (value == null) { if (value === null) {
const emoji = customEmojisLookup.get(e.id)?.custom_emoji; const emoji = customEmojisLookup.get(e.id)?.custom_emoji;
if (emoji) { if (emoji) {
value = `![${emoji.alt_text}](${emoji.image_url} "${emoji.shortcode}")`; value = `![${emoji.alt_text}](${emoji.image_url} "${emoji.shortcode}")`;

View file

@ -15,7 +15,7 @@ export class Paginator extends Component<PaginatorProps, any> {
<div className="paginator my-2"> <div className="paginator my-2">
<button <button
className="btn btn-secondary me-2" className="btn btn-secondary me-2"
disabled={this.props.page == 1} disabled={this.props.page === 1}
onClick={linkEvent(this, this.handlePrev)} onClick={linkEvent(this, this.handlePrev)}
> >
{I18NextService.i18n.t("prev")} {I18NextService.i18n.t("prev")}

View file

@ -146,7 +146,7 @@ class PasswordInput extends Component<PasswordInputProps, PasswordInputState> {
if (strength && ["weak", "medium"].includes(strength)) { if (strength && ["weak", "medium"].includes(strength)) {
return "text-warning"; return "text-warning";
} else if (strength == "strong") { } else if (strength === "strong") {
return "text-success"; return "text-success";
} else { } else {
return "text-danger"; return "text-danger";

View file

@ -56,7 +56,7 @@ export class PictrsImage extends Component<PictrsImageProps, any> {
const split = this.props.src.split("/pictrs/image/"); const split = this.props.src.split("/pictrs/image/");
// If theres not multiple, then its not a pictrs image // If theres not multiple, then its not a pictrs image
if (split.length == 1) { if (split.length === 1) {
return this.props.src; return this.props.src;
} }

View file

@ -44,7 +44,7 @@ export class RegistrationApplication extends Component<
{ children?: InfernoNode } & RegistrationApplicationProps { children?: InfernoNode } & RegistrationApplicationProps
> >
): void { ): void {
if (this.props != nextProps) { if (this.props !== nextProps) {
this.setState({ this.setState({
denyExpanded: false, denyExpanded: false,
approveLoading: false, approveLoading: false,

View file

@ -193,7 +193,7 @@ export class VoteButtons extends Component<VoteButtonsProps, VoteButtonsState> {
<button <button
type="button" type="button"
className={`btn-animate btn btn-link p-0 ${ 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)} onClick={linkEvent(this, handleUpvote)}
data-tippy-content={I18NextService.i18n.t("upvote")} data-tippy-content={I18NextService.i18n.t("upvote")}
@ -220,7 +220,7 @@ export class VoteButtons extends Component<VoteButtonsProps, VoteButtonsState> {
<button <button
type="button" type="button"
className={`btn-animate btn btn-link p-0 ${ 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)} onClick={linkEvent(this, handleDownvote)}
data-tippy-content={I18NextService.i18n.t("downvote")} data-tippy-content={I18NextService.i18n.t("downvote")}

View file

@ -172,7 +172,7 @@ export class Communities extends Component<any, CommunitiesState> {
{numToSI(cv.counts.comments)} {numToSI(cv.counts.comments)}
</td> </td>
<td className="text-right"> <td className="text-right">
{cv.subscribed == "Subscribed" && ( {cv.subscribed === "Subscribed" && (
<button <button
className="btn btn-link d-inline-block" className="btn btn-link d-inline-block"
onClick={linkEvent( onClick={linkEvent(
@ -369,8 +369,8 @@ export class Communities extends Component<any, CommunitiesState> {
findAndUpdateCommunity(res: RequestState<CommunityResponse>) { findAndUpdateCommunity(res: RequestState<CommunityResponse>) {
this.setState(s => { this.setState(s => {
if ( if (
s.listCommunitiesResponse.state == "success" && s.listCommunitiesResponse.state === "success" &&
res.state == "success" res.state === "success"
) { ) {
s.listCommunitiesResponse.data.communities = editCommunity( s.listCommunitiesResponse.data.communities = editCommunity(
res.data.community_view, res.data.community_view,

View file

@ -22,7 +22,7 @@ export class CommunityLink extends Component<CommunityLinkProps, any> {
render() { render() {
const community = this.props.community; const community = this.props.community;
let name_: string, title: string, link: string; 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) { if (local) {
name_ = community.name; name_ = community.name;
title = community.title; title = community.title;

View file

@ -290,7 +290,7 @@ export class Community extends Component<
get documentTitle(): string { get documentTitle(): string {
const cRes = this.state.communityRes; 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}` ? `${cRes.data.community_view.community.title} - ${this.isoData.site_res.site_view.site.name}`
: ""; : "";
} }
@ -626,11 +626,11 @@ export class Community extends Component<
this.updateCommunity(followCommunityRes); this.updateCommunity(followCommunityRes);
// Update myUserInfo // Update myUserInfo
if (followCommunityRes.state == "success") { if (followCommunityRes.state === "success") {
const communityId = followCommunityRes.data.community_view.community.id; const communityId = followCommunityRes.data.community_view.community.id;
const mui = UserService.Instance.myUserInfo; const mui = UserService.Instance.myUserInfo;
if (mui) { if (mui) {
mui.follows = mui.follows.filter(i => i.community.id != communityId); mui.follows = mui.follows.filter(i => i.community.id !== communityId);
} }
} }
} }
@ -657,10 +657,10 @@ export class Community extends Component<
async handleBlockCommunity(form: BlockCommunity) { async handleBlockCommunity(form: BlockCommunity) {
const blockCommunityRes = await HttpService.client.blockCommunity(form); const blockCommunityRes = await HttpService.client.blockCommunity(form);
if (blockCommunityRes.state == "success") { if (blockCommunityRes.state === "success") {
updateCommunityBlock(blockCommunityRes.data); updateCommunityBlock(blockCommunityRes.data);
this.setState(s => { this.setState(s => {
if (s.communityRes.state == "success") { if (s.communityRes.state === "success") {
s.communityRes.data.community_view.blocked = s.communityRes.data.community_view.blocked =
blockCommunityRes.data.blocked; blockCommunityRes.data.blocked;
} }
@ -670,7 +670,7 @@ export class Community extends Component<
async handleBlockPerson(form: BlockPerson) { async handleBlockPerson(form: BlockPerson) {
const blockPersonRes = await HttpService.client.blockPerson(form); const blockPersonRes = await HttpService.client.blockPerson(form);
if (blockPersonRes.state == "success") { if (blockPersonRes.state === "success") {
updatePersonBlock(blockPersonRes.data); updatePersonBlock(blockPersonRes.data);
} }
} }
@ -753,14 +753,14 @@ export class Community extends Component<
async handleCommentReport(form: CreateCommentReport) { async handleCommentReport(form: CreateCommentReport) {
const reportRes = await HttpService.client.createCommentReport(form); const reportRes = await HttpService.client.createCommentReport(form);
if (reportRes.state == "success") { if (reportRes.state === "success") {
toast(I18NextService.i18n.t("report_created")); toast(I18NextService.i18n.t("report_created"));
} }
} }
async handlePostReport(form: CreatePostReport) { async handlePostReport(form: CreatePostReport) {
const reportRes = await HttpService.client.createPostReport(form); const reportRes = await HttpService.client.createPostReport(form);
if (reportRes.state == "success") { if (reportRes.state === "success") {
toast(I18NextService.i18n.t("report_created")); toast(I18NextService.i18n.t("report_created"));
} }
} }
@ -778,7 +778,7 @@ export class Community extends Component<
async handleAddAdmin(form: AddAdmin) { async handleAddAdmin(form: AddAdmin) {
const addAdminRes = await HttpService.client.addAdmin(form); 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)); this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s));
} }
} }
@ -813,18 +813,18 @@ export class Community extends Component<
updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) { updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
// Maybe not necessary // Maybe not necessary
if (banRes.state == "success") { if (banRes.state === "success") {
this.setState(s => { this.setState(s => {
if (s.postsRes.state == "success") { if (s.postsRes.state === "success") {
s.postsRes.data.posts 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( .forEach(
c => (c.creator_banned_from_community = banRes.data.banned) c => (c.creator_banned_from_community = banRes.data.banned)
); );
} }
if (s.commentsRes.state == "success") { if (s.commentsRes.state === "success") {
s.commentsRes.data.comments 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( .forEach(
c => (c.creator_banned_from_community = banRes.data.banned) c => (c.creator_banned_from_community = banRes.data.banned)
); );
@ -836,16 +836,16 @@ export class Community extends Component<
updateBan(banRes: RequestState<BanPersonResponse>) { updateBan(banRes: RequestState<BanPersonResponse>) {
// Maybe not necessary // Maybe not necessary
if (banRes.state == "success") { if (banRes.state === "success") {
this.setState(s => { this.setState(s => {
if (s.postsRes.state == "success") { if (s.postsRes.state === "success") {
s.postsRes.data.posts 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)); .forEach(c => (c.creator.banned = banRes.data.banned));
} }
if (s.commentsRes.state == "success") { if (s.commentsRes.state === "success") {
s.commentsRes.data.comments 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)); .forEach(c => (c.creator.banned = banRes.data.banned));
} }
return s; return s;
@ -855,7 +855,7 @@ export class Community extends Component<
updateCommunity(res: RequestState<CommunityResponse>) { updateCommunity(res: RequestState<CommunityResponse>) {
this.setState(s => { 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.community_view = res.data.community_view;
s.communityRes.data.discussion_languages = s.communityRes.data.discussion_languages =
res.data.discussion_languages; res.data.discussion_languages;
@ -866,7 +866,7 @@ export class Community extends Component<
updateCommunityFull(res: RequestState<GetCommunityResponse>) { updateCommunityFull(res: RequestState<GetCommunityResponse>) {
this.setState(s => { 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.community_view = res.data.community_view;
s.communityRes.data.moderators = res.data.moderators; s.communityRes.data.moderators = res.data.moderators;
} }
@ -875,7 +875,7 @@ export class Community extends Component<
} }
purgeItem(purgeRes: RequestState<PurgeItemResponse>) { purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
if (purgeRes.state == "success") { if (purgeRes.state === "success") {
toast(I18NextService.i18n.t("purge_success")); toast(I18NextService.i18n.t("purge_success"));
this.context.router.history.push(`/`); this.context.router.history.push(`/`);
} }
@ -883,7 +883,7 @@ export class Community extends Component<
findAndUpdateComment(res: RequestState<CommentResponse>) { findAndUpdateComment(res: RequestState<CommentResponse>) {
this.setState(s => { this.setState(s => {
if (s.commentsRes.state == "success" && res.state == "success") { if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editComment( s.commentsRes.data.comments = editComment(
res.data.comment_view, res.data.comment_view,
s.commentsRes.data.comments s.commentsRes.data.comments
@ -896,7 +896,7 @@ export class Community extends Component<
createAndUpdateComments(res: RequestState<CommentResponse>) { createAndUpdateComments(res: RequestState<CommentResponse>) {
this.setState(s => { 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); s.commentsRes.data.comments.unshift(res.data.comment_view);
// Set finished for the parent // Set finished for the parent
@ -911,7 +911,7 @@ export class Community extends Component<
findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) { findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
this.setState(s => { this.setState(s => {
if (s.commentsRes.state == "success" && res.state == "success") { if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editWith( s.commentsRes.data.comments = editWith(
res.data.comment_reply_view, res.data.comment_reply_view,
s.commentsRes.data.comments s.commentsRes.data.comments
@ -923,7 +923,7 @@ export class Community extends Component<
findAndUpdatePost(res: RequestState<PostResponse>) { findAndUpdatePost(res: RequestState<PostResponse>) {
this.setState(s => { this.setState(s => {
if (s.postsRes.state == "success" && res.state == "success") { if (s.postsRes.state === "success" && res.state === "success") {
s.postsRes.data.posts = editPost( s.postsRes.data.posts = editPost(
res.data.post_view, res.data.post_view,
s.postsRes.data.posts s.postsRes.data.posts
@ -936,7 +936,7 @@ export class Community extends Component<
updateModerators(res: RequestState<AddModToCommunityResponse>) { updateModerators(res: RequestState<AddModToCommunityResponse>) {
// Update the moderators // Update the moderators
this.setState(s => { 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; s.communityRes.data.moderators = res.data.moderators;
} }
return s; return s;

View file

@ -81,13 +81,13 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
componentWillReceiveProps( componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & SidebarProps> nextProps: Readonly<{ children?: InfernoNode } & SidebarProps>
): void { ): void {
if (this.props.moderators != nextProps.moderators) { if (this.props.moderators !== nextProps.moderators) {
this.setState({ this.setState({
showConfirmLeaveModTeam: false, showConfirmLeaveModTeam: false,
}); });
} }
if (this.props.community_view != nextProps.community_view) { if (this.props.community_view !== nextProps.community_view) {
this.setState({ this.setState({
showEdit: false, showEdit: false,
showPurgeDialog: false, showPurgeDialog: false,

View file

@ -274,7 +274,7 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
onClick={linkEvent(this, this.handleLeaveAdminTeam)} onClick={linkEvent(this, this.handleLeaveAdminTeam)}
className="btn btn-danger mb-2" className="btn btn-danger mb-2"
> >
{this.state.leaveAdminTeamRes.state == "loading" ? ( {this.state.leaveAdminTeamRes.state === "loading" ? (
<Spinner /> <Spinner />
) : ( ) : (
I18NextService.i18n.t("leave_admin_team") I18NextService.i18n.t("leave_admin_team")

View file

@ -290,8 +290,8 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
cv.shortcode.length > 0; cv.shortcode.length > 0;
const noDuplicateShortCodes = const noDuplicateShortCodes =
this.state.customEmojis.filter( this.state.customEmojis.filter(
x => x.shortcode == cv.shortcode && x.id != cv.id x => x.shortcode === cv.shortcode && x.id !== cv.id
).length == 0; ).length === 0;
return noEmptyFields && noDuplicateShortCodes && !cv.loading && cv.changed; return noEmptyFields && noDuplicateShortCodes && !cv.loading && cv.changed;
} }
@ -308,7 +308,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
const view = customEmojisLookup.get(e.id); const view = customEmojisLookup.get(e.id);
if (view) { if (view) {
const page = this.state.customEmojis.find( const page = this.state.customEmojis.find(
x => x.id == view.custom_emoji.id x => x.id === view.custom_emoji.id
)?.page; )?.page;
if (page) { if (page) {
this.setState({ page: page }); this.setState({ page: page });
@ -420,7 +420,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
cv: CustomEmojiViewForm; cv: CustomEmojiViewForm;
}) { }) {
const pagedIndex = (d.i.state.page - 1) * d.i.itemsPerPage + d.index; 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({ d.i.props.onDelete({
id: d.cv.id, id: d.cv.id,
auth: myAuthRequired(), auth: myAuthRequired(),

View file

@ -900,7 +900,7 @@ export class Home extends Component<any, HomeState> {
async handleBlockPerson(form: BlockPerson) { async handleBlockPerson(form: BlockPerson) {
const blockPersonRes = await HttpService.client.blockPerson(form); const blockPersonRes = await HttpService.client.blockPerson(form);
if (blockPersonRes.state == "success") { if (blockPersonRes.state === "success") {
updatePersonBlock(blockPersonRes.data); updatePersonBlock(blockPersonRes.data);
} }
} }
@ -971,14 +971,14 @@ export class Home extends Component<any, HomeState> {
async handleCommentReport(form: CreateCommentReport) { async handleCommentReport(form: CreateCommentReport) {
const reportRes = await HttpService.client.createCommentReport(form); const reportRes = await HttpService.client.createCommentReport(form);
if (reportRes.state == "success") { if (reportRes.state === "success") {
toast(I18NextService.i18n.t("report_created")); toast(I18NextService.i18n.t("report_created"));
} }
} }
async handlePostReport(form: CreatePostReport) { async handlePostReport(form: CreatePostReport) {
const reportRes = await HttpService.client.createPostReport(form); const reportRes = await HttpService.client.createPostReport(form);
if (reportRes.state == "success") { if (reportRes.state === "success") {
toast(I18NextService.i18n.t("report_created")); toast(I18NextService.i18n.t("report_created"));
} }
} }
@ -996,7 +996,7 @@ export class Home extends Component<any, HomeState> {
async handleAddAdmin(form: AddAdmin) { async handleAddAdmin(form: AddAdmin) {
const addAdminRes = await HttpService.client.addAdmin(form); 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)); this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s));
} }
} }
@ -1028,18 +1028,18 @@ export class Home extends Component<any, HomeState> {
updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) { updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
// Maybe not necessary // Maybe not necessary
if (banRes.state == "success") { if (banRes.state === "success") {
this.setState(s => { this.setState(s => {
if (s.postsRes.state == "success") { if (s.postsRes.state === "success") {
s.postsRes.data.posts 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( .forEach(
c => (c.creator_banned_from_community = banRes.data.banned) c => (c.creator_banned_from_community = banRes.data.banned)
); );
} }
if (s.commentsRes.state == "success") { if (s.commentsRes.state === "success") {
s.commentsRes.data.comments 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( .forEach(
c => (c.creator_banned_from_community = banRes.data.banned) c => (c.creator_banned_from_community = banRes.data.banned)
); );
@ -1051,16 +1051,16 @@ export class Home extends Component<any, HomeState> {
updateBan(banRes: RequestState<BanPersonResponse>) { updateBan(banRes: RequestState<BanPersonResponse>) {
// Maybe not necessary // Maybe not necessary
if (banRes.state == "success") { if (banRes.state === "success") {
this.setState(s => { this.setState(s => {
if (s.postsRes.state == "success") { if (s.postsRes.state === "success") {
s.postsRes.data.posts 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)); .forEach(c => (c.creator.banned = banRes.data.banned));
} }
if (s.commentsRes.state == "success") { if (s.commentsRes.state === "success") {
s.commentsRes.data.comments 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)); .forEach(c => (c.creator.banned = banRes.data.banned));
} }
return s; return s;
@ -1069,7 +1069,7 @@ export class Home extends Component<any, HomeState> {
} }
purgeItem(purgeRes: RequestState<PurgeItemResponse>) { purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
if (purgeRes.state == "success") { if (purgeRes.state === "success") {
toast(I18NextService.i18n.t("purge_success")); toast(I18NextService.i18n.t("purge_success"));
this.context.router.history.push(`/`); this.context.router.history.push(`/`);
} }
@ -1077,7 +1077,7 @@ export class Home extends Component<any, HomeState> {
findAndUpdateComment(res: RequestState<CommentResponse>) { findAndUpdateComment(res: RequestState<CommentResponse>) {
this.setState(s => { this.setState(s => {
if (s.commentsRes.state == "success" && res.state == "success") { if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editComment( s.commentsRes.data.comments = editComment(
res.data.comment_view, res.data.comment_view,
s.commentsRes.data.comments s.commentsRes.data.comments
@ -1090,7 +1090,7 @@ export class Home extends Component<any, HomeState> {
createAndUpdateComments(res: RequestState<CommentResponse>) { createAndUpdateComments(res: RequestState<CommentResponse>) {
this.setState(s => { 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); s.commentsRes.data.comments.unshift(res.data.comment_view);
// Set finished for the parent // Set finished for the parent
@ -1105,7 +1105,7 @@ export class Home extends Component<any, HomeState> {
findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) { findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
this.setState(s => { this.setState(s => {
if (s.commentsRes.state == "success" && res.state == "success") { if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editWith( s.commentsRes.data.comments = editWith(
res.data.comment_reply_view, res.data.comment_reply_view,
s.commentsRes.data.comments s.commentsRes.data.comments
@ -1117,7 +1117,7 @@ export class Home extends Component<any, HomeState> {
findAndUpdatePost(res: RequestState<PostResponse>) { findAndUpdatePost(res: RequestState<PostResponse>) {
this.setState(s => { this.setState(s => {
if (s.postsRes.state == "success" && res.state == "success") { if (s.postsRes.state === "success" && res.state === "success") {
s.postsRes.data.posts = editPost( s.postsRes.data.posts = editPost(
res.data.post_view, res.data.post_view,
s.postsRes.data.posts s.postsRes.data.posts

View file

@ -127,7 +127,7 @@ export class LoginReset extends Component<any, State> {
const res = await HttpService.client.passwordReset({ email }); const res = await HttpService.client.passwordReset({ email });
if (res.state == "success") { if (res.state === "success") {
toast(I18NextService.i18n.t("reset_password_mail_sent")); toast(I18NextService.i18n.t("reset_password_mail_sent"));
i.context.router.history.push("/login"); i.context.router.history.push("/login");
} }

View file

@ -48,7 +48,7 @@ export class Login extends Component<any, State> {
} }
get isLemmyMl(): boolean { get isLemmyMl(): boolean {
return isBrowser() && window.location.hostname == "lemmy.ml"; return isBrowser() && window.location.hostname === "lemmy.ml";
} }
render() { render() {
@ -124,7 +124,7 @@ export class Login extends Component<any, State> {
<div className="mb-3 row"> <div className="mb-3 row">
<div className="col-sm-10"> <div className="col-sm-10">
<button type="submit" className="btn btn-secondary"> <button type="submit" className="btn btn-secondary">
{this.state.loginRes.state == "loading" ? ( {this.state.loginRes.state === "loading" ? (
<Spinner /> <Spinner />
) : ( ) : (
I18NextService.i18n.t("login") I18NextService.i18n.t("login")

View file

@ -141,7 +141,7 @@ export class Setup extends Component<any, State> {
<div className="mb-3 row"> <div className="mb-3 row">
<div className="col-sm-10"> <div className="col-sm-10">
<button type="submit" className="btn btn-secondary"> <button type="submit" className="btn btn-secondary">
{this.state.registerRes.state == "loading" ? ( {this.state.registerRes.state === "loading" ? (
<Spinner /> <Spinner />
) : ( ) : (
I18NextService.i18n.t("sign_up") I18NextService.i18n.t("sign_up")
@ -184,7 +184,7 @@ export class Setup extends Component<any, State> {
registerRes: await HttpService.client.register(form), registerRes: await HttpService.client.register(form),
}); });
if (i.state.registerRes.state == "success") { if (i.state.registerRes.state === "success") {
const data = i.state.registerRes.data; const data = i.state.registerRes.data;
UserService.Instance.login({ res: data }); UserService.Instance.login({ res: data });

View file

@ -71,7 +71,7 @@ export class Signup extends Component<any, State> {
}); });
this.setState(s => { this.setState(s => {
if (s.captchaRes.state == "success") { if (s.captchaRes.state === "success") {
s.form.captcha_uuid = s.captchaRes.data.ok?.uuid; s.form.captcha_uuid = s.captchaRes.data.ok?.uuid;
} }
return s; return s;
@ -90,7 +90,7 @@ export class Signup extends Component<any, State> {
} }
get isLemmyMl(): boolean { get isLemmyMl(): boolean {
return isBrowser() && window.location.hostname == "lemmy.ml"; return isBrowser() && window.location.hostname === "lemmy.ml";
} }
render() { render() {
@ -269,7 +269,7 @@ export class Signup extends Component<any, State> {
<div className="mb-3 row"> <div className="mb-3 row">
<div className="col-sm-10"> <div className="col-sm-10">
<button type="submit" className="btn btn-secondary"> <button type="submit" className="btn btn-secondary">
{this.state.registerRes.state == "loading" ? ( {this.state.registerRes.state === "loading" ? (
<Spinner /> <Spinner />
) : ( ) : (
this.titleName(siteView) this.titleName(siteView)
@ -424,7 +424,7 @@ export class Signup extends Component<any, State> {
handleRegisterEmailChange(i: Signup, event: any) { handleRegisterEmailChange(i: Signup, event: any) {
i.state.form.email = event.target.value; i.state.form.email = event.target.value;
if (i.state.form.email == "") { if (i.state.form.email === "") {
i.state.form.email = undefined; i.state.form.email = undefined;
} }
i.setState(i.state); i.setState(i.state);
@ -469,7 +469,7 @@ export class Signup extends Component<any, State> {
// This was a bad bug, it should only build the new audio on a new file. // 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. // 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; const captchaRes = i.state.captchaRes.data.ok;
if (!i.audio) { if (!i.audio) {
const base64 = `data:audio/wav;base64,${captchaRes.wav}`; const base64 = `data:audio/wav;base64,${captchaRes.wav}`;

View file

@ -293,7 +293,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
</select> </select>
</div> </div>
</div> </div>
{this.state.siteForm.registration_mode == "RequireApplication" && ( {this.state.siteForm.registration_mode === "RequireApplication" && (
<div className="mb-3 row"> <div className="mb-3 row">
<label className="col-12 col-form-label"> <label className="col-12 col-form-label">
{I18NextService.i18n.t("application_questionnaire")} {I18NextService.i18n.t("application_questionnaire")}

View file

@ -48,7 +48,7 @@ export class TaglineForm extends Component<TaglineFormProps, TaglineFormState> {
{this.state.taglines.map((cv, index) => ( {this.state.taglines.map((cv, index) => (
<tr key={index}> <tr key={index}>
<td> <td>
{this.state.editingRow == index && ( {this.state.editingRow === index && (
<MarkdownTextArea <MarkdownTextArea
initialContent={cv} initialContent={cv}
onContentChange={s => onContentChange={s =>
@ -59,7 +59,7 @@ export class TaglineForm extends Component<TaglineFormProps, TaglineFormState> {
siteLanguages={[]} siteLanguages={[]}
/> />
)} )}
{this.state.editingRow != index && <div>{cv}</div>} {this.state.editingRow !== index && <div>{cv}</div>}
</td> </td>
<td className="text-right"> <td className="text-right">
<button <button
@ -141,7 +141,7 @@ export class TaglineForm extends Component<TaglineFormProps, TaglineFormState> {
handleEditTaglineClick(d: { i: TaglineForm; index: number }, event: any) { handleEditTaglineClick(d: { i: TaglineForm; index: number }, event: any) {
event.preventDefault(); event.preventDefault();
if (d.i.state.editingRow == d.index) { if (d.i.state.editingRow === d.index) {
d.i.setState({ editingRow: undefined }); d.i.setState({ editingRow: undefined });
} else { } else {
d.i.setState({ editingRow: d.index }); d.i.setState({ editingRow: d.index });

View file

@ -698,7 +698,7 @@ export class Modlog extends Component<
get combined() { get combined() {
const res = this.state.res; const res = this.state.res;
const combined = res.state == "success" ? buildCombined(res.data) : []; const combined = res.state === "success" ? buildCombined(res.data) : [];
return ( return (
<tbody> <tbody>
@ -723,7 +723,7 @@ export class Modlog extends Component<
get amAdminOrMod(): boolean { get amAdminOrMod(): boolean {
const amMod_ = const amMod_ =
this.state.communityRes.state == "success" && this.state.communityRes.state === "success" &&
amMod(this.state.communityRes.data.moderators); amMod(this.state.communityRes.data.moderators);
return amAdmin() || amMod_; return amAdmin() || amMod_;
} }

View file

@ -194,14 +194,14 @@ export class Inbox extends Component<any, InboxState> {
} }
get hasUnreads(): boolean { get hasUnreads(): boolean {
if (this.state.unreadOrAll == UnreadOrAll.Unread) { if (this.state.unreadOrAll === UnreadOrAll.Unread) {
const { repliesRes, mentionsRes, messagesRes } = this.state; const { repliesRes, mentionsRes, messagesRes } = this.state;
const replyCount = const replyCount =
repliesRes.state == "success" ? repliesRes.data.replies.length : 0; repliesRes.state === "success" ? repliesRes.data.replies.length : 0;
const mentionCount = const mentionCount =
mentionsRes.state == "success" ? mentionsRes.data.mentions.length : 0; mentionsRes.state === "success" ? mentionsRes.data.mentions.length : 0;
const messageCount = const messageCount =
messagesRes.state == "success" messagesRes.state === "success"
? messagesRes.data.private_messages.length ? messagesRes.data.private_messages.length
: 0; : 0;
@ -242,7 +242,7 @@ export class Inbox extends Component<any, InboxState> {
className="btn btn-secondary mb-2 mb-sm-3" className="btn btn-secondary mb-2 mb-sm-3"
onClick={linkEvent(this, this.handleMarkAllAsRead)} onClick={linkEvent(this, this.handleMarkAllAsRead)}
> >
{this.state.markAllAsReadRes.state == "loading" ? ( {this.state.markAllAsReadRes.state === "loading" ? (
<Spinner /> <Spinner />
) : ( ) : (
capitalizeFirstLetter( capitalizeFirstLetter(
@ -445,15 +445,15 @@ export class Inbox extends Component<any, InboxState> {
buildCombined(): ReplyType[] { buildCombined(): ReplyType[] {
const replies: ReplyType[] = const replies: ReplyType[] =
this.state.repliesRes.state == "success" this.state.repliesRes.state === "success"
? this.state.repliesRes.data.replies.map(this.replyToReplyType) ? this.state.repliesRes.data.replies.map(this.replyToReplyType)
: []; : [];
const mentions: ReplyType[] = const mentions: ReplyType[] =
this.state.mentionsRes.state == "success" this.state.mentionsRes.state === "success"
? this.state.mentionsRes.data.mentions.map(this.mentionToReplyType) ? this.state.mentionsRes.data.mentions.map(this.mentionToReplyType)
: []; : [];
const messages: ReplyType[] = const messages: ReplyType[] =
this.state.messagesRes.state == "success" this.state.messagesRes.state === "success"
? this.state.messagesRes.data.private_messages.map( ? this.state.messagesRes.data.private_messages.map(
this.messageToReplyType this.messageToReplyType
) )
@ -559,9 +559,9 @@ export class Inbox extends Component<any, InboxState> {
all() { all() {
if ( if (
this.state.repliesRes.state == "loading" || this.state.repliesRes.state === "loading" ||
this.state.mentionsRes.state == "loading" || this.state.mentionsRes.state === "loading" ||
this.state.messagesRes.state == "loading" this.state.messagesRes.state === "loading"
) { ) {
return ( return (
<h1 className="h4"> <h1 className="h4">
@ -754,7 +754,7 @@ export class Inbox extends Component<any, InboxState> {
async refetch() { async refetch() {
const sort = this.state.sort; 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 page = this.state.page;
const limit = fetchLimit; const limit = fetchLimit;
const auth = myAuthRequired(); const auth = myAuthRequired();
@ -806,7 +806,7 @@ export class Inbox extends Component<any, InboxState> {
}), }),
}); });
if (i.state.markAllAsReadRes.state == "success") { if (i.state.markAllAsReadRes.state === "success") {
i.setState({ i.setState({
repliesRes: { state: "empty" }, repliesRes: { state: "empty" },
mentionsRes: { state: "empty" }, mentionsRes: { state: "empty" },
@ -837,7 +837,7 @@ export class Inbox extends Component<any, InboxState> {
async handleBlockPerson(form: BlockPerson) { async handleBlockPerson(form: BlockPerson) {
const blockPersonRes = await HttpService.client.blockPerson(form); const blockPersonRes = await HttpService.client.blockPerson(form);
if (blockPersonRes.state == "success") { if (blockPersonRes.state === "success") {
updatePersonBlock(blockPersonRes.data); updatePersonBlock(blockPersonRes.data);
} }
} }
@ -868,7 +868,7 @@ export class Inbox extends Component<any, InboxState> {
async handleDeleteComment(form: DeleteComment) { async handleDeleteComment(form: DeleteComment) {
const res = await HttpService.client.deleteComment(form); const res = await HttpService.client.deleteComment(form);
if (res.state == "success") { if (res.state === "success") {
toast(I18NextService.i18n.t("deleted")); toast(I18NextService.i18n.t("deleted"));
this.findAndUpdateComment(res); this.findAndUpdateComment(res);
} }
@ -876,7 +876,7 @@ export class Inbox extends Component<any, InboxState> {
async handleRemoveComment(form: RemoveComment) { async handleRemoveComment(form: RemoveComment) {
const res = await HttpService.client.removeComment(form); const res = await HttpService.client.removeComment(form);
if (res.state == "success") { if (res.state === "success") {
toast(I18NextService.i18n.t("remove_comment")); toast(I18NextService.i18n.t("remove_comment"));
this.findAndUpdateComment(res); this.findAndUpdateComment(res);
} }
@ -958,7 +958,7 @@ export class Inbox extends Component<any, InboxState> {
async handleCreateMessage(form: CreatePrivateMessage) { async handleCreateMessage(form: CreatePrivateMessage) {
const res = await HttpService.client.createPrivateMessage(form); const res = await HttpService.client.createPrivateMessage(form);
this.setState(s => { 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( s.messagesRes.data.private_messages.unshift(
res.data.private_message_view res.data.private_message_view
); );
@ -982,18 +982,18 @@ export class Inbox extends Component<any, InboxState> {
updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) { updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
// Maybe not necessary // Maybe not necessary
if (banRes.state == "success") { if (banRes.state === "success") {
this.setState(s => { this.setState(s => {
if (s.repliesRes.state == "success") { if (s.repliesRes.state === "success") {
s.repliesRes.data.replies 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( .forEach(
c => (c.creator_banned_from_community = banRes.data.banned) c => (c.creator_banned_from_community = banRes.data.banned)
); );
} }
if (s.mentionsRes.state == "success") { if (s.mentionsRes.state === "success") {
s.mentionsRes.data.mentions 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( .forEach(
c => (c.creator_banned_from_community = banRes.data.banned) c => (c.creator_banned_from_community = banRes.data.banned)
); );
@ -1005,16 +1005,16 @@ export class Inbox extends Component<any, InboxState> {
updateBan(banRes: RequestState<BanPersonResponse>) { updateBan(banRes: RequestState<BanPersonResponse>) {
// Maybe not necessary // Maybe not necessary
if (banRes.state == "success") { if (banRes.state === "success") {
this.setState(s => { this.setState(s => {
if (s.repliesRes.state == "success") { if (s.repliesRes.state === "success") {
s.repliesRes.data.replies 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)); .forEach(c => (c.creator.banned = banRes.data.banned));
} }
if (s.mentionsRes.state == "success") { if (s.mentionsRes.state === "success") {
s.mentionsRes.data.mentions 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)); .forEach(c => (c.creator.banned = banRes.data.banned));
} }
return s; return s;
@ -1023,7 +1023,7 @@ export class Inbox extends Component<any, InboxState> {
} }
purgeItem(purgeRes: RequestState<PurgeItemResponse>) { purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
if (purgeRes.state == "success") { if (purgeRes.state === "success") {
toast(I18NextService.i18n.t("purge_success")); toast(I18NextService.i18n.t("purge_success"));
this.context.router.history.push(`/`); this.context.router.history.push(`/`);
} }
@ -1032,22 +1032,22 @@ export class Inbox extends Component<any, InboxState> {
reportToast( reportToast(
res: RequestState<PrivateMessageReportResponse | CommentReportResponse> res: RequestState<PrivateMessageReportResponse | CommentReportResponse>
) { ) {
if (res.state == "success") { if (res.state === "success") {
toast(I18NextService.i18n.t("report_created")); toast(I18NextService.i18n.t("report_created"));
} }
} }
// A weird case, since you have only replies and mentions, not comment responses // A weird case, since you have only replies and mentions, not comment responses
findAndUpdateComment(res: RequestState<CommentResponse>) { findAndUpdateComment(res: RequestState<CommentResponse>) {
if (res.state == "success") { if (res.state === "success") {
this.setState(s => { this.setState(s => {
if (s.repliesRes.state == "success") { if (s.repliesRes.state === "success") {
s.repliesRes.data.replies = editWith( s.repliesRes.data.replies = editWith(
res.data.comment_view, res.data.comment_view,
s.repliesRes.data.replies s.repliesRes.data.replies
); );
} }
if (s.mentionsRes.state == "success") { if (s.mentionsRes.state === "success") {
s.mentionsRes.data.mentions = editWith( s.mentionsRes.data.mentions = editWith(
res.data.comment_view, res.data.comment_view,
s.mentionsRes.data.mentions s.mentionsRes.data.mentions
@ -1065,7 +1065,7 @@ export class Inbox extends Component<any, InboxState> {
findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) { findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
this.setState(s => { this.setState(s => {
if (s.repliesRes.state == "success" && res.state == "success") { if (s.repliesRes.state === "success" && res.state === "success") {
s.repliesRes.data.replies = editCommentReply( s.repliesRes.data.replies = editCommentReply(
res.data.comment_reply_view, res.data.comment_reply_view,
s.repliesRes.data.replies s.repliesRes.data.replies
@ -1077,7 +1077,7 @@ export class Inbox extends Component<any, InboxState> {
findAndUpdateMention(res: RequestState<PersonMentionResponse>) { findAndUpdateMention(res: RequestState<PersonMentionResponse>) {
this.setState(s => { this.setState(s => {
if (s.mentionsRes.state == "success" && res.state == "success") { if (s.mentionsRes.state === "success" && res.state === "success") {
s.mentionsRes.data.mentions = editMention( s.mentionsRes.data.mentions = editMention(
res.data.person_mention_view, res.data.person_mention_view,
s.mentionsRes.data.mentions s.mentionsRes.data.mentions

View file

@ -81,7 +81,7 @@ export class PasswordChange extends Component<any, State> {
<div className="mb-3 row"> <div className="mb-3 row">
<div className="col-sm-10"> <div className="col-sm-10">
<button type="submit" className="btn btn-secondary"> <button type="submit" className="btn btn-secondary">
{this.state.passwordChangeRes.state == "loading" ? ( {this.state.passwordChangeRes.state === "loading" ? (
<Spinner /> <Spinner />
) : ( ) : (
capitalizeFirstLetter(I18NextService.i18n.t("save")) capitalizeFirstLetter(I18NextService.i18n.t("save"))

View file

@ -300,7 +300,7 @@ export class Profile extends Component<
get documentTitle(): string { get documentTitle(): string {
const siteName = this.state.siteRes.site_view.site.name; const siteName = this.state.siteRes.site_view.site.name;
const res = this.state.personRes; const res = this.state.personRes;
return res.state == "success" return res.state === "success"
? `@${res.data.person_view.person.name} - ${siteName}` ? `@${res.data.person_view.person.name} - ${siteName}`
: siteName; : siteName;
} }
@ -764,7 +764,7 @@ export class Profile extends Component<
const personRes = i.state.personRes; const personRes = i.state.personRes;
if (personRes.state == "success") { if (personRes.state === "success") {
const person = personRes.data.person_view.person; const person = personRes.data.person_view.person;
const ban = !person.banned; const ban = !person.banned;
@ -793,7 +793,7 @@ export class Profile extends Component<
block, block,
auth: myAuthRequired(), auth: myAuthRequired(),
}); });
if (res.state == "success") { if (res.state === "success") {
updatePersonBlock(res.data); updatePersonBlock(res.data);
} }
} }
@ -924,7 +924,7 @@ export class Profile extends Component<
async handleAddAdmin(form: AddAdmin) { async handleAddAdmin(form: AddAdmin) {
const addAdminRes = await HttpService.client.addAdmin(form); 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)); this.setState(s => ((s.siteRes.admins = addAdminRes.data.admins), s));
} }
} }
@ -958,7 +958,7 @@ export class Profile extends Component<
// Maybe not necessary // Maybe not necessary
if (banRes.state === "success") { if (banRes.state === "success") {
this.setState(s => { this.setState(s => {
if (s.personRes.state == "success") { if (s.personRes.state === "success") {
s.personRes.data.posts 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( .forEach(
@ -978,14 +978,14 @@ export class Profile extends Component<
updateBan(banRes: RequestState<BanPersonResponse>) { updateBan(banRes: RequestState<BanPersonResponse>) {
// Maybe not necessary // Maybe not necessary
if (banRes.state == "success") { if (banRes.state === "success") {
this.setState(s => { this.setState(s => {
if (s.personRes.state == "success") { if (s.personRes.state === "success") {
s.personRes.data.posts 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)); .forEach(c => (c.creator.banned = banRes.data.banned));
s.personRes.data.comments 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)); .forEach(c => (c.creator.banned = banRes.data.banned));
s.personRes.data.person_view.person.banned = banRes.data.banned; s.personRes.data.person_view.person.banned = banRes.data.banned;
} }
@ -995,7 +995,7 @@ export class Profile extends Component<
} }
purgeItem(purgeRes: RequestState<PurgeItemResponse>) { purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
if (purgeRes.state == "success") { if (purgeRes.state === "success") {
toast(I18NextService.i18n.t("purge_success")); toast(I18NextService.i18n.t("purge_success"));
this.context.router.history.push(`/`); this.context.router.history.push(`/`);
} }
@ -1003,7 +1003,7 @@ export class Profile extends Component<
findAndUpdateComment(res: RequestState<CommentResponse>) { findAndUpdateComment(res: RequestState<CommentResponse>) {
this.setState(s => { this.setState(s => {
if (s.personRes.state == "success" && res.state == "success") { if (s.personRes.state === "success" && res.state === "success") {
s.personRes.data.comments = editComment( s.personRes.data.comments = editComment(
res.data.comment_view, res.data.comment_view,
s.personRes.data.comments s.personRes.data.comments
@ -1016,7 +1016,7 @@ export class Profile extends Component<
createAndUpdateComments(res: RequestState<CommentResponse>) { createAndUpdateComments(res: RequestState<CommentResponse>) {
this.setState(s => { 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); s.personRes.data.comments.unshift(res.data.comment_view);
// Set finished for the parent // Set finished for the parent
s.finished.set( s.finished.set(
@ -1030,7 +1030,7 @@ export class Profile extends Component<
findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) { findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
this.setState(s => { this.setState(s => {
if (s.personRes.state == "success" && res.state == "success") { if (s.personRes.state === "success" && res.state === "success") {
s.personRes.data.comments = editWith( s.personRes.data.comments = editWith(
res.data.comment_reply_view, res.data.comment_reply_view,
s.personRes.data.comments s.personRes.data.comments
@ -1042,7 +1042,7 @@ export class Profile extends Component<
findAndUpdatePost(res: RequestState<PostResponse>) { findAndUpdatePost(res: RequestState<PostResponse>) {
this.setState(s => { this.setState(s => {
if (s.personRes.state == "success" && res.state == "success") { if (s.personRes.state === "success" && res.state === "success") {
s.personRes.data.posts = editPost( s.personRes.data.posts = editPost(
res.data.post_view, res.data.post_view,
s.personRes.data.posts s.personRes.data.posts

View file

@ -220,7 +220,7 @@ export class RegistrationApplications extends Component<
} }
async refetch() { async refetch() {
const unread_only = this.state.unreadOrAll == UnreadOrAll.Unread; const unread_only = this.state.unreadOrAll === UnreadOrAll.Unread;
this.setState({ this.setState({
appsRes: { state: "loading" }, appsRes: { state: "loading" },
}); });
@ -239,7 +239,7 @@ export class RegistrationApplications extends Component<
form form
); );
this.setState(s => { 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( s.appsRes.data.registration_applications = editRegistrationApplication(
approveRes.data.registration_application, approveRes.data.registration_application,
s.appsRes.data.registration_applications s.appsRes.data.registration_applications

View file

@ -352,18 +352,18 @@ export class Reports extends Component<any, ReportsState> {
get buildCombined(): ItemType[] { get buildCombined(): ItemType[] {
const commentRes = this.state.commentReportsRes; const commentRes = this.state.commentReportsRes;
const comments = const comments =
commentRes.state == "success" commentRes.state === "success"
? commentRes.data.comment_reports.map(this.commentReportToItemType) ? commentRes.data.comment_reports.map(this.commentReportToItemType)
: []; : [];
const postRes = this.state.postReportsRes; const postRes = this.state.postReportsRes;
const posts = const posts =
postRes.state == "success" postRes.state === "success"
? postRes.data.post_reports.map(this.postReportToItemType) ? postRes.data.post_reports.map(this.postReportToItemType)
: []; : [];
const pmRes = this.state.messageReportsRes; const pmRes = this.state.messageReportsRes;
const privateMessages = const privateMessages =
pmRes.state == "success" pmRes.state === "success"
? pmRes.data.private_message_reports.map( ? pmRes.data.private_message_reports.map(
this.privateMessageReportToItemType this.privateMessageReportToItemType
) )
@ -565,7 +565,7 @@ export class Reports extends Component<any, ReportsState> {
} }
async refetch() { async refetch() {
const unresolved_only = this.state.unreadOrAll == UnreadOrAll.Unread; const unresolved_only = this.state.unreadOrAll === UnreadOrAll.Unread;
const page = this.state.page; const page = this.state.page;
const limit = fetchLimit; const limit = fetchLimit;
const auth = myAuthRequired(); const auth = myAuthRequired();
@ -617,7 +617,7 @@ export class Reports extends Component<any, ReportsState> {
findAndUpdateCommentReport(res: RequestState<CommentReportResponse>) { findAndUpdateCommentReport(res: RequestState<CommentReportResponse>) {
this.setState(s => { 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( s.commentReportsRes.data.comment_reports = editCommentReport(
res.data.comment_report_view, res.data.comment_report_view,
s.commentReportsRes.data.comment_reports s.commentReportsRes.data.comment_reports
@ -629,7 +629,7 @@ export class Reports extends Component<any, ReportsState> {
findAndUpdatePostReport(res: RequestState<PostReportResponse>) { findAndUpdatePostReport(res: RequestState<PostReportResponse>) {
this.setState(s => { 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( s.postReportsRes.data.post_reports = editPostReport(
res.data.post_report_view, res.data.post_report_view,
s.postReportsRes.data.post_reports s.postReportsRes.data.post_reports
@ -643,7 +643,7 @@ export class Reports extends Component<any, ReportsState> {
res: RequestState<PrivateMessageReportResponse> res: RequestState<PrivateMessageReportResponse>
) { ) {
this.setState(s => { 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 = s.messageReportsRes.data.private_message_reports =
editPrivateMessageReport( editPrivateMessageReport(
res.data.private_message_report_view, res.data.private_message_report_view,

View file

@ -887,7 +887,7 @@ export class Settings extends Component<any, SettingsState> {
id="user-remove-totp" id="user-remove-totp"
type="checkbox" type="checkbox"
checked={ checked={
this.state.saveUserSettingsForm.generate_totp_2fa == false this.state.saveUserSettingsForm.generate_totp_2fa === false
} }
onChange={linkEvent(this, this.handleRemoveTotp)} onChange={linkEvent(this, this.handleRemoveTotp)}
/> />
@ -1132,13 +1132,13 @@ export class Settings extends Component<any, SettingsState> {
handleNewPasswordChange(i: Settings, event: any) { handleNewPasswordChange(i: Settings, event: any) {
const newPass: string | undefined = 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)); i.setState(s => ((s.changePasswordForm.new_password = newPass), s));
} }
handleNewPasswordVerifyChange(i: Settings, event: any) { handleNewPasswordVerifyChange(i: Settings, event: any) {
const newPassVerify: string | undefined = const newPassVerify: string | undefined =
event.target.value == "" ? undefined : event.target.value; event.target.value === "" ? undefined : event.target.value;
i.setState( i.setState(
s => ((s.changePasswordForm.new_password_verify = newPassVerify), s) s => ((s.changePasswordForm.new_password_verify = newPassVerify), s)
); );
@ -1146,7 +1146,7 @@ export class Settings extends Component<any, SettingsState> {
handleOldPasswordChange(i: Settings, event: any) { handleOldPasswordChange(i: Settings, event: any) {
const oldPass: string | undefined = 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)); i.setState(s => ((s.changePasswordForm.old_password = oldPass), s));
} }

View file

@ -35,7 +35,7 @@ export class VerifyEmail extends Component<any, State> {
}), }),
}); });
if (this.state.verifyRes.state == "success") { if (this.state.verifyRes.state === "success") {
toast(I18NextService.i18n.t("email_verified")); toast(I18NextService.i18n.t("email_verified"));
this.props.history.push("/login"); this.props.history.push("/login");
} }
@ -61,7 +61,7 @@ export class VerifyEmail extends Component<any, State> {
<div className="row"> <div className="row">
<div className="col-12 col-lg-6 offset-lg-3 mb-4"> <div className="col-12 col-lg-6 offset-lg-3 mb-4">
<h1 className="h4 mb-4">{I18NextService.i18n.t("verify_email")}</h1> <h1 className="h4 mb-4">{I18NextService.i18n.t("verify_email")}</h1>
{this.state.verifyRes.state == "loading" && ( {this.state.verifyRes.state === "loading" && (
<h5> <h5>
<Spinner large /> <Spinner large />
</h5> </h5>

View file

@ -312,7 +312,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
componentWillReceiveProps( componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & PostFormProps> nextProps: Readonly<{ children?: InfernoNode } & PostFormProps>
): void { ): void {
if (this.props != nextProps) { if (this.props !== nextProps) {
this.setState( this.setState(
s => ( s => (
(s.form.community_id = getIdFromString( (s.form.community_id = getIdFromString(

View file

@ -765,7 +765,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
get unreadCount(): number | undefined { get unreadCount(): number | undefined {
const pv = this.postView; 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 ? undefined
: pv.unread_comments; : pv.unread_comments;
} }
@ -1136,7 +1136,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
removeAndBanDialogs() { removeAndBanDialogs() {
const post = this.postView; const post = this.postView;
const purgeTypeText = const purgeTypeText =
this.state.purgeType == PurgeType.Post this.state.purgeType === PurgeType.Post
? I18NextService.i18n.t("purge_post") ? I18NextService.i18n.t("purge_post")
: `${I18NextService.i18n.t("purge")} ${post.creator.name}`; : `${I18NextService.i18n.t("purge")} ${post.creator.name}`;
return ( return (
@ -1405,7 +1405,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
private get myPost(): boolean { private get myPost(): boolean {
return ( return (
this.postView.creator.id == this.postView.creator.id ===
UserService.Instance.myUserInfo?.local_user_view.person.id UserService.Instance.myUserInfo?.local_user_view.person.id
); );
} }
@ -1644,7 +1644,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
const ban = !i.props.post_view.creator_banned_from_community; const ban = !i.props.post_view.creator_banned_from_community;
// If its an unban, restore all their data // If its an unban, restore all their data
if (ban == false) { if (ban === false) {
i.setState({ removeData: false }); i.setState({ removeData: false });
} }
const person_id = i.props.post_view.creator.id; const person_id = i.props.post_view.creator.id;
@ -1652,7 +1652,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
const reason = i.state.banReason; const reason = i.state.banReason;
const expires = futureDaysToUnixTime(i.state.banExpireDays); 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; const community_id = i.postView.community.id;
i.props.onBanPersonFromCommunity({ i.props.onBanPersonFromCommunity({
community_id, community_id,

View file

@ -141,7 +141,7 @@ export class PostListings extends Component<PostListingsProps, any> {
// Sort by oldest // Sort by oldest
// Remove the ones that have no length // Remove the ones that have no length
for (const e of urlMap.entries()) { for (const e of urlMap.entries()) {
if (e[1].length == 1) { if (e[1].length === 1) {
urlMap.delete(e[0]); urlMap.delete(e[0]);
} else { } else {
e[1].sort((a, b) => a.post.published.localeCompare(b.post.published)); e[1].sort((a, b) => a.post.published.localeCompare(b.post.published));
@ -155,7 +155,7 @@ export class PostListings extends Component<PostListingsProps, any> {
const found = urlMap.get(url); const found = urlMap.get(url);
if (found) { if (found) {
// If its the oldest, add // 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)); this.duplicatesMap.set(pv.post.id, found.slice(1));
} }
// Otherwise, delete it // Otherwise, delete it

View file

@ -28,7 +28,7 @@ export class PostReport extends Component<PostReportProps, PostReportState> {
componentWillReceiveProps( componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & PostReportProps> nextProps: Readonly<{ children?: InfernoNode } & PostReportProps>
): void { ): void {
if (this.props != nextProps) { if (this.props !== nextProps) {
this.setState({ loading: false }); this.setState({ loading: false });
} }
} }

View file

@ -309,7 +309,7 @@ export class Post extends Component<any, PostState> {
const wrappedElement = document.getElementsByClassName("comments")[0]; const wrappedElement = document.getElementsByClassName("comments")[0];
if (wrappedElement && this.isBottom(wrappedElement)) { if (wrappedElement && this.isBottom(wrappedElement)) {
const commentCount = const commentCount =
this.state.commentsRes.state == "success" this.state.commentsRes.state === "success"
? this.state.commentsRes.data.comments.length ? this.state.commentsRes.data.comments.length
: 0; : 0;
@ -323,13 +323,13 @@ export class Post extends Component<any, PostState> {
get documentTitle(): string { get documentTitle(): string {
const siteName = this.state.siteRes.site_view.site.name; 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}` ? `${this.state.postRes.data.post_view.post.name} - ${siteName}`
: siteName; : siteName;
} }
get imageTag(): string | undefined { 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 post = this.state.postRes.data.post_view.post;
const thumbnail = post.thumbnail_url; const thumbnail = post.thumbnail_url;
const url = post.url; const url = post.url;
@ -413,9 +413,9 @@ export class Post extends Component<any, PostState> {
{this.state.showSidebarMobile && this.sidebar()} {this.state.showSidebarMobile && this.sidebar()}
</div> </div>
{this.sortRadios()} {this.sortRadios()}
{this.state.commentViewType == CommentViewType.Tree && {this.state.commentViewType === CommentViewType.Tree &&
this.commentsTree()} this.commentsTree()}
{this.state.commentViewType == CommentViewType.Flat && {this.state.commentViewType === CommentViewType.Flat &&
this.commentsFlat()} this.commentsFlat()}
</main> </main>
<aside className="d-none d-md-block col-md-4 col-lg-3"> <aside className="d-none d-md-block col-md-4 col-lg-3">
@ -535,7 +535,7 @@ export class Post extends Component<any, PostState> {
const commentsRes = this.state.commentsRes; const commentsRes = this.state.commentsRes;
const postRes = this.state.postRes; const postRes = this.state.postRes;
if (commentsRes.state == "success" && postRes.state == "success") { if (commentsRes.state === "success" && postRes.state === "success") {
return ( return (
<div> <div>
<CommentNodes <CommentNodes
@ -607,7 +607,7 @@ export class Post extends Component<any, PostState> {
const showContextButton = depth ? depth > 0 : false; const showContextButton = depth ? depth > 0 : false;
return ( return (
res.state == "success" && ( res.state === "success" && (
<div> <div>
{!!this.state.commentId && ( {!!this.state.commentId && (
<> <>
@ -664,7 +664,7 @@ export class Post extends Component<any, PostState> {
} }
commentTree(): CommentNodeI[] { commentTree(): CommentNodeI[] {
if (this.state.commentsRes.state == "success") { if (this.state.commentsRes.state === "success") {
return buildCommentsTree( return buildCommentsTree(
this.state.commentsRes.data.comments, this.state.commentsRes.data.comments,
!!this.state.commentId !!this.state.commentId
@ -696,14 +696,14 @@ export class Post extends Component<any, PostState> {
} }
handleViewPost(i: Post) { 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; const id = i.state.postRes.data.post_view.post.id;
i.context.router.history.push(`/post/${id}`); i.context.router.history.push(`/post/${id}`);
} }
} }
handleViewContext(i: Post) { handleViewContext(i: Post) {
if (i.state.commentsRes.state == "success") { if (i.state.commentsRes.state === "success") {
const parentId = getCommentParentId( const parentId = getCommentParentId(
i.state.commentsRes.data.comments.at(0)?.comment i.state.commentsRes.data.comments.at(0)?.comment
); );
@ -732,7 +732,7 @@ export class Post extends Component<any, PostState> {
const communityId = followCommunityRes.data.community_view.community.id; const communityId = followCommunityRes.data.community_view.community.id;
const mui = UserService.Instance.myUserInfo; const mui = UserService.Instance.myUserInfo;
if (mui) { if (mui) {
mui.follows = mui.follows.filter(i => i.community.id != communityId); mui.follows = mui.follows.filter(i => i.community.id !== communityId);
} }
} }
} }
@ -759,10 +759,10 @@ export class Post extends Component<any, PostState> {
async handleBlockCommunity(form: BlockCommunity) { async handleBlockCommunity(form: BlockCommunity) {
const blockCommunityRes = await HttpService.client.blockCommunity(form); const blockCommunityRes = await HttpService.client.blockCommunity(form);
if (blockCommunityRes.state == "success") { if (blockCommunityRes.state === "success") {
updateCommunityBlock(blockCommunityRes.data); updateCommunityBlock(blockCommunityRes.data);
this.setState(s => { this.setState(s => {
if (s.postRes.state == "success") { if (s.postRes.state === "success") {
s.postRes.data.community_view.blocked = s.postRes.data.community_view.blocked =
blockCommunityRes.data.blocked; blockCommunityRes.data.blocked;
} }
@ -772,7 +772,7 @@ export class Post extends Component<any, PostState> {
async handleBlockPerson(form: BlockPerson) { async handleBlockPerson(form: BlockPerson) {
const blockPersonRes = await HttpService.client.blockPerson(form); const blockPersonRes = await HttpService.client.blockPerson(form);
if (blockPersonRes.state == "success") { if (blockPersonRes.state === "success") {
updatePersonBlock(blockPersonRes.data); updatePersonBlock(blockPersonRes.data);
} }
} }
@ -855,14 +855,14 @@ export class Post extends Component<any, PostState> {
async handleCommentReport(form: CreateCommentReport) { async handleCommentReport(form: CreateCommentReport) {
const reportRes = await HttpService.client.createCommentReport(form); const reportRes = await HttpService.client.createCommentReport(form);
if (reportRes.state == "success") { if (reportRes.state === "success") {
toast(I18NextService.i18n.t("report_created")); toast(I18NextService.i18n.t("report_created"));
} }
} }
async handlePostReport(form: CreatePostReport) { async handlePostReport(form: CreatePostReport) {
const reportRes = await HttpService.client.createPostReport(form); const reportRes = await HttpService.client.createPostReport(form);
if (reportRes.state == "success") { if (reportRes.state === "success") {
toast(I18NextService.i18n.t("report_created")); toast(I18NextService.i18n.t("report_created"));
} }
} }
@ -895,8 +895,8 @@ export class Post extends Component<any, PostState> {
async handleFetchChildren(form: GetComments) { async handleFetchChildren(form: GetComments) {
const moreCommentsRes = await HttpService.client.getComments(form); const moreCommentsRes = await HttpService.client.getComments(form);
if ( if (
this.state.commentsRes.state == "success" && this.state.commentsRes.state === "success" &&
moreCommentsRes.state == "success" moreCommentsRes.state === "success"
) { ) {
const newComments = moreCommentsRes.data.comments; const newComments = moreCommentsRes.data.comments;
// Remove the first comment, since it is the parent // Remove the first comment, since it is the parent
@ -929,19 +929,19 @@ export class Post extends Component<any, PostState> {
updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) { updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
// Maybe not necessary // Maybe not necessary
if (banRes.state == "success") { if (banRes.state === "success") {
this.setState(s => { this.setState(s => {
if ( if (
s.postRes.state == "success" && s.postRes.state === "success" &&
s.postRes.data.post_view.creator.id == s.postRes.data.post_view.creator.id ===
banRes.data.person_view.person.id banRes.data.person_view.person.id
) { ) {
s.postRes.data.post_view.creator_banned_from_community = s.postRes.data.post_view.creator_banned_from_community =
banRes.data.banned; banRes.data.banned;
} }
if (s.commentsRes.state == "success") { if (s.commentsRes.state === "success") {
s.commentsRes.data.comments 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( .forEach(
c => (c.creator_banned_from_community = banRes.data.banned) c => (c.creator_banned_from_community = banRes.data.banned)
); );
@ -953,18 +953,18 @@ export class Post extends Component<any, PostState> {
updateBan(banRes: RequestState<BanPersonResponse>) { updateBan(banRes: RequestState<BanPersonResponse>) {
// Maybe not necessary // Maybe not necessary
if (banRes.state == "success") { if (banRes.state === "success") {
this.setState(s => { this.setState(s => {
if ( if (
s.postRes.state == "success" && s.postRes.state === "success" &&
s.postRes.data.post_view.creator.id == s.postRes.data.post_view.creator.id ===
banRes.data.person_view.person.id banRes.data.person_view.person.id
) { ) {
s.postRes.data.post_view.creator.banned = banRes.data.banned; s.postRes.data.post_view.creator.banned = banRes.data.banned;
} }
if (s.commentsRes.state == "success") { if (s.commentsRes.state === "success") {
s.commentsRes.data.comments 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)); .forEach(c => (c.creator.banned = banRes.data.banned));
} }
return s; return s;
@ -974,7 +974,7 @@ export class Post extends Component<any, PostState> {
updateCommunity(communityRes: RequestState<CommunityResponse>) { updateCommunity(communityRes: RequestState<CommunityResponse>) {
this.setState(s => { 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; s.postRes.data.community_view = communityRes.data.community_view;
} }
return s; return s;
@ -983,7 +983,7 @@ export class Post extends Component<any, PostState> {
updateCommunityFull(res: RequestState<GetCommunityResponse>) { updateCommunityFull(res: RequestState<GetCommunityResponse>) {
this.setState(s => { 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.community_view = res.data.community_view;
s.postRes.data.moderators = res.data.moderators; s.postRes.data.moderators = res.data.moderators;
} }
@ -993,7 +993,7 @@ export class Post extends Component<any, PostState> {
updatePost(post: RequestState<PostResponse>) { updatePost(post: RequestState<PostResponse>) {
this.setState(s => { 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; s.postRes.data.post_view = post.data.post_view;
} }
return s; return s;
@ -1001,7 +1001,7 @@ export class Post extends Component<any, PostState> {
} }
purgeItem(purgeRes: RequestState<PurgeItemResponse>) { purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
if (purgeRes.state == "success") { if (purgeRes.state === "success") {
toast(I18NextService.i18n.t("purge_success")); toast(I18NextService.i18n.t("purge_success"));
this.context.router.history.push(`/`); this.context.router.history.push(`/`);
} }
@ -1024,7 +1024,7 @@ export class Post extends Component<any, PostState> {
findAndUpdateComment(res: RequestState<CommentResponse>) { findAndUpdateComment(res: RequestState<CommentResponse>) {
this.setState(s => { this.setState(s => {
if (s.commentsRes.state == "success" && res.state == "success") { if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editComment( s.commentsRes.data.comments = editComment(
res.data.comment_view, res.data.comment_view,
s.commentsRes.data.comments s.commentsRes.data.comments
@ -1037,7 +1037,7 @@ export class Post extends Component<any, PostState> {
findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) { findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
this.setState(s => { this.setState(s => {
if (s.commentsRes.state == "success" && res.state == "success") { if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editWith( s.commentsRes.data.comments = editWith(
res.data.comment_reply_view, res.data.comment_reply_view,
s.commentsRes.data.comments s.commentsRes.data.comments
@ -1050,7 +1050,7 @@ export class Post extends Component<any, PostState> {
updateModerators(res: RequestState<AddModToCommunityResponse>) { updateModerators(res: RequestState<AddModToCommunityResponse>) {
// Update the moderators // Update the moderators
this.setState(s => { 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; s.postRes.data.moderators = res.data.moderators;
} }
return s; return s;

View file

@ -94,7 +94,7 @@ export class CreatePrivateMessage extends Component<
} }
get documentTitle(): string { 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; const name_ = this.state.recipientRes.data.person_view.person.name;
return `${I18NextService.i18n.t("create_private_message")} - ${name_}`; return `${I18NextService.i18n.t("create_private_message")} - ${name_}`;
} else { } else {
@ -144,7 +144,7 @@ export class CreatePrivateMessage extends Component<
async handlePrivateMessageCreate(form: CreatePrivateMessageI) { async handlePrivateMessageCreate(form: CreatePrivateMessageI) {
const res = await HttpService.client.createPrivateMessage(form); const res = await HttpService.client.createPrivateMessage(form);
if (res.state == "success") { if (res.state === "success") {
toast(I18NextService.i18n.t("message_sent")); toast(I18NextService.i18n.t("message_sent"));
// Navigate to the front // Navigate to the front

View file

@ -58,7 +58,7 @@ export class PrivateMessageForm extends Component<
componentWillReceiveProps( componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & PrivateMessageFormProps> nextProps: Readonly<{ children?: InfernoNode } & PrivateMessageFormProps>
): void { ): void {
if (this.props != nextProps) { if (this.props !== nextProps) {
this.setState({ loading: false, content: undefined, previewMode: false }); this.setState({ loading: false, content: undefined, previewMode: false });
} }
} }

View file

@ -31,7 +31,7 @@ export class PrivateMessageReport extends Component<Props, State> {
componentWillReceiveProps( componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & Props> nextProps: Readonly<{ children?: InfernoNode } & Props>
): void { ): void {
if (this.props != nextProps) { if (this.props !== nextProps) {
this.setState({ loading: false }); this.setState({ loading: false });
} }
} }

View file

@ -59,7 +59,7 @@ export class PrivateMessage extends Component<
get mine(): boolean { get mine(): boolean {
return ( return (
UserService.Instance.myUserInfo?.local_user_view.person.id == UserService.Instance.myUserInfo?.local_user_view.person.id ===
this.props.private_message_view.creator.id this.props.private_message_view.creator.id
); );
} }
@ -67,7 +67,7 @@ export class PrivateMessage extends Component<
componentWillReceiveProps( componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & PrivateMessageProps> nextProps: Readonly<{ children?: InfernoNode } & PrivateMessageProps>
): void { ): void {
if (this.props != nextProps) { if (this.props !== nextProps) {
this.setState({ this.setState({
showReply: false, showReply: false,
showEdit: false, showEdit: false,

View file

@ -545,7 +545,7 @@ export class Search extends Component<any, SearchState> {
} = this.state; } = this.state;
const hasCommunities = const hasCommunities =
communitiesRes.state == "success" && communitiesRes.state === "success" &&
communitiesRes.data.communities.length > 0; communitiesRes.data.communities.length > 0;
return ( return (
@ -619,7 +619,7 @@ export class Search extends Component<any, SearchState> {
} = this.state; } = this.state;
// Push the possible resolve / federated objects first // Push the possible resolve / federated objects first
if (resolveObjectResponse.state == "success") { if (resolveObjectResponse.state === "success") {
const { comment, post, community, person } = resolveObjectResponse.data; const { comment, post, community, person } = resolveObjectResponse.data;
if (comment) { if (comment) {

View file

@ -197,7 +197,7 @@ export function setupMarkdown() {
const item = tokens[idx] as any; const item = tokens[idx] as any;
const title = item.attrs.length >= 3 ? item.attrs[2][1] : ""; const title = item.attrs.length >= 3 ? item.attrs[2][1] : "";
const customEmoji = customEmojisLookup.get(title); const customEmoji = customEmojisLookup.get(title);
const isCustomEmoji = customEmoji != undefined; const isCustomEmoji = customEmoji !== undefined;
if (!isCustomEmoji) { if (!isCustomEmoji) {
return defaultRenderer?.(tokens, idx, options, env, self) ?? ""; return defaultRenderer?.(tokens, idx, options, env, self) ?? "";
} }
@ -242,9 +242,9 @@ export function updateEmojiDataModel(custom_emoji_view: CustomEmojiView) {
skins: [{ src: custom_emoji_view.custom_emoji.image_url }], skins: [{ src: custom_emoji_view.custom_emoji.image_url }],
}; };
const categoryIndex = customEmojis.findIndex( 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({ customEmojis.push({
id: custom_emoji_view.custom_emoji.category, id: custom_emoji_view.custom_emoji.category,
name: custom_emoji_view.custom_emoji.category, name: custom_emoji_view.custom_emoji.category,
@ -252,9 +252,9 @@ export function updateEmojiDataModel(custom_emoji_view: CustomEmojiView) {
}); });
} else { } else {
const emojiIndex = customEmojis[categoryIndex].emojis.findIndex( 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); customEmojis[categoryIndex].emojis.push(emoji);
} else { } else {
customEmojis[categoryIndex].emojis[emojiIndex] = emoji; customEmojis[categoryIndex].emojis[emojiIndex] = emoji;
@ -276,10 +276,10 @@ export function removeFromEmojiDataModel(id: number) {
} }
if (!view) return; if (!view) return;
const categoryIndex = customEmojis.findIndex( const categoryIndex = customEmojis.findIndex(
x => x.id == view?.custom_emoji.category x => x.id === view?.custom_emoji.category
); );
const emojiIndex = customEmojis[categoryIndex].emojis.findIndex( const emojiIndex = customEmojis[categoryIndex].emojis.findIndex(
x => x.id == view?.custom_emoji.shortcode x => x.id === view?.custom_emoji.shortcode
); );
customEmojis[categoryIndex].emojis = customEmojis[ customEmojis[categoryIndex].emojis = customEmojis[
categoryIndex categoryIndex
@ -317,7 +317,7 @@ export function setupTribute() {
const customEmoji = customEmojisLookup.get( const customEmoji = customEmojisLookup.get(
item.original.key item.original.key
)?.custom_emoji; )?.custom_emoji;
if (customEmoji == undefined) return `${item.original.val}`; if (customEmoji === undefined) return `${item.original.val}`;
else else
return `![${customEmoji.alt_text}](${customEmoji.image_url} "${customEmoji.shortcode}")`; return `![${customEmoji.alt_text}](${customEmoji.image_url} "${customEmoji.shortcode}")`;
}, },

View file

@ -1,9 +1,9 @@
import { VoteType } from "../../interfaces"; import { VoteType } from "../../interfaces";
export default function newVote(voteType: VoteType, myVote?: number): number { export default function newVote(voteType: VoteType, myVote?: number): number {
if (voteType == VoteType.Upvote) { if (voteType === VoteType.Upvote) {
return myVote == 1 ? 0 : 1; return myVote === 1 ? 0 : 1;
} else { } else {
return myVote == -1 ? 0 : -1; return myVote === -1 ? 0 : -1;
} }
} }

View file

@ -17,8 +17,8 @@ export default function selectableLanguages(
): Language[] { ): Language[] {
const allLangIds = allLanguages.map(l => l.id); const allLangIds = allLanguages.map(l => l.id);
let myLangs = myUserInfo?.discussion_languages ?? allLangIds; let myLangs = myUserInfo?.discussion_languages ?? allLangIds;
myLangs = myLangs.length == 0 ? allLangIds : myLangs; myLangs = myLangs.length === 0 ? allLangIds : myLangs;
const siteLangs = siteLanguages.length == 0 ? allLangIds : siteLanguages; const siteLangs = siteLanguages.length === 0 ? allLangIds : siteLanguages;
if (showAll) { if (showAll) {
return allLanguages; return allLanguages;

View file

@ -9,7 +9,7 @@ export default async function setTheme(theme: string, forceReload = false) {
return; return;
} }
// This is only run on a force reload // This is only run on a force reload
if (theme == "browser") { if (theme === "browser") {
theme = "darkly"; theme = "darkly";
} }

View file

@ -6,7 +6,7 @@ export default function getExternalHost() {
? `${window.location.hostname}${ ? `${window.location.hostname}${
["1234", "1235"].includes(window.location.port) ["1234", "1235"].includes(window.location.port)
? ":8536" ? ":8536"
: window.location.port == "" : window.location.port === ""
? "" ? ""
: `:${window.location.port}` : `:${window.location.port}`
}` }`

View file

@ -1,5 +1,5 @@
export default function getRandomFromList<T>(list: T[]): T | undefined { export default function getRandomFromList<T>(list: T[]): T | undefined {
return list.length == 0 return list.length === 0
? undefined ? undefined
: list.at(Math.floor(Math.random() * list.length)); : list.at(Math.floor(Math.random() * list.length));
} }

View file

@ -8,5 +8,5 @@ export default function amCommunityCreator(
): boolean { ): boolean {
const myId = myUserInfo?.local_user_view.person.id; const myId = myUserInfo?.local_user_view.person.id;
// Don't allow mod actions on yourself // 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;
} }

View file

@ -7,5 +7,5 @@ export default function amSiteCreator(
myUserInfo = UserService.Instance.myUserInfo myUserInfo = UserService.Instance.myUserInfo
): boolean { ): boolean {
const myId = myUserInfo?.local_user_view.person.id; 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;
} }

View file

@ -5,5 +5,5 @@ export default function amTopMod(
mods: CommunityModeratorView[], mods: CommunityModeratorView[],
myUserInfo = UserService.Instance.myUserInfo myUserInfo = UserService.Instance.myUserInfo
): boolean { ): 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;
} }

View file

@ -16,9 +16,9 @@ export default function canMod(
if (myUserInfo) { if (myUserInfo) {
const myIndex = adminsThenMods.findIndex( 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; return false;
} else { } else {
// onSelf +1 on mod actions not for yourself, IE ban, remove, etc // onSelf +1 on mod actions not for yourself, IE ban, remove, etc