Upgrading deps, running prettier. (#1987)

This commit is contained in:
Dessalines 2023-08-07 13:10:14 -04:00
parent 0308fab8c6
commit 9679dd9bc6
108 changed files with 893 additions and 856 deletions

View file

@ -35,16 +35,16 @@
},
"dependencies": {
"@babel/plugin-proposal-decorators": "^7.21.0",
"@babel/plugin-transform-runtime": "^7.21.4",
"@babel/plugin-transform-typescript": "^7.21.3",
"@babel/preset-env": "7.21.5",
"@babel/plugin-transform-runtime": "^7.22.9",
"@babel/plugin-transform-typescript": "^7.22.9",
"@babel/preset-env": "7.22.9",
"@babel/preset-typescript": "^7.21.5",
"@babel/runtime": "^7.21.5",
"@emoji-mart/data": "^1.1.0",
"autosize": "^6.0.1",
"babel-loader": "^9.1.2",
"babel-plugin-inferno": "^6.6.0",
"bootstrap": "^5.2.3",
"bootstrap": "^5.3.1",
"check-password-strength": "^2.0.7",
"classnames": "^2.3.1",
"clean-webpack-plugin": "^4.0.0",
@ -58,7 +58,7 @@
"express": "~4.18.2",
"history": "^5.3.0",
"html-to-text": "^9.0.5",
"i18next": "^23.2.8",
"i18next": "^23.3.0",
"inferno": "^8.2.2",
"inferno-create-element": "^8.2.2",
"inferno-helmet": "^5.2.1",
@ -81,20 +81,21 @@
"register-service-worker": "^1.7.2",
"run-node-webpack-plugin": "^1.3.0",
"sanitize-html": "^2.11.0",
"sass": "^1.63.6",
"sass": "^1.64.1",
"sass-loader": "^13.3.2",
"serialize-javascript": "^6.0.1",
"service-worker-webpack": "^1.0.0",
"sharp": "^0.32.1",
"sharp": "^0.32.4",
"tippy.js": "^6.3.7",
"toastify-js": "^1.12.0",
"tributejs": "^5.1.3",
"webpack": "5.88.1",
"webpack": "5.88.2",
"webpack-cli": "^5.1.4",
"webpack-node-externals": "^3.0.0"
},
"devDependencies": {
"@babel/core": "^7.21.8",
"@babel/core": "^7.22.9",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@types/autosize": "^4.0.0",
"@types/bootstrap": "^5.2.6",
"@types/cookie": "^0.5.1",
@ -102,29 +103,29 @@
"@types/html-to-text": "^9.0.0",
"@types/lodash.isequal": "^4.5.6",
"@types/markdown-it": "^12.2.3",
"@types/markdown-it-container": "^2.0.5",
"@types/node": "^20.4.0",
"@types/markdown-it-container": "^2.0.6",
"@types/node": "^20.4.5",
"@types/path-browserify": "^1.0.0",
"@types/sanitize-html": "^2.9.0",
"@types/serialize-javascript": "^5.0.1",
"@types/toastify-js": "^1.11.1",
"@typescript-eslint/eslint-plugin": "^5.61.0",
"@typescript-eslint/parser": "^5.61.0",
"eslint": "^8.44.0",
"@types/toastify-js": "^1.12.0",
"@typescript-eslint/eslint-plugin": "^6.2.0",
"@typescript-eslint/parser": "^6.2.0",
"eslint": "^8.45.0",
"eslint-plugin-inferno": "^7.32.2",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-prettier": "^5.0.0",
"husky": "^8.0.3",
"import-sort-style-module": "^6.0.0",
"lint-staged": "^13.2.3",
"prettier": "^2.8.8",
"prettier": "^3.0.0",
"prettier-plugin-import-sort": "^0.0.7",
"prettier-plugin-organize-imports": "^3.2.2",
"prettier-plugin-packagejson": "^2.4.4",
"prettier-plugin-organize-imports": "^3.2.3",
"prettier-plugin-packagejson": "^2.4.5",
"rimraf": "^5.0.0",
"sortpack": "^2.3.4",
"style-loader": "^3.3.2",
"terser": "^5.18.2",
"terser": "^5.19.2",
"typescript": "^5.1.6",
"typescript-language-server": "^3.3.2",
"webpack-bundle-analyzer": "^4.9.0",

View file

@ -30,9 +30,18 @@ $mark-bg: $gray-900;
$text-muted: $gray-600;
$yiq-contrasted-threshold: 175;
$font-family-sans-serif: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI",
Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji",
"Segoe UI Emoji", "Segoe UI Symbol";
$font-family-sans-serif:
"Lato",
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
"Helvetica Neue",
Arial,
sans-serif,
"Apple Color Emoji",
"Segoe UI Emoji",
"Segoe UI Symbol";
$font-size-base: 0.9375rem;
$h1-font-size: 3rem;
$h2-font-size: 2.5rem;

View file

@ -29,9 +29,18 @@ $mark-bg: #333;
$text-muted: $gray-600;
$yiq-contrasted-threshold: 175;
$font-family-sans-serif: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI",
Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji",
"Segoe UI Emoji", "Segoe UI Symbol";
$font-family-sans-serif:
"Lato",
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
"Helvetica Neue",
Arial,
sans-serif,
"Apple Color Emoji",
"Segoe UI Emoji",
"Segoe UI Symbol";
$h1-font-size: 3rem;
$h2-font-size: 2.5rem;
$h3-font-size: 2rem;

View file

@ -23,8 +23,11 @@ option:disabled {
}
.form-control::placeholder {
text-shadow: 0.5px 0.5px 0 $secondary, 0.5px -0.5px 0 $secondary,
-0.5px 0.5px 0 $secondary, -0.5px -0.5px 0 $secondary;
text-shadow:
0.5px 0.5px 0 $secondary,
0.5px -0.5px 0 $secondary,
-0.5px 0.5px 0 $secondary,
-0.5px -0.5px 0 $secondary;
}
.input-group-text {

View file

@ -35,7 +35,7 @@ export default async (req: Request, res: Response) => {
const headers = setForwardedHeaders(req.headers);
const client = wrapClient(
new LemmyHttp(getHttpBaseInternal(), { fetchFunction: fetch, headers })
new LemmyHttp(getHttpBaseInternal(), { fetchFunction: fetch, headers }),
);
const { path, url, query } = req;
@ -50,7 +50,7 @@ export default async (req: Request, res: Response) => {
if (try_site.state === "failed" && try_site.msg == "not_logged_in") {
console.error(
"Incorrect JWT token, skipping auth so frontend can remove jwt cookie"
"Incorrect JWT token, skipping auth so frontend can remove jwt cookie",
);
getSiteForm.auth = undefined;
auth = undefined;
@ -90,7 +90,7 @@ export default async (req: Request, res: Response) => {
}
const error = Object.values(routeData).find(
res => res.state === "failed" && res.msg !== "couldnt_find_object" // TODO: find a better way of handling errors
res => res.state === "failed" && res.msg !== "couldnt_find_object", // TODO: find a better way of handling errors
) as FailedRequestState | undefined;
// Redirect to the 404 if there's an API error
@ -127,7 +127,7 @@ export default async (req: Request, res: Response) => {
res.statusCode = 500;
return res.send(
process.env.NODE_ENV === "development" ? err.message : "Server error"
process.env.NODE_ENV === "development" ? err.message : "Server error",
);
}
};

View file

@ -13,7 +13,7 @@ export default async (req: Request, res: Response) => {
if (!manifest || manifest.start_url !== getHttpBaseExternal()) {
const headers = setForwardedHeaders(req.headers);
const client = wrapClient(
new LemmyHttp(getHttpBaseInternal(), { fetchFunction: fetch, headers })
new LemmyHttp(getHttpBaseInternal(), { fetchFunction: fetch, headers }),
);
const site = await client.getSite({});

View file

@ -12,6 +12,6 @@ export default async ({ res }: { res: Response }) => {
process.env.LEMMY_UI_LEMMY_EXTERNAL_HOST +
`
Expires: 2024-01-01T04:59:00.000Z
`
`,
);
};

View file

@ -8,7 +8,7 @@ export default async ({ res }: { res: Response }) => {
path.resolve(
`./dist/service-worker${
process.env.NODE_ENV === "development" ? "-development" : ""
}.js`
)
}.js`,
),
);
};

View file

@ -25,7 +25,7 @@ server.use(
express.static(path.resolve("./dist"), {
maxAge: 24 * 60 * 60 * 1000, // 1 day
immutable: true,
})
}),
);
server.use(setCacheControl);

View file

@ -22,7 +22,7 @@ export function setDefaultCsp({
form-action 'self';
base-uri 'self';
frame-src *;
media-src * data:`.replace(/\s+/g, " ")
media-src * data:`.replace(/\s+/g, " "),
);
next();
@ -37,7 +37,7 @@ export function setDefaultCsp({
export function setCacheControl(
req: Request,
res: Response,
next: NextFunction
next: NextFunction,
) {
if (process.env.NODE_ENV !== "production") {
return next();

View file

@ -15,7 +15,7 @@ let appleTouchIcon: string | undefined = undefined;
export async function createSsrHtml(
root: string,
isoData: IsoDataOptionalSite,
cspNonce: string
cspNonce: string,
) {
const site = isoData.site_res;
@ -26,13 +26,13 @@ export async function createSsrHtml(
const customHtmlHeaderScriptTag = new RegExp("<script", "g");
const customHtmlHeaderWithNonce = customHtmlHeader.replace(
customHtmlHeaderScriptTag,
`<script nonce="${cspNonce}"`
`<script nonce="${cspNonce}"`,
);
if (!appleTouchIcon) {
appleTouchIcon = site?.site_view.site.icon
? `data:image/png;base64,${await sharp(
await fetchIconPng(site.site_view.site.icon)
await fetchIconPng(site.site_view.site.icon),
)
.resize(180, 180)
.extend({
@ -57,7 +57,7 @@ export async function createSsrHtml(
src="//cdn.jsdelivr.net/npm/eruda"
></script>
<script nonce={cspNonce}>eruda.init();</script>
</>
</>,
)
: "";

View file

@ -10,7 +10,7 @@ const defaultLogoPathDirectory = path.join(
process.cwd(),
"dist",
"assets",
"icons"
"icons",
);
export default async function ({
@ -34,7 +34,7 @@ export default async function ({
icons: await Promise.all(
iconSizes.map(async size => {
let src = await readFile(
path.join(defaultLogoPathDirectory, `icon-${size}x${size}.png`)
path.join(defaultLogoPathDirectory, `icon-${size}x${size}.png`),
).then(buf => buf.toString("base64"));
if (icon) {
@ -51,7 +51,7 @@ export default async function ({
src: `data:image/png;base64,${src}`,
purpose: "any maskable",
};
})
}),
),
shortcuts: [
{
@ -82,7 +82,7 @@ export default async function ({
description: "Create a community",
},
]
: []
: [],
),
related_applications: [
{

View file

@ -86,7 +86,7 @@ export class App extends Component<AppProps, any> {
);
}}
/>
)
),
)}
<Route component={ErrorPage} />
</Switch>

View file

@ -146,7 +146,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
{
count: Number(this.unreadApplicationCount),
formattedCount: numToSI(this.unreadApplicationCount),
}
},
)}
onMouseUp={linkEvent(this, handleCollapseClick)}
>
@ -323,9 +323,9 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
{
count: Number(this.unreadApplicationCount),
formattedCount: numToSI(
this.unreadApplicationCount
this.unreadApplicationCount,
),
}
},
)}
onMouseUp={linkEvent(this, handleCollapseClick)}
>
@ -336,9 +336,9 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
{
count: Number(this.unreadApplicationCount),
formattedCount: numToSI(
this.unreadApplicationCount
this.unreadApplicationCount,
),
}
},
)}
</span>
{this.unreadApplicationCount > 0 && (

View file

@ -43,7 +43,7 @@ export class CommentForm extends Component<CommentFormProps, any> {
return (
<div
className={["comment-form", "mb-3", this.props.containerClass].join(
" "
" ",
)}
>
{UserService.Instance.myUserInfo ? (

View file

@ -198,7 +198,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
}
componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & CommentNodeProps>
nextProps: Readonly<{ children?: InfernoNode } & CommentNodeProps>,
): void {
if (!deepEqual(this.props, nextProps)) {
this.setState({
@ -250,27 +250,27 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
const canMod_ = canMod(
cv.creator.id,
this.props.moderators,
this.props.admins
this.props.admins,
);
const canModOnSelf = canMod(
cv.creator.id,
this.props.moderators,
this.props.admins,
UserService.Instance.myUserInfo,
true
true,
);
const canAdmin_ = canAdmin(cv.creator.id, this.props.admins);
const canAdminOnSelf = canAdmin(
cv.creator.id,
this.props.admins,
UserService.Instance.myUserInfo,
true
true,
);
const isMod_ = isMod(cv.creator.id, this.props.moderators);
const isAdmin_ = isAdmin(cv.creator.id, this.props.admins);
const amCommunityCreator_ = amCommunityCreator(
cv.creator.id,
this.props.moderators
this.props.moderators,
);
const moreRepliesBorderColor = this.props.node.depth
@ -337,7 +337,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
<span className="badge text-bg-light d-none d-sm-inline me-2">
{
this.props.allLanguages.find(
lang => lang.id === cv.comment.language_id
lang => lang.id === cv.comment.language_id,
)?.name
}
</span>
@ -374,7 +374,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
onReplyCancel={this.handleReplyCancel}
disabled={this.props.locked}
finished={this.props.finished.get(
this.props.node.comment_view.comment.id
this.props.node.comment_view.comment.id,
)}
focus
allLanguages={this.props.allLanguages}
@ -472,13 +472,13 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleShowReportDialog
this.handleShowReportDialog,
)}
data-tippy-content={I18NextService.i18n.t(
"show_report_dialog"
"show_report_dialog",
)}
aria-label={I18NextService.i18n.t(
"show_report_dialog"
"show_report_dialog",
)}
>
<Icon icon="flag" />
@ -487,10 +487,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleBlockPerson
this.handleBlockPerson,
)}
data-tippy-content={I18NextService.i18n.t(
"block_user"
"block_user",
)}
aria-label={I18NextService.i18n.t("block_user")}
>
@ -531,7 +531,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(this, this.handleViewSource)}
data-tippy-content={I18NextService.i18n.t(
"view_source"
"view_source",
)}
aria-label={I18NextService.i18n.t("view_source")}
>
@ -548,7 +548,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(this, this.handleEditClick)}
data-tippy-content={I18NextService.i18n.t(
"edit"
"edit",
)}
aria-label={I18NextService.i18n.t("edit")}
>
@ -558,7 +558,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleDeleteComment
this.handleDeleteComment,
)}
data-tippy-content={
!cv.comment.deleted
@ -588,7 +588,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleDistinguishComment
this.handleDistinguishComment,
)}
data-tippy-content={
!cv.comment.distinguished
@ -619,7 +619,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleModRemoveShow
this.handleModRemoveShow,
)}
aria-label={I18NextService.i18n.t("remove")}
>
@ -630,7 +630,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleRemoveComment
this.handleRemoveComment,
)}
aria-label={I18NextService.i18n.t("restore")}
>
@ -652,14 +652,14 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleModBanFromCommunityShow
this.handleModBanFromCommunityShow,
)}
aria-label={I18NextService.i18n.t(
"ban_from_community"
"ban_from_community",
)}
>
{I18NextService.i18n.t(
"ban_from_community"
"ban_from_community",
)}
</button>
) : (
@ -667,7 +667,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleBanPersonFromCommunity
this.handleBanPersonFromCommunity,
)}
aria-label={I18NextService.i18n.t("unban")}
>
@ -684,13 +684,13 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleShowConfirmAppointAsMod
this.handleShowConfirmAppointAsMod,
)}
aria-label={
isMod_
? I18NextService.i18n.t("remove_as_mod")
: I18NextService.i18n.t(
"appoint_as_mod"
"appoint_as_mod",
)
}
>
@ -703,7 +703,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
<button
className="btn btn-link btn-animate text-muted"
aria-label={I18NextService.i18n.t(
"are_you_sure"
"are_you_sure",
)}
>
{I18NextService.i18n.t("are_you_sure")}
@ -712,7 +712,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleAddModToCommunity
this.handleAddModToCommunity,
)}
aria-label={I18NextService.i18n.t("yes")}
>
@ -726,7 +726,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleCancelConfirmAppointAsMod
this.handleCancelConfirmAppointAsMod,
)}
aria-label={I18NextService.i18n.t("no")}
>
@ -745,10 +745,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleShowConfirmTransferCommunity
this.handleShowConfirmTransferCommunity,
)}
aria-label={I18NextService.i18n.t(
"transfer_community"
"transfer_community",
)}
>
{I18NextService.i18n.t("transfer_community")}
@ -758,7 +758,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
<button
className="btn btn-link btn-animate text-muted"
aria-label={I18NextService.i18n.t(
"are_you_sure"
"are_you_sure",
)}
>
{I18NextService.i18n.t("are_you_sure")}
@ -767,7 +767,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleTransferCommunity
this.handleTransferCommunity,
)}
aria-label={I18NextService.i18n.t("yes")}
>
@ -782,7 +782,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
onClick={linkEvent(
this,
this
.handleCancelShowConfirmTransferCommunity
.handleCancelShowConfirmTransferCommunity,
)}
aria-label={I18NextService.i18n.t("no")}
>
@ -799,10 +799,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handlePurgePersonShow
this.handlePurgePersonShow,
)}
aria-label={I18NextService.i18n.t(
"purge_user"
"purge_user",
)}
>
{I18NextService.i18n.t("purge_user")}
@ -811,10 +811,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handlePurgeCommentShow
this.handlePurgeCommentShow,
)}
aria-label={I18NextService.i18n.t(
"purge_comment"
"purge_comment",
)}
>
{I18NextService.i18n.t("purge_comment")}
@ -825,10 +825,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleModBanShow
this.handleModBanShow,
)}
aria-label={I18NextService.i18n.t(
"ban_from_site"
"ban_from_site",
)}
>
{I18NextService.i18n.t("ban_from_site")}
@ -838,10 +838,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleBanPerson
this.handleBanPerson,
)}
aria-label={I18NextService.i18n.t(
"unban_from_site"
"unban_from_site",
)}
>
{this.state.banLoading ? (
@ -860,22 +860,22 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleShowConfirmAppointAsAdmin
this.handleShowConfirmAppointAsAdmin,
)}
aria-label={
isAdmin_
? I18NextService.i18n.t(
"remove_as_admin"
"remove_as_admin",
)
: I18NextService.i18n.t(
"appoint_as_admin"
"appoint_as_admin",
)
}
>
{isAdmin_
? I18NextService.i18n.t("remove_as_admin")
: I18NextService.i18n.t(
"appoint_as_admin"
"appoint_as_admin",
)}
</button>
) : (
@ -887,7 +887,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleAddAdmin
this.handleAddAdmin,
)}
aria-label={I18NextService.i18n.t("yes")}
>
@ -901,7 +901,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
this,
this.handleCancelConfirmAppointAsAdmin
this.handleCancelConfirmAppointAsAdmin,
)}
aria-label={I18NextService.i18n.t("no")}
>
@ -939,7 +939,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
{I18NextService.i18n.t("x_more_replies", {
count: node.comment_view.counts.child_count,
formattedCount: numToSI(
node.comment_view.counts.child_count
node.comment_view.counts.child_count,
),
})}{" "}
@ -1114,7 +1114,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
onReplyCancel={this.handleReplyCancel}
disabled={this.props.locked}
finished={this.props.finished.get(
this.props.node.comment_view.comment.id
this.props.node.comment_view.comment.id,
)}
focus
allLanguages={this.props.allLanguages}
@ -1299,13 +1299,13 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
}
isPersonMentionType(
item: CommentView | PersonMentionView | CommentReplyView
item: CommentView | PersonMentionView | CommentReplyView,
): item is PersonMentionView {
return (item as PersonMentionView).person_mention?.id !== undefined;
}
isCommentReplyType(
item: CommentView | PersonMentionView | CommentReplyView
item: CommentView | PersonMentionView | CommentReplyView,
): item is CommentReplyView {
return (item as CommentReplyView).comment_reply?.id !== undefined;
}

View file

@ -33,7 +33,7 @@ export class CommentReport extends Component<
}
componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & CommentReportProps>
nextProps: Readonly<{ children?: InfernoNode } & CommentReportProps>,
): void {
if (this.props != nextProps) {
this.setState({ loading: false });
@ -44,7 +44,7 @@ export class CommentReport extends Component<
const r = this.props.report;
const comment = r.comment;
const tippyContent = I18NextService.i18n.t(
r.comment_report.resolved ? "unresolve_report" : "resolve_report"
r.comment_report.resolved ? "unresolve_report" : "resolve_report",
);
// Set the original post data ( a troll could change it )

View file

@ -13,13 +13,13 @@ interface BadgesProps {
}
const isCommunityAggregates = (
counts: CommunityAggregates | SiteAggregates
counts: CommunityAggregates | SiteAggregates,
): counts is CommunityAggregates => {
return "subscribers" in counts;
};
const isSiteAggregates = (
counts: CommunityAggregates | SiteAggregates
counts: CommunityAggregates | SiteAggregates,
): counts is SiteAggregates => {
return "communities" in counts;
};
@ -34,7 +34,7 @@ export const Badges = ({ counts, communityId }: BadgesProps) => {
{
count: Number(counts.users_active_day),
formattedCount: numToSI(counts.users_active_day),
}
},
)}
>
{I18NextService.i18n.t("number_of_users", {
@ -50,7 +50,7 @@ export const Badges = ({ counts, communityId }: BadgesProps) => {
{
count: Number(counts.users_active_week),
formattedCount: numToSI(counts.users_active_week),
}
},
)}
>
{I18NextService.i18n.t("number_of_users", {
@ -66,7 +66,7 @@ export const Badges = ({ counts, communityId }: BadgesProps) => {
{
count: Number(counts.users_active_month),
formattedCount: numToSI(counts.users_active_month),
}
},
)}
>
{I18NextService.i18n.t("number_of_users", {
@ -82,7 +82,7 @@ export const Badges = ({ counts, communityId }: BadgesProps) => {
{
count: Number(counts.users_active_half_year),
formattedCount: numToSI(counts.users_active_half_year),
}
},
)}
>
{I18NextService.i18n.t("number_of_users", {

View file

@ -15,7 +15,7 @@ export class EmojiMart extends Component<EmojiMartProps> {
const div: any = document.getElementById("emoji-picker");
if (div) {
div.appendChild(
getEmojiMart(this.handleEmojiClick, this.props.pickerOptions)
getEmojiMart(this.handleEmojiClick, this.props.pickerOptions),
);
}
}

View file

@ -50,10 +50,10 @@ export class HtmlTags extends Component<HtmlTagsProps, any> {
name={n}
content={htmlToText(md.renderInline(desc))}
/>
)
),
)}
{["og:image", "twitter:image"].map(
p => image && <meta key={p} property={p} content={image} />
p => image && <meta key={p} property={p} content={image} />,
)}
</Helmet>
);

View file

@ -53,12 +53,12 @@ export class LanguageSelect extends Component<LanguageSelectProps, any> {
<label
className={classNames(
"col-form-label",
`col-sm-${this.props.multiple ? 3 : 2}`
`col-sm-${this.props.multiple ? 3 : 2}`,
)}
htmlFor={this.id}
>
{I18NextService.i18n.t(
this.props.multiple ? "language_plural" : "language"
this.props.multiple ? "language_plural" : "language",
)}
</label>
{this.props.multiple && this.props.showLanguageWarning && (
@ -97,7 +97,7 @@ export class LanguageSelect extends Component<LanguageSelectProps, any> {
this.props.siteLanguages,
this.props.showAll,
this.props.showSite,
UserService.Instance.myUserInfo
UserService.Instance.myUserInfo,
);
return (

View file

@ -30,7 +30,7 @@ export class ListingTypeSelect extends Component<
}
static getDerivedStateFromProps(
props: ListingTypeSelectProps
props: ListingTypeSelectProps,
): ListingTypeSelectState {
return {
type_: props.type_,

View file

@ -201,7 +201,7 @@ export class MarkdownTextArea extends Component<
{this.getFormatButton("header", this.handleInsertHeader)}
{this.getFormatButton(
"strikethrough",
this.handleInsertStrikethrough
this.handleInsertStrikethrough,
)}
{this.getFormatButton("quote", this.handleInsertQuote)}
{this.getFormatButton("list", this.handleInsertList)}
@ -209,7 +209,7 @@ export class MarkdownTextArea extends Component<
{this.getFormatButton("subscript", this.handleInsertSubscript)}
{this.getFormatButton(
"superscript",
this.handleInsertSuperscript
this.handleInsertSuperscript,
)}
{this.getFormatButton("spoiler", this.handleInsertSpoiler)}
<a
@ -229,7 +229,7 @@ export class MarkdownTextArea extends Component<
"form-control border-0 rounded-top-0 rounded-bottom",
{
"d-none": this.state.previewMode,
}
},
)}
value={this.state.content}
onInput={linkEvent(this, this.handleContentChange)}
@ -328,7 +328,7 @@ export class MarkdownTextArea extends Component<
getFormatButton(
type: NoOptionI18nKeys,
handleClick: (i: MarkdownTextArea, event: any) => void
handleClick: (i: MarkdownTextArea, event: any) => void,
) {
let iconType: string;
@ -396,7 +396,7 @@ export class MarkdownTextArea extends Component<
count: Number(maxUploadImages),
formattedCount: numToSI(maxUploadImages),
}),
"danger"
"danger",
);
} else {
i.setState({
@ -424,7 +424,7 @@ export class MarkdownTextArea extends Component<
uploaded: (imageUploadStatus?.uploaded ?? 0) + 1,
},
}));
})
}),
);
} catch (e) {
errorOccurred = true;
@ -560,7 +560,7 @@ export class MarkdownTextArea extends Component<
i.setState({
content: `${content?.substring(
0,
start
start,
)}[${selectedText}]()${content?.substring(end)}`,
});
textarea.focus();
@ -584,7 +584,7 @@ export class MarkdownTextArea extends Component<
simpleSurroundBeforeAfter(
beforeChars: string,
afterChars: string,
emptyChars = "___"
emptyChars = "___",
) {
const content = this.state.content ?? "";
if (!this.state.content) {
@ -599,7 +599,7 @@ export class MarkdownTextArea extends Component<
this.setState({
content: `${content?.substring(
0,
start
start,
)}${beforeChars}${selectedText}${afterChars}${content?.substring(end)}`,
});
} else {
@ -614,12 +614,12 @@ export class MarkdownTextArea extends Component<
if (start !== end) {
textarea.setSelectionRange(
start + beforeChars.length,
end + afterChars.length
end + afterChars.length,
);
} else {
textarea.setSelectionRange(
start + beforeChars.length,
end + emptyChars.length + afterChars.length
end + emptyChars.length + afterChars.length,
);
}

View file

@ -25,11 +25,11 @@ export class MomentTime extends Component<MomentTimeProps, any> {
createdAndModifiedTimes() {
const updated = this.props.updated;
let line = `${capitalizeFirstLetter(
I18NextService.i18n.t("created")
I18NextService.i18n.t("created"),
)}: ${formatDate(this.props.published)}`;
if (updated) {
line += `\n\n\n${capitalizeFirstLetter(
I18NextService.i18n.t("modified")
I18NextService.i18n.t("modified"),
)} ${formatDate(updated)}`;
}
return line;

View file

@ -104,10 +104,10 @@ class PasswordInput extends Component<PasswordInputProps, PasswordInputState> {
id={id}
onClick={linkEvent(this, handleToggleShow)}
aria-label={I18NextService.i18n.t(
`${show ? "show" : "hide"}_password`
`${show ? "show" : "hide"}_password`,
)}
data-tippy-content={I18NextService.i18n.t(
`${show ? "show" : "hide"}_password`
`${show ? "show" : "hide"}_password`,
)}
>
<Icon icon={`eye${show ? "-slash" : ""}`} inline />
@ -116,7 +116,7 @@ class PasswordInput extends Component<PasswordInputProps, PasswordInputState> {
{showStrength && value && (
<div className={this.passwordColorClass}>
{I18NextService.i18n.t(
this.passwordStrength as NoOptionI18nKeys
this.passwordStrength as NoOptionI18nKeys,
)}
</div>
)}

View file

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

View file

@ -83,7 +83,7 @@ export class SearchableSelect extends Component<
if (props.value) {
let selectedIndex = props.options.findIndex(
({ value }) => value === props.value?.toString()
({ value }) => value === props.value?.toString(),
);
if (selectedIndex < 0) {
@ -140,7 +140,7 @@ export class SearchableSelect extends Component<
(onSearch || searchText.length === 0
? options
: options.filter(({ label }) =>
label.toLowerCase().includes(searchText.toLowerCase())
label.toLowerCase().includes(searchText.toLowerCase()),
)
).map((option, index) => (
<button

View file

@ -45,7 +45,7 @@ export class UserBadges extends Component<UserBadgesProps> {
<span
className={classNames(
"row d-inline-flex gx-1",
this.props.classNames
this.props.classNames,
)}
>
{this.props.isBanned && (

View file

@ -170,7 +170,7 @@ export class Communities extends Component<any, CommunitiesState> {
communityId: cv.community.id,
follow: false,
},
this.handleFollow
this.handleFollow,
)}
>
{I18NextService.i18n.t("unsubscribe")}
@ -185,7 +185,7 @@ export class Communities extends Component<any, CommunitiesState> {
communityId: cv.community.id,
follow: true,
},
this.handleFollow
this.handleFollow,
)}
>
{I18NextService.i18n.t("subscribe")}
@ -198,7 +198,7 @@ export class Communities extends Component<any, CommunitiesState> {
)}
</td>
</tr>
)
),
)}
</tbody>
</table>
@ -285,7 +285,7 @@ export class Communities extends Component<any, CommunitiesState> {
event.preventDefault();
const searchParamEncoded = encodeURIComponent(i.state.searchText);
i.context.router.history.push(
`/search?q=${searchParamEncoded}&type=Communities`
`/search?q=${searchParamEncoded}&type=Communities`,
);
}
@ -306,7 +306,7 @@ export class Communities extends Component<any, CommunitiesState> {
return {
listCommunitiesResponse: await client.listCommunities(
listCommunitiesForm
listCommunitiesForm,
),
};
}
@ -357,7 +357,7 @@ export class Communities extends Component<any, CommunitiesState> {
) {
s.listCommunitiesResponse.data.communities = editCommunity(
res.data.community_view,
s.listCommunitiesResponse.data.communities
s.listCommunitiesResponse.data.communities,
);
}
return s;

View file

@ -231,7 +231,7 @@ export class CommunityForm extends Component<
checked={this.state.form.posting_restricted_to_mods}
onChange={linkEvent(
this,
this.handleCommunityPostingRestrictedToMods
this.handleCommunityPostingRestrictedToMods,
)}
/>
</div>
@ -330,7 +330,7 @@ export class CommunityForm extends Component<
handleCommunityPostingRestrictedToMods(i: CommunityForm, event: any) {
i.setState(
s => ((s.form.posting_restricted_to_mods = event.target.checked), s)
s => ((s.form.posting_restricted_to_mods = event.target.checked), s),
);
}

View file

@ -570,7 +570,7 @@ export class Community extends Component<
};
this.props.history.push(
`/c/${this.props.match.params.name}${getQueryString(queryParams)}`
`/c/${this.props.match.params.name}${getQueryString(queryParams)}`,
);
await this.fetchData();
@ -785,7 +785,7 @@ export class Community extends Component<
async handleTransferCommunity(form: TransferCommunity) {
const transferCommunityRes = await HttpService.client.transferCommunity(
form
form,
);
toast(I18NextService.i18n.t("transfer_community"));
this.updateCommunityFull(transferCommunityRes);
@ -819,14 +819,14 @@ export class Community extends Component<
s.postsRes.data.posts
.filter(c => c.creator.id == banRes.data.person_view.person.id)
.forEach(
c => (c.creator_banned_from_community = banRes.data.banned)
c => (c.creator_banned_from_community = banRes.data.banned),
);
}
if (s.commentsRes.state == "success") {
s.commentsRes.data.comments
.filter(c => c.creator.id == banRes.data.person_view.person.id)
.forEach(
c => (c.creator_banned_from_community = banRes.data.banned)
c => (c.creator_banned_from_community = banRes.data.banned),
);
}
return s;
@ -886,7 +886,7 @@ export class Community extends Component<
if (s.commentsRes.state == "success" && res.state == "success") {
s.commentsRes.data.comments = editComment(
res.data.comment_view,
s.commentsRes.data.comments
s.commentsRes.data.comments,
);
s.finished.set(res.data.comment_view.comment.id, true);
}
@ -902,7 +902,7 @@ export class Community extends Component<
// Set finished for the parent
s.finished.set(
getCommentParentId(res.data.comment_view.comment) ?? 0,
true
true,
);
}
return s;
@ -914,7 +914,7 @@ export class Community extends Component<
if (s.commentsRes.state == "success" && res.state == "success") {
s.commentsRes.data.comments = editWith(
res.data.comment_reply_view,
s.commentsRes.data.comments
s.commentsRes.data.comments,
);
}
return s;
@ -926,7 +926,7 @@ export class Community extends Component<
if (s.postsRes.state == "success" && res.state == "success") {
s.postsRes.data.posts = editPost(
res.data.post_view,
s.postsRes.data.posts
s.postsRes.data.posts,
);
}
return s;

View file

@ -79,7 +79,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
}
componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & SidebarProps>
nextProps: Readonly<{ children?: InfernoNode } & SidebarProps>,
): void {
if (this.props.moderators != nextProps.moderators) {
this.setState({
@ -292,7 +292,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
onClick={linkEvent(this, this.handleBlockCommunity)}
>
{I18NextService.i18n.t(
blocked ? "unblock_community" : "block_community"
blocked ? "unblock_community" : "block_community",
)}
</button>
)
@ -332,7 +332,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
className="btn btn-link text-muted d-inline-block"
onClick={linkEvent(
this,
this.handleShowConfirmLeaveModTeamClick
this.handleShowConfirmLeaveModTeamClick,
)}
>
{I18NextService.i18n.t("leave_mod_team")}
@ -356,7 +356,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
className="btn btn-link text-muted d-inline-block"
onClick={linkEvent(
this,
this.handleCancelLeaveModTeamClick
this.handleCancelLeaveModTeamClick,
)}
>
{I18NextService.i18n.t("no")}

View file

@ -109,8 +109,8 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
Number((this.state.page - 1) * this.itemsPerPage),
Number(
(this.state.page - 1) * this.itemsPerPage +
this.itemsPerPage
)
this.itemsPerPage,
),
)
.map((cv, index) => (
<tr key={index} ref={e => (this.scrollRef[cv.shortcode] = e)}>
@ -130,11 +130,11 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
className="btn btn-sm btn-secondary pointer"
htmlFor={`file-uploader-${index}`}
data-tippy-content={I18NextService.i18n.t(
"upload_image"
"upload_image",
)}
>
{capitalizeFirstLetter(
I18NextService.i18n.t("upload")
I18NextService.i18n.t("upload"),
)}
<input
name={`file-uploader-${index}`}
@ -144,7 +144,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
className="d-none"
onChange={linkEvent(
{ form: this, index: index },
this.handleImageUpload
this.handleImageUpload,
)}
/>
</label>
@ -159,7 +159,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
value={cv.shortcode}
onInput={linkEvent(
{ form: this, index: index },
this.handleEmojiShortCodeChange
this.handleEmojiShortCodeChange,
)}
/>
</td>
@ -171,7 +171,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
value={cv.category}
onInput={linkEvent(
{ form: this, index: index },
this.handleEmojiCategoryChange
this.handleEmojiCategoryChange,
)}
/>
</td>
@ -183,7 +183,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
value={cv.image_url}
onInput={linkEvent(
{ form: this, index: index, overrideValue: null },
this.handleEmojiImageUrlChange
this.handleEmojiImageUrlChange,
)}
/>
</td>
@ -195,7 +195,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
value={cv.alt_text}
onInput={linkEvent(
{ form: this, index: index },
this.handleEmojiAltTextChange
this.handleEmojiAltTextChange,
)}
/>
</td>
@ -207,7 +207,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
value={cv.keywords}
onInput={linkEvent(
{ form: this, index: index },
this.handleEmojiKeywordChange
this.handleEmojiKeywordChange,
)}
/>
</td>
@ -222,7 +222,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
}
onClick={linkEvent(
{ i: this, cv: cv },
this.handleEditEmojiClick
this.handleEditEmojiClick,
)}
data-tippy-content={I18NextService.i18n.t("save")}
aria-label={I18NextService.i18n.t("save")}
@ -232,7 +232,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
<Spinner />
) : (
capitalizeFirstLetter(
I18NextService.i18n.t("save")
I18NextService.i18n.t("save"),
)
)}
</button>
@ -241,7 +241,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
{ i: this, index: index, cv: cv },
this.handleDeleteEmojiClick
this.handleDeleteEmojiClick,
)}
data-tippy-content={I18NextService.i18n.t("delete")}
aria-label={I18NextService.i18n.t("delete")}
@ -281,8 +281,8 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
cv.shortcode.length > 0;
const noDuplicateShortCodes =
this.state.customEmojis.filter(
x => x.shortcode == cv.shortcode && x.id != cv.id
).length == 0;
x => x.shortcode === cv.shortcode && x.id !== cv.id,
).length === 0;
return noEmptyFields && noDuplicateShortCodes && !cv.loading && cv.changed;
}
@ -299,7 +299,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
const view = customEmojisLookup.get(e.id);
if (view) {
const page = this.state.customEmojis.find(
x => x.id == view.custom_emoji.id
x => x.id === view.custom_emoji.id,
)?.page;
if (page) {
this.setState({ page: page });
@ -310,7 +310,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
handleEmojiCategoryChange(
props: { form: EmojiForm; index: number },
event: any
event: any,
) {
const custom_emojis = [...props.form.state.customEmojis];
const pagedIndex =
@ -326,7 +326,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
handleEmojiShortCodeChange(
props: { form: EmojiForm; index: number },
event: any
event: any,
) {
const custom_emojis = [...props.form.state.customEmojis];
const pagedIndex =
@ -346,7 +346,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
index,
overrideValue,
}: { form: EmojiForm; index: number; overrideValue: string | null },
event: any
event: any,
) {
form.setState(prevState => {
const custom_emojis = [...form.state.customEmojis];
@ -367,7 +367,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
changed: true,
loading: false,
}
: ce
: ce,
),
};
});
@ -375,7 +375,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
handleEmojiAltTextChange(
props: { form: EmojiForm; index: number },
event: any
event: any,
) {
const custom_emojis = [...props.form.state.customEmojis];
const pagedIndex =
@ -391,7 +391,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
handleEmojiKeywordChange(
props: { form: EmojiForm; index: number },
event: any
event: any,
) {
const custom_emojis = [...props.form.state.customEmojis];
const pagedIndex =
@ -476,7 +476,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
handleImageUpload(
{ form, index }: { form: EmojiForm; index: number },
event: any
event: any,
) {
let file: any;
if (event.target) {
@ -489,7 +489,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
form.setState(prevState => ({
...prevState,
customEmojis: prevState.customEmojis.map((cv, i) =>
i === index ? { ...cv, loading: true } : cv
i === index ? { ...cv, loading: true } : cv,
),
}));
@ -501,7 +501,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
pictrsDeleteToast(file.name, res.data.delete_url as string);
form.handleEmojiImageUrlChange(
{ form: form, index: index, overrideValue: res.data.url as string },
event
event,
);
} else if (res.data.msg === "too_large") {
toast(I18NextService.i18n.t("upload_too_large"), "danger");

View file

@ -285,9 +285,8 @@ export class Home extends Component<any, HomeState> {
HomeCacheService.postsRes = postsRes;
}
this.state.tagline = getRandomFromList(
this.state?.siteRes?.taglines ?? []
)?.content;
this.state.tagline = getRandomFromList(this.state?.siteRes?.taglines ?? [])
?.content;
}
componentWillUnmount() {
@ -298,7 +297,7 @@ export class Home extends Component<any, HomeState> {
if (
!this.state.isIsomorphic ||
!Object.values(this.isoData.routeData).some(
res => res.state === "success" || res.state === "failed"
res => res.state === "success" || res.state === "failed",
)
) {
await Promise.all([this.fetchTrendingCommunities(), this.fetchData()]);
@ -359,7 +358,7 @@ export class Home extends Component<any, HomeState> {
return {
trendingCommunitiesRes: await client.listCommunities(
trendingCommunitiesForm
trendingCommunitiesForm,
),
commentsRes,
postsRes,
@ -777,7 +776,7 @@ export class Home extends Component<any, HomeState> {
<div className="col-auto ps-0">
{getRss(
listingType ??
this.state.siteRes.site_view.local_site.default_post_listing_type
this.state.siteRes.site_view.local_site.default_post_listing_type,
)}
</div>
</div>
@ -1034,14 +1033,14 @@ export class Home extends Component<any, HomeState> {
s.postsRes.data.posts
.filter(c => c.creator.id == banRes.data.person_view.person.id)
.forEach(
c => (c.creator_banned_from_community = banRes.data.banned)
c => (c.creator_banned_from_community = banRes.data.banned),
);
}
if (s.commentsRes.state == "success") {
s.commentsRes.data.comments
.filter(c => c.creator.id == banRes.data.person_view.person.id)
.forEach(
c => (c.creator_banned_from_community = banRes.data.banned)
c => (c.creator_banned_from_community = banRes.data.banned),
);
}
return s;
@ -1080,7 +1079,7 @@ export class Home extends Component<any, HomeState> {
if (s.commentsRes.state == "success" && res.state == "success") {
s.commentsRes.data.comments = editComment(
res.data.comment_view,
s.commentsRes.data.comments
s.commentsRes.data.comments,
);
s.finished.set(res.data.comment_view.comment.id, true);
}
@ -1096,7 +1095,7 @@ export class Home extends Component<any, HomeState> {
// Set finished for the parent
s.finished.set(
getCommentParentId(res.data.comment_view.comment) ?? 0,
true
true,
);
}
return s;
@ -1108,7 +1107,7 @@ export class Home extends Component<any, HomeState> {
if (s.commentsRes.state == "success" && res.state == "success") {
s.commentsRes.data.comments = editWith(
res.data.comment_reply_view,
s.commentsRes.data.comments
s.commentsRes.data.comments,
);
}
return s;
@ -1120,7 +1119,7 @@ export class Home extends Component<any, HomeState> {
if (s.postsRes.state == "success" && res.state == "success") {
s.postsRes.data.posts = editPost(
res.data.post_view,
s.postsRes.data.posts
s.postsRes.data.posts,
);
}
return s;

View file

@ -38,7 +38,7 @@ export class LoginReset extends Component<any, State> {
get documentTitle(): string {
return `${capitalizeFirstLetter(
I18NextService.i18n.t("forgot_password")
I18NextService.i18n.t("forgot_password"),
)} - ${this.state.siteRes.site_view.site.name}`;
}

View file

@ -88,7 +88,7 @@ function RateLimits({
function handleRateLimitChange(
{ rateLimitType, ctx }: { rateLimitType: string; ctx: RateLimitsForm },
event: any
event: any,
) {
ctx.setState(prev => ({
...prev,
@ -101,7 +101,7 @@ function handleRateLimitChange(
function handlePerSecondChange(
{ rateLimitType, ctx }: { rateLimitType: string; ctx: RateLimitsForm },
event: any
event: any,
) {
ctx.setState(prev => ({
...prev,
@ -122,7 +122,7 @@ function submitRateLimitForm(i: RateLimitsForm, event: any) {
},
{
auth,
}
},
);
i.props.onSaveSite(form);
@ -159,11 +159,11 @@ export default class RateLimitsForm extends Component<
})}
handleRateLimit={linkEvent(
{ rateLimitType, ctx: this },
handleRateLimitChange
handleRateLimitChange,
)}
handleRateLimitPerSecond={linkEvent(
{ rateLimitType, ctx: this },
handlePerSecondChange
handlePerSecondChange,
)}
rateLimitValue={this.state.form[rateLimitType]}
rateLimitPerSecondValue={

View file

@ -85,7 +85,7 @@ export class Signup extends Component<any, State> {
titleName(siteView: SiteView): string {
return I18NextService.i18n.t(
siteView.local_site.private_instance ? "apply_to_join" : "sign_up"
siteView.local_site.private_instance ? "apply_to_join" : "sign_up",
);
}
@ -213,7 +213,7 @@ export class Signup extends Component<any, State> {
<div
className="md-div"
dangerouslySetInnerHTML={mdToHtml(
siteView.local_site.application_question
siteView.local_site.application_question,
)}
/>
)}
@ -311,7 +311,7 @@ export class Signup extends Component<any, State> {
value={this.state.form.captcha_answer}
onInput={linkEvent(
this,
this.handleRegisterCaptchaAnswerChange
this.handleRegisterCaptchaAnswerChange,
)}
required
/>

View file

@ -319,7 +319,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
checked={this.state.siteForm.community_creation_admin_only}
onChange={linkEvent(
this,
this.handleSiteCommunityCreationAdminOnly
this.handleSiteCommunityCreationAdminOnly,
)}
/>
<label
@ -341,7 +341,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
checked={this.state.siteForm.require_email_verification}
onChange={linkEvent(
this,
this.handleSiteRequireEmailVerification
this.handleSiteRequireEmailVerification,
)}
/>
<label
@ -363,7 +363,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
checked={this.state.siteForm.application_email_admins}
onChange={linkEvent(
this,
this.handleSiteApplicationEmailAdmins
this.handleSiteApplicationEmailAdmins,
)}
/>
<label
@ -631,7 +631,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
}
componentDidUpdate(
prevProps: Readonly<{ children?: InfernoNode } & SiteFormProps>
prevProps: Readonly<{ children?: InfernoNode } & SiteFormProps>,
) {
if (
!(
@ -694,7 +694,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
className="btn btn-sm bg-danger"
onClick={linkEvent(
{ key, instance },
this.handleRemoveInstance
this.handleRemoveInstance,
)}
>
<Icon
@ -722,7 +722,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
handleInstanceEnterPress(
key: InstanceKey,
event: InfernoKeyboardEvent<HTMLInputElement>
event: InfernoKeyboardEvent<HTMLInputElement>,
) {
if (event.code.toLowerCase() === "enter") {
event.preventDefault();
@ -863,7 +863,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
handleDeleteTaglineClick(
i: SiteForm,
index: number,
event: InfernoMouseEvent<HTMLButtonElement>
event: InfernoMouseEvent<HTMLButtonElement>,
) {
event.preventDefault();
const taglines = i.state.siteForm.taglines;
@ -878,7 +878,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
handleAddTaglineClick(
i: SiteForm,
event: InfernoMouseEvent<HTMLButtonElement>
event: InfernoMouseEvent<HTMLButtonElement>,
) {
event.preventDefault();
if (!i.state.siteForm.taglines) {
@ -969,7 +969,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
handleSiteActorNameMaxLength(i: SiteForm, event: any) {
i.setState(
s => ((s.siteForm.actor_name_max_length = Number(event.target.value)), s)
s => ((s.siteForm.actor_name_max_length = Number(event.target.value)), s),
);
}

View file

@ -58,7 +58,7 @@ export class TaglineForm extends Component<TaglineFormProps, TaglineFormState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
{ i: this, index: index },
this.handleEditTaglineClick
this.handleEditTaglineClick,
)}
data-tippy-content={I18NextService.i18n.t("edit")}
aria-label={I18NextService.i18n.t("edit")}
@ -70,7 +70,7 @@ export class TaglineForm extends Component<TaglineFormProps, TaglineFormState> {
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(
{ i: this, index: index },
this.handleDeleteTaglineClick
this.handleDeleteTaglineClick,
)}
data-tippy-content={I18NextService.i18n.t("delete")}
aria-label={I18NextService.i18n.t("delete")}
@ -149,7 +149,7 @@ export class TaglineForm extends Component<TaglineFormProps, TaglineFormState> {
handleAddTaglineClick(
i: TaglineForm,
event: InfernoMouseEvent<HTMLButtonElement>
event: InfernoMouseEvent<HTMLButtonElement>,
) {
event.preventDefault();
const newTaglines = [...i.state.taglines];

View file

@ -121,7 +121,7 @@ function getActionFromString(action?: string): ModlogActionType {
const getModlogActionMapper =
(
actionType: ModlogActionType,
getAction: (view: View) => { id: number; when_: string }
getAction: (view: View) => { id: number; when_: string },
) =>
(view: View & { moderator?: Person; admin?: Person }): ModlogType => {
const { id, when_ } = getAction(view);
@ -155,111 +155,111 @@ function buildCombined({
.map(
getModlogActionMapper(
"ModRemovePost",
({ mod_remove_post }: ModRemovePostView) => mod_remove_post
)
({ mod_remove_post }: ModRemovePostView) => mod_remove_post,
),
)
.concat(
locked_posts.map(
getModlogActionMapper(
"ModLockPost",
({ mod_lock_post }: ModLockPostView) => mod_lock_post
)
)
({ mod_lock_post }: ModLockPostView) => mod_lock_post,
),
),
)
.concat(
featured_posts.map(
getModlogActionMapper(
"ModFeaturePost",
({ mod_feature_post }: ModFeaturePostView) => mod_feature_post
)
)
({ mod_feature_post }: ModFeaturePostView) => mod_feature_post,
),
),
)
.concat(
removed_comments.map(
getModlogActionMapper(
"ModRemoveComment",
({ mod_remove_comment }: ModRemoveCommentView) => mod_remove_comment
)
)
({ mod_remove_comment }: ModRemoveCommentView) => mod_remove_comment,
),
),
)
.concat(
removed_communities.map(
getModlogActionMapper(
"ModRemoveCommunity",
({ mod_remove_community }: ModRemoveCommunityView) =>
mod_remove_community
)
)
mod_remove_community,
),
),
)
.concat(
banned_from_community.map(
getModlogActionMapper(
"ModBanFromCommunity",
({ mod_ban_from_community }: ModBanFromCommunityView) =>
mod_ban_from_community
)
)
mod_ban_from_community,
),
),
)
.concat(
added_to_community.map(
getModlogActionMapper(
"ModAddCommunity",
({ mod_add_community }: ModAddCommunityView) => mod_add_community
)
)
({ mod_add_community }: ModAddCommunityView) => mod_add_community,
),
),
)
.concat(
transferred_to_community.map(
getModlogActionMapper(
"ModTransferCommunity",
({ mod_transfer_community }: ModTransferCommunityView) =>
mod_transfer_community
)
)
mod_transfer_community,
),
),
)
.concat(
added.map(
getModlogActionMapper("ModAdd", ({ mod_add }: ModAddView) => mod_add)
)
getModlogActionMapper("ModAdd", ({ mod_add }: ModAddView) => mod_add),
),
)
.concat(
banned.map(
getModlogActionMapper("ModBan", ({ mod_ban }: ModBanView) => mod_ban)
)
getModlogActionMapper("ModBan", ({ mod_ban }: ModBanView) => mod_ban),
),
)
.concat(
admin_purged_persons.map(
getModlogActionMapper(
"AdminPurgePerson",
({ admin_purge_person }: AdminPurgePersonView) => admin_purge_person
)
)
({ admin_purge_person }: AdminPurgePersonView) => admin_purge_person,
),
),
)
.concat(
admin_purged_communities.map(
getModlogActionMapper(
"AdminPurgeCommunity",
({ admin_purge_community }: AdminPurgeCommunityView) =>
admin_purge_community
)
)
admin_purge_community,
),
),
)
.concat(
admin_purged_posts.map(
getModlogActionMapper(
"AdminPurgePost",
({ admin_purge_post }: AdminPurgePostView) => admin_purge_post
)
)
({ admin_purge_post }: AdminPurgePostView) => admin_purge_post,
),
),
)
.concat(
admin_purged_comments.map(
getModlogActionMapper(
"AdminPurgeComment",
({ admin_purge_comment }: AdminPurgeCommentView) =>
admin_purge_comment
)
)
admin_purge_comment,
),
),
);
// Sort them by time
@ -622,7 +622,7 @@ async function createNewOptions({
if (id) {
const selectedUser = oldOptions.find(
({ value }) => value === id.toString()
({ value }) => value === id.toString(),
);
if (selectedUser) {
@ -634,7 +634,7 @@ async function createNewOptions({
newOptions.push(
...(await fetchUsers(text))
.slice(0, Number(fetchLimit))
.map<Choice>(personToChoice)
.map<Choice>(personToChoice),
);
}
@ -658,7 +658,7 @@ export class Modlog extends Component<
constructor(
props: RouteComponentProps<{ communityId?: string }>,
context: any
context: any,
) {
super(props, context);
this.handlePageChange = this.handlePageChange.bind(this);
@ -731,7 +731,7 @@ export class Modlog extends Component<
modOrAdminText(person?: Person): string {
return person &&
this.isoData.site_res.admins.some(
({ person: { id } }) => id === person.id
({ person: { id } }) => id === person.id,
)
? I18NextService.i18n.t("admin")
: I18NextService.i18n.t("mod");
@ -939,8 +939,8 @@ export class Modlog extends Component<
this.props.history.push(
`/modlog${communityId ? `/${communityId}` : ""}${getQueryString(
queryParams
)}`
queryParams,
)}`,
);
await this.refetch();

View file

@ -188,7 +188,7 @@ export class Inbox extends Component<any, InboxState> {
const mui = UserService.Instance.myUserInfo;
return mui
? `@${mui.local_user_view.person.name} ${I18NextService.i18n.t(
"inbox"
"inbox",
)} - ${this.state.siteRes.site_view.site.name}`
: "";
}
@ -246,7 +246,7 @@ export class Inbox extends Component<any, InboxState> {
<Spinner />
) : (
capitalizeFirstLetter(
I18NextService.i18n.t("mark_all_as_read")
I18NextService.i18n.t("mark_all_as_read"),
)
)}
</button>
@ -455,12 +455,12 @@ export class Inbox extends Component<any, InboxState> {
const messages: ReplyType[] =
this.state.messagesRes.state == "success"
? this.state.messagesRes.data.private_messages.map(
this.messageToReplyType
this.messageToReplyType,
)
: [];
return [...replies, ...mentions, ...messages].sort((a, b) =>
b.published.localeCompare(a.published)
b.published.localeCompare(a.published),
);
}
@ -960,7 +960,7 @@ export class Inbox extends Component<any, InboxState> {
this.setState(s => {
if (s.messagesRes.state == "success" && res.state == "success") {
s.messagesRes.data.private_messages.unshift(
res.data.private_message_view
res.data.private_message_view,
);
}
@ -973,7 +973,7 @@ export class Inbox extends Component<any, InboxState> {
if (s.messagesRes.state === "success" && res.state === "success") {
s.messagesRes.data.private_messages = editPrivateMessage(
res.data.private_message_view,
s.messagesRes.data.private_messages
s.messagesRes.data.private_messages,
);
}
return s;
@ -988,14 +988,14 @@ export class Inbox extends Component<any, InboxState> {
s.repliesRes.data.replies
.filter(c => c.creator.id == banRes.data.person_view.person.id)
.forEach(
c => (c.creator_banned_from_community = banRes.data.banned)
c => (c.creator_banned_from_community = banRes.data.banned),
);
}
if (s.mentionsRes.state == "success") {
s.mentionsRes.data.mentions
.filter(c => c.creator.id == banRes.data.person_view.person.id)
.forEach(
c => (c.creator_banned_from_community = banRes.data.banned)
c => (c.creator_banned_from_community = banRes.data.banned),
);
}
return s;
@ -1030,7 +1030,7 @@ export class Inbox extends Component<any, InboxState> {
}
reportToast(
res: RequestState<PrivateMessageReportResponse | CommentReportResponse>
res: RequestState<PrivateMessageReportResponse | CommentReportResponse>,
) {
if (res.state == "success") {
toast(I18NextService.i18n.t("report_created"));
@ -1044,19 +1044,19 @@ export class Inbox extends Component<any, InboxState> {
if (s.repliesRes.state == "success") {
s.repliesRes.data.replies = editWith(
res.data.comment_view,
s.repliesRes.data.replies
s.repliesRes.data.replies,
);
}
if (s.mentionsRes.state == "success") {
s.mentionsRes.data.mentions = editWith(
res.data.comment_view,
s.mentionsRes.data.mentions
s.mentionsRes.data.mentions,
);
}
// Set finished for the parent
s.finished.set(
getCommentParentId(res.data.comment_view.comment) ?? 0,
true
true,
);
return s;
});
@ -1068,7 +1068,7 @@ export class Inbox extends Component<any, InboxState> {
if (s.repliesRes.state == "success" && res.state == "success") {
s.repliesRes.data.replies = editCommentReply(
res.data.comment_reply_view,
s.repliesRes.data.replies
s.repliesRes.data.replies,
);
}
return s;
@ -1080,7 +1080,7 @@ export class Inbox extends Component<any, InboxState> {
if (s.mentionsRes.state == "success" && res.state == "success") {
s.mentionsRes.data.mentions = editMention(
res.data.person_mention_view,
s.mentionsRes.data.mentions
s.mentionsRes.data.mentions,
);
}
return s;

View file

@ -57,7 +57,7 @@ export class PersonListing extends Component<PersonListingProps, any> {
{
"text-muted": this.props.muted,
"text-info": !this.props.muted,
}
},
)}
to={link}
>

View file

@ -132,7 +132,7 @@ function getViewFromProps(view?: string): PersonDetailsView {
const getCommunitiesListing = (
translationKey: NoOptionI18nKeys,
communityViews?: { community: Community }[]
communityViews?: { community: Community }[],
) =>
communityViews &&
communityViews.length > 0 && (
@ -266,7 +266,7 @@ export class Profile extends Component<
if (mui && res.state === "success") {
this.setState({
personBlocked: mui.person_blocks.some(
({ target: { id } }) => id === res.data.person_view.person.id
({ target: { id } }) => id === res.data.person_view.person.id,
),
});
}
@ -530,7 +530,7 @@ export class Profile extends Component<
}
onClick={linkEvent(
pv.person.id,
this.handleUnblockPerson
this.handleUnblockPerson,
)}
>
{I18NextService.i18n.t("unblock_user")}
@ -542,7 +542,7 @@ export class Profile extends Component<
}
onClick={linkEvent(
pv.person.id,
this.handleBlockPerson
this.handleBlockPerson,
)}
>
{I18NextService.i18n.t("block_user")}
@ -962,13 +962,13 @@ export class Profile extends Component<
s.personRes.data.posts
.filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(
c => (c.creator_banned_from_community = banRes.data.banned)
c => (c.creator_banned_from_community = banRes.data.banned),
);
s.personRes.data.comments
.filter(c => c.creator.id === banRes.data.person_view.person.id)
.forEach(
c => (c.creator_banned_from_community = banRes.data.banned)
c => (c.creator_banned_from_community = banRes.data.banned),
);
}
return s;
@ -1006,7 +1006,7 @@ export class Profile extends Component<
if (s.personRes.state == "success" && res.state == "success") {
s.personRes.data.comments = editComment(
res.data.comment_view,
s.personRes.data.comments
s.personRes.data.comments,
);
s.finished.set(res.data.comment_view.comment.id, true);
}
@ -1021,7 +1021,7 @@ export class Profile extends Component<
// Set finished for the parent
s.finished.set(
getCommentParentId(res.data.comment_view.comment) ?? 0,
true
true,
);
}
return s;
@ -1033,7 +1033,7 @@ export class Profile extends Component<
if (s.personRes.state == "success" && res.state == "success") {
s.personRes.data.comments = editWith(
res.data.comment_reply_view,
s.personRes.data.comments
s.personRes.data.comments,
);
}
return s;
@ -1045,7 +1045,7 @@ export class Profile extends Component<
if (s.personRes.state == "success" && res.state == "success") {
s.personRes.data.posts = editPost(
res.data.post_view,
s.personRes.data.posts
s.personRes.data.posts,
);
}
return s;

View file

@ -80,7 +80,7 @@ export class RegistrationApplications extends Component<
const mui = UserService.Instance.myUserInfo;
return mui
? `@${mui.local_user_view.person.name} ${I18NextService.i18n.t(
"registration_applications"
"registration_applications",
)} - ${this.state.siteRes.site_view.site.name}`
: "";
}
@ -236,13 +236,13 @@ export class RegistrationApplications extends Component<
async handleApproveApplication(form: ApproveRegistrationApplication) {
const approveRes = await HttpService.client.approveRegistrationApplication(
form
form,
);
this.setState(s => {
if (s.appsRes.state == "success" && approveRes.state == "success") {
s.appsRes.data.registration_applications = editRegistrationApplication(
approveRes.data.registration_application,
s.appsRes.data.registration_applications
s.appsRes.data.registration_applications,
);
}
return s;

View file

@ -140,7 +140,7 @@ export class Reports extends Component<any, ReportsState> {
const mui = UserService.Instance.myUserInfo;
return mui
? `@${mui.local_user_view.person.name} ${I18NextService.i18n.t(
"reports"
"reports",
)} - ${this.state.siteRes.site_view.site.name}`
: "";
}
@ -365,12 +365,12 @@ export class Reports extends Component<any, ReportsState> {
const privateMessages =
pmRes.state == "success"
? pmRes.data.private_message_reports.map(
this.privateMessageReportToItemType
this.privateMessageReportToItemType,
)
: [];
return [...comments, ...posts, ...privateMessages].sort((a, b) =>
b.published.localeCompare(a.published)
b.published.localeCompare(a.published),
);
}
@ -557,7 +557,7 @@ export class Reports extends Component<any, ReportsState> {
};
data.messageReportsRes = await client.listPrivateMessageReports(
privateMessageReportsForm
privateMessageReportsForm,
);
}
@ -594,7 +594,7 @@ export class Reports extends Component<any, ReportsState> {
if (amAdmin()) {
this.setState({
messageReportsRes: await HttpService.client.listPrivateMessageReports(
form
form,
),
});
}
@ -620,7 +620,7 @@ export class Reports extends Component<any, ReportsState> {
if (s.commentReportsRes.state == "success" && res.state == "success") {
s.commentReportsRes.data.comment_reports = editCommentReport(
res.data.comment_report_view,
s.commentReportsRes.data.comment_reports
s.commentReportsRes.data.comment_reports,
);
}
return s;
@ -632,7 +632,7 @@ export class Reports extends Component<any, ReportsState> {
if (s.postReportsRes.state == "success" && res.state == "success") {
s.postReportsRes.data.post_reports = editPostReport(
res.data.post_report_view,
s.postReportsRes.data.post_reports
s.postReportsRes.data.post_reports,
);
}
return s;
@ -640,14 +640,14 @@ export class Reports extends Component<any, ReportsState> {
}
findAndUpdatePrivateMessageReport(
res: RequestState<PrivateMessageReportResponse>
res: RequestState<PrivateMessageReportResponse>,
) {
this.setState(s => {
if (s.messageReportsRes.state == "success" && res.state == "success") {
s.messageReportsRes.data.private_message_reports =
editPrivateMessageReport(
res.data.private_message_report_view,
s.messageReportsRes.data.private_message_reports
s.messageReportsRes.data.private_message_reports,
);
}
return s;

View file

@ -391,7 +391,7 @@ export class Settings extends Component<any, SettingsState> {
className="btn btn-sm"
onClick={linkEvent(
{ ctx: this, recipientId: pb.target.id },
this.handleUnblockPerson
this.handleUnblockPerson,
)}
data-tippy-content={I18NextService.i18n.t("unblock_user")}
>
@ -435,10 +435,10 @@ export class Settings extends Component<any, SettingsState> {
className="btn btn-sm"
onClick={linkEvent(
{ ctx: this, communityId: cb.community.id },
this.handleUnblockCommunity
this.handleUnblockCommunity,
)}
data-tippy-content={I18NextService.i18n.t(
"unblock_community"
"unblock_community",
)}
>
<Icon icon="x" classes="icon-inline" />
@ -767,7 +767,7 @@ export class Settings extends Component<any, SettingsState> {
}
onChange={linkEvent(
this,
this.handleSendNotificationsToEmailChange
this.handleSendNotificationsToEmailChange,
)}
/>
<label
@ -798,7 +798,7 @@ export class Settings extends Component<any, SettingsState> {
className="btn d-block btn-danger"
onClick={linkEvent(
this,
this.handleDeleteAccountShowConfirmToggle
this.handleDeleteAccountShowConfirmToggle,
)}
>
{I18NextService.i18n.t("delete_account")}
@ -817,7 +817,7 @@ export class Settings extends Component<any, SettingsState> {
value={this.state.deleteAccountForm.password}
onInput={linkEvent(
this,
this.handleDeleteAccountPasswordChange
this.handleDeleteAccountPasswordChange,
)}
className="my-2"
/>
@ -837,7 +837,7 @@ export class Settings extends Component<any, SettingsState> {
type="button"
onClick={linkEvent(
this,
this.handleDeleteAccountShowConfirmToggle
this.handleDeleteAccountShowConfirmToggle,
)}
>
{I18NextService.i18n.t("cancel")}
@ -924,7 +924,7 @@ export class Settings extends Component<any, SettingsState> {
if (text.length > 0) {
searchCommunityOptions.push(
...(await fetchCommunities(text)).map(communityToChoice)
...(await fetchCommunities(text)).map(communityToChoice),
);
}
@ -985,7 +985,7 @@ export class Settings extends Component<any, SettingsState> {
handleShowNsfwChange(i: Settings, event: any) {
i.setState(
s => ((s.saveUserSettingsForm.show_nsfw = event.target.checked), s)
s => ((s.saveUserSettingsForm.show_nsfw = event.target.checked), s),
);
}
@ -995,13 +995,13 @@ export class Settings extends Component<any, SettingsState> {
mui.local_user_view.local_user.show_avatars = event.target.checked;
}
i.setState(
s => ((s.saveUserSettingsForm.show_avatars = event.target.checked), s)
s => ((s.saveUserSettingsForm.show_avatars = event.target.checked), s),
);
}
handleBotAccount(i: Settings, event: any) {
i.setState(
s => ((s.saveUserSettingsForm.bot_account = event.target.checked), s)
s => ((s.saveUserSettingsForm.bot_account = event.target.checked), s),
);
}
@ -1009,13 +1009,13 @@ export class Settings extends Component<any, SettingsState> {
i.setState(
s => (
(s.saveUserSettingsForm.show_bot_accounts = event.target.checked), s
)
),
);
}
handleReadPosts(i: Settings, event: any) {
i.setState(
s => ((s.saveUserSettingsForm.show_read_posts = event.target.checked), s)
s => ((s.saveUserSettingsForm.show_read_posts = event.target.checked), s),
);
}
@ -1023,7 +1023,7 @@ export class Settings extends Component<any, SettingsState> {
i.setState(
s => (
(s.saveUserSettingsForm.show_new_post_notifs = event.target.checked), s
)
),
);
}
@ -1033,7 +1033,7 @@ export class Settings extends Component<any, SettingsState> {
mui.local_user_view.local_user.show_scores = event.target.checked;
}
i.setState(
s => ((s.saveUserSettingsForm.show_scores = event.target.checked), s)
s => ((s.saveUserSettingsForm.show_scores = event.target.checked), s),
);
}
@ -1058,7 +1058,7 @@ export class Settings extends Component<any, SettingsState> {
(s.saveUserSettingsForm.send_notifications_to_email =
event.target.checked),
s
)
),
);
}
@ -1070,17 +1070,19 @@ export class Settings extends Component<any, SettingsState> {
handleInterfaceLangChange(i: Settings, event: any) {
const newLang = event.target.value ?? "browser";
I18NextService.i18n.changeLanguage(
newLang === "browser" ? navigator.languages : newLang
newLang === "browser" ? navigator.languages : newLang,
);
i.setState(
s => ((s.saveUserSettingsForm.interface_language = event.target.value), s)
s => (
(s.saveUserSettingsForm.interface_language = event.target.value), s
),
);
}
handleDiscussionLanguageChange(val: number[]) {
this.setState(
s => ((s.saveUserSettingsForm.discussion_languages = val), s)
s => ((s.saveUserSettingsForm.discussion_languages = val), s),
);
}
@ -1090,7 +1092,7 @@ export class Settings extends Component<any, SettingsState> {
handleListingTypeChange(val: ListingType) {
this.setState(
s => ((s.saveUserSettingsForm.default_listing_type = val), s)
s => ((s.saveUserSettingsForm.default_listing_type = val), s),
);
}
@ -1120,13 +1122,13 @@ export class Settings extends Component<any, SettingsState> {
handleDisplayNameChange(i: Settings, event: any) {
i.setState(
s => ((s.saveUserSettingsForm.display_name = event.target.value), s)
s => ((s.saveUserSettingsForm.display_name = event.target.value), s),
);
}
handleMatrixUserIdChange(i: Settings, event: any) {
i.setState(
s => ((s.saveUserSettingsForm.matrix_user_id = event.target.value), s)
s => ((s.saveUserSettingsForm.matrix_user_id = event.target.value), s),
);
}
@ -1140,7 +1142,7 @@ export class Settings extends Component<any, SettingsState> {
const newPassVerify: string | undefined =
event.target.value == "" ? undefined : event.target.value;
i.setState(
s => ((s.changePasswordForm.new_password_verify = newPassVerify), s)
s => ((s.changePasswordForm.new_password_verify = newPassVerify), s),
);
}

View file

@ -121,7 +121,7 @@ export class CreatePost extends Component<
const { communityId } = getCreatePostQueryParams();
const initialCommunitiesRes = await fetchCommunitiesForOptions(
HttpService.client
HttpService.client,
);
this.setState({

View file

@ -122,7 +122,7 @@ function copySuggestedTitle(d: { i: PostForm; suggestedTitle?: string }) {
const sTitle = d.suggestedTitle;
if (sTitle) {
d.i.setState(
s => ((s.form.name = sTitle?.substring(0, MAX_POST_TITLE_LENGTH)), s)
s => ((s.form.name = sTitle?.substring(0, MAX_POST_TITLE_LENGTH)), s),
);
d.i.setState({ suggestedPostsRes: { state: "empty" } });
setTimeout(() => {
@ -271,9 +271,9 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
({ community: { id, title } }) => ({
label: title,
value: id.toString(),
})
}),
) ?? []
).filter(option => option.value !== selectedCommunityChoice.value)
).filter(option => option.value !== selectedCommunityChoice.value),
),
};
} else {
@ -284,7 +284,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
({ community: { id, title } }) => ({
label: title,
value: id.toString(),
})
}),
) ?? [],
};
}
@ -310,16 +310,16 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
}
componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & PostFormProps>
nextProps: Readonly<{ children?: InfernoNode } & PostFormProps>,
): void {
if (this.props != nextProps) {
this.setState(
s => (
(s.form.community_id = getIdFromString(
nextProps.selectedCommunityChoice?.value
nextProps.selectedCommunityChoice?.value,
)),
s
)
),
);
}
}
@ -367,7 +367,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
</a>
<a
href={`${ghostArchiveUrl}/search?term=${encodeURIComponent(
url
url,
)}`}
className="me-2 d-inline-block float-right text-muted small fw-bold"
rel={relTags}
@ -376,7 +376,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
</a>
<a
href={`${archiveTodayUrl}/?run=1&url=${encodeURIComponent(
url
url,
)}`}
className="me-2 d-inline-block float-right text-muted small fw-bold"
rel={relTags}
@ -590,7 +590,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
className="mt-1 small border-0 bg-transparent p-0 d-block text-muted fw-bold pointer"
onClick={linkEvent(
{ i: this, suggestedTitle },
copySuggestedTitle
copySuggestedTitle,
)}
>
{I18NextService.i18n.t("copy_suggested_title", { title: "" })}{" "}

View file

@ -419,7 +419,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
<span className="mx-1 badge text-bg-light">
{
this.props.allLanguages.find(
lang => lang.id === post_view.post.language_id
lang => lang.id === post_view.post.language_id,
)?.name
}
</span>
@ -515,7 +515,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
<small
className="unselectable pointer ms-2 text-muted fst-italic"
data-tippy-content={I18NextService.i18n.t(
"featured_in_community"
"featured_in_community",
)}
aria-label={I18NextService.i18n.t("featured_in_community")}
>
@ -1115,7 +1115,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
className="btn btn-link btn-sm d-flex align-items-center rounded-0 dropdown-item"
onClick={linkEvent(
this,
!removed ? this.handleModRemoveShow : this.handleModRemoveSubmit
!removed ? this.handleModRemoveShow : this.handleModRemoveSubmit,
)}
>
{/* TODO: Find an icon for this. */}
@ -1188,7 +1188,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
className="btn btn-link btn-animate text-muted py-0 d-inline-block"
onClick={linkEvent(
this,
this.handleCancelShowConfirmTransferCommunity
this.handleCancelShowConfirmTransferCommunity,
)}
aria-label={I18NextService.i18n.t("no")}
>
@ -1772,7 +1772,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
this.props.moderators,
this.props.admins,
undefined,
true
true,
);
}
@ -1780,7 +1780,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
return canMod(
this.postView.creator.id,
this.props.moderators,
this.props.admins
this.props.admins,
);
}

View file

@ -26,7 +26,7 @@ export class PostReport extends Component<PostReportProps, PostReportState> {
}
componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & PostReportProps>
nextProps: Readonly<{ children?: InfernoNode } & PostReportProps>,
): void {
if (this.props != nextProps) {
this.setState({ loading: false });
@ -38,7 +38,7 @@ export class PostReport extends Component<PostReportProps, PostReportState> {
const resolver = r.resolver;
const post = r.post;
const tippyContent = I18NextService.i18n.t(
r.post_report.resolved ? "unresolve_report" : "resolve_report"
r.post_report.resolved ? "unresolve_report" : "resolve_report",
);
// Set the original post data ( a troll could change it )

View file

@ -290,7 +290,7 @@ export class Post extends Component<any, PostState> {
get checkScrollIntoCommentsParam() {
return Boolean(
new URLSearchParams(this.props.location.search).get("scrollToComments")
new URLSearchParams(this.props.location.search).get("scrollToComments"),
);
}
@ -667,7 +667,7 @@ export class Post extends Component<any, PostState> {
if (this.state.commentsRes.state == "success") {
return buildCommentsTree(
this.state.commentsRes.data.comments,
!!this.state.commentId
!!this.state.commentId,
);
} else {
return [];
@ -705,7 +705,7 @@ export class Post extends Component<any, PostState> {
handleViewContext(i: Post) {
if (i.state.commentsRes.state == "success") {
const parentId = getCommentParentId(
i.state.commentsRes.data.comments.at(0)?.comment
i.state.commentsRes.data.comments.at(0)?.comment,
);
if (parentId) {
i.context.router.history.push(`/comment/${parentId}`);
@ -887,7 +887,7 @@ export class Post extends Component<any, PostState> {
async handleTransferCommunity(form: TransferCommunity) {
const transferCommunityRes = await HttpService.client.transferCommunity(
form
form,
);
this.updateCommunityFull(transferCommunityRes);
}
@ -943,7 +943,7 @@ export class Post extends Component<any, PostState> {
s.commentsRes.data.comments
.filter(c => c.creator.id == banRes.data.person_view.person.id)
.forEach(
c => (c.creator_banned_from_community = banRes.data.banned)
c => (c.creator_banned_from_community = banRes.data.banned),
);
}
return s;
@ -1015,7 +1015,7 @@ export class Post extends Component<any, PostState> {
// Set finished for the parent
s.finished.set(
getCommentParentId(res.data.comment_view.comment) ?? 0,
true
true,
);
}
return s;
@ -1027,7 +1027,7 @@ export class Post extends Component<any, PostState> {
if (s.commentsRes.state == "success" && res.state == "success") {
s.commentsRes.data.comments = editComment(
res.data.comment_view,
s.commentsRes.data.comments
s.commentsRes.data.comments,
);
s.finished.set(res.data.comment_view.comment.id, true);
}
@ -1040,7 +1040,7 @@ export class Post extends Component<any, PostState> {
if (s.commentsRes.state == "success" && res.state == "success") {
s.commentsRes.data.comments = editWith(
res.data.comment_reply_view,
s.commentsRes.data.comments
s.commentsRes.data.comments,
);
}
return s;

View file

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

View file

@ -29,7 +29,7 @@ export class PrivateMessageReport extends Component<Props, State> {
}
componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & Props>
nextProps: Readonly<{ children?: InfernoNode } & Props>,
): void {
if (this.props != nextProps) {
this.setState({ loading: false });
@ -40,7 +40,7 @@ export class PrivateMessageReport extends Component<Props, State> {
const r = this.props.report;
const pmr = r.private_message_report;
const tippyContent = I18NextService.i18n.t(
r.private_message_report.resolved ? "unresolve_report" : "resolve_report"
r.private_message_report.resolved ? "unresolve_report" : "resolve_report",
);
return (

View file

@ -65,7 +65,7 @@ export class PrivateMessage extends Component<
}
componentWillReceiveProps(
nextProps: Readonly<{ children?: InfernoNode } & PrivateMessageProps>
nextProps: Readonly<{ children?: InfernoNode } & PrivateMessageProps>,
): void {
if (this.props != nextProps) {
this.setState({

View file

@ -209,20 +209,20 @@ const communityListing = ({
getListing(
<CommunityLink community={community} />,
subscribers,
"number_of_subscribers"
"number_of_subscribers",
);
const personListing = ({ person, counts: { comment_count } }: PersonView) =>
getListing(
<PersonListing person={person} showApubName />,
comment_count,
"number_of_comments"
"number_of_comments",
);
function getListing(
listing: JSX.ElementClass,
count: number,
translationKey: "number_of_comments" | "number_of_subscribers"
translationKey: "number_of_comments" | "number_of_subscribers",
) {
return (
<>
@ -386,7 +386,7 @@ export class Search extends Component<any, SearchState> {
};
listCommunitiesResponse = await client.listCommunities(
listCommunitiesForm
listCommunitiesForm,
);
}
@ -431,7 +431,7 @@ export class Search extends Component<any, SearchState> {
auth,
};
resolveObjectResponse = await HttpService.silent_client.resolveObject(
resolveObjectForm
resolveObjectForm,
);
// If we return this object with a state of failed, the catch-all-handler will redirect
@ -564,7 +564,7 @@ export class Search extends Component<any, SearchState> {
{searchTypes.map(option => (
<option value={option} key={option}>
{I18NextService.i18n.t(
option.toString().toLowerCase() as NoOptionI18nKeys
option.toString().toLowerCase() as NoOptionI18nKeys,
)}
</option>
))}
@ -646,7 +646,7 @@ export class Search extends Component<any, SearchState> {
...(posts?.map(postViewToCombined) ?? []),
...(communities?.map(communityViewToCombined) ?? []),
...(users?.map(personViewSafeToCombined) ?? []),
]
],
);
}
@ -663,8 +663,8 @@ export class Search extends Component<any, SearchState> {
(b.data as PersonView).counts.comment_score) -
((a.data as CommentView | PostView).counts.score |
(a.data as CommunityView).counts.subscribers |
(a.data as PersonView).counts.comment_score)
)
(a.data as PersonView).counts.comment_score),
),
);
}
@ -984,7 +984,7 @@ export class Search extends Component<any, SearchState> {
this.setState({ searchCreatorLoading: true });
const selectedChoice = creatorSearchOptions.find(
choice => getIdFromString(choice.value) === creatorId
choice => getIdFromString(choice.value) === creatorId,
);
if (selectedChoice) {
@ -1011,7 +1011,7 @@ export class Search extends Component<any, SearchState> {
const newOptions: Choice[] = [];
const selectedChoice = communitySearchOptions.find(
choice => getIdFromString(choice.value) === communityId
choice => getIdFromString(choice.value) === communityId,
);
if (selectedChoice) {

View file

@ -191,7 +191,7 @@ export function setupMarkdown() {
idx: number,
options: MarkdownIt.Options,
env: any,
self: Renderer
self: Renderer,
) {
//Provide custom renderer for our emojis to allow us to add a css class and force size dimensions on them.
const item = tokens[idx] as any;
@ -215,7 +215,7 @@ export function setupMarkdown() {
export function setupEmojiDataModel(custom_emoji_views: CustomEmojiView[]) {
const groupedEmojis = groupBy(
custom_emoji_views,
x => x.custom_emoji.category
x => x.custom_emoji.category,
);
for (const [category, emojis] of Object.entries(groupedEmojis)) {
customEmojis.push({
@ -230,7 +230,7 @@ export function setupEmojiDataModel(custom_emoji_views: CustomEmojiView[]) {
});
}
customEmojisLookup = new Map(
custom_emoji_views.map(view => [view.custom_emoji.shortcode, view])
custom_emoji_views.map(view => [view.custom_emoji.shortcode, view]),
);
}
@ -242,7 +242,7 @@ export function updateEmojiDataModel(custom_emoji_view: CustomEmojiView) {
skins: [{ src: custom_emoji_view.custom_emoji.image_url }],
};
const categoryIndex = customEmojis.findIndex(
x => x.id == custom_emoji_view.custom_emoji.category
x => x.id === custom_emoji_view.custom_emoji.category,
);
if (categoryIndex == -1) {
customEmojis.push({
@ -252,7 +252,7 @@ export function updateEmojiDataModel(custom_emoji_view: CustomEmojiView) {
});
} else {
const emojiIndex = customEmojis[categoryIndex].emojis.findIndex(
x => x.id == custom_emoji_view.custom_emoji.shortcode
x => x.id === custom_emoji_view.custom_emoji.shortcode,
);
if (emojiIndex == -1) {
customEmojis[categoryIndex].emojis.push(emoji);
@ -262,7 +262,7 @@ export function updateEmojiDataModel(custom_emoji_view: CustomEmojiView) {
}
customEmojisLookup.set(
custom_emoji_view.custom_emoji.shortcode,
custom_emoji_view
custom_emoji_view,
);
}
@ -276,10 +276,10 @@ export function removeFromEmojiDataModel(id: number) {
}
if (!view) return;
const categoryIndex = customEmojis.findIndex(
x => x.id == view?.custom_emoji.category
x => x.id === view?.custom_emoji.category,
);
const emojiIndex = customEmojis[categoryIndex].emojis.findIndex(
x => x.id == view?.custom_emoji.shortcode
x => x.id === view?.custom_emoji.shortcode,
);
customEmojis[categoryIndex].emojis = customEmojis[
categoryIndex
@ -290,7 +290,7 @@ export function removeFromEmojiDataModel(id: number) {
export function getEmojiMart(
onEmojiSelect: (e: any) => void,
customPickerOptions: any = {}
customPickerOptions: any = {},
) {
const pickerOptions = {
...customPickerOptions,
@ -314,10 +314,9 @@ export function setupTribute() {
return `${item.original.val} ${shortName}`;
},
selectTemplate: (item: any) => {
const customEmoji = customEmojisLookup.get(
item.original.key
)?.custom_emoji;
if (customEmoji == undefined) return `${item.original.val}`;
const customEmoji = customEmojisLookup.get(item.original.key)
?.custom_emoji;
if (customEmoji === undefined) return `${item.original.val}`;
else
return `![${customEmoji.alt_text}](${customEmoji.image_url} "${customEmoji.shortcode}")`;
},
@ -329,7 +328,7 @@ export function setupTribute() {
Array.from(customEmojisLookup.entries()).map(k => ({
key: k[0],
val: `<img class="icon icon-emoji" src="${k[1].custom_emoji.image_url}" title="${k[1].custom_emoji.shortcode}" alt="${k[1].custom_emoji.alt_text}" />`,
}))
})),
),
allowSpaces: false,
autocompleteMode: true,

View file

@ -49,7 +49,7 @@ class WrappedLemmyHttpClient {
this.#client = client;
for (const key of Object.getOwnPropertyNames(
Object.getPrototypeOf(this.#client)
Object.getPrototypeOf(this.#client),
)) {
if (key !== "constructor") {
WrappedLemmyHttpClient.prototype[key] = async (...args) => {
@ -80,7 +80,7 @@ export function wrapClient(client: LemmyHttp, silent = false) {
// unfortunately, this verbose cast is necessary
return new WrappedLemmyHttpClient(
client,
silent
silent,
) as unknown as WrappedLemmyHttp;
}

View file

@ -28,7 +28,7 @@ export function pictrsDeleteToast(filename: string, deleteUrl: string) {
"failed_to_delete_picture",
{
filename,
}
},
);
const backgroundColor = `var(--bs-light)`;

View file

@ -4,7 +4,7 @@ import { CommentNodeI } from "../../interfaces";
export default function buildCommentsTree(
comments: CommentView[],
parentComment: boolean
parentComment: boolean,
): CommentNodeI[] {
const map = new Map<number, CommentNodeI>();
const depthOffset = !parentComment

View file

@ -2,7 +2,7 @@ import { CommentView } from "lemmy-js-client";
import { CommentNodeI } from "../../interfaces";
export default function commentsToFlatNodes(
comments: CommentView[]
comments: CommentView[],
): CommentNodeI[] {
const nodes: CommentNodeI[] = [];
for (const comment of comments) {

View file

@ -3,7 +3,7 @@ import { hostname } from "@utils/helpers";
import { CommunityTribute } from "@utils/types";
export default async function communitySearch(
text: string
text: string,
): Promise<CommunityTribute[]> {
const communitiesResponse = await fetchCommunities(text);

View file

@ -1,7 +1,7 @@
import { CommentSortType, SortType } from "lemmy-js-client";
export default function convertCommentSortType(
sort: SortType
sort: SortType,
): CommentSortType {
switch (sort) {
case "TopAll":

View file

@ -3,7 +3,7 @@ import { CommentReplyView } from "lemmy-js-client";
export default function editCommentReply(
data: CommentReplyView,
replies: CommentReplyView[]
replies: CommentReplyView[],
): CommentReplyView[] {
return editListImmutable("comment_reply", data, replies);
}

View file

@ -3,7 +3,7 @@ import { CommentReportView } from "lemmy-js-client";
export default function editCommentReport(
data: CommentReportView,
reports: CommentReportView[]
reports: CommentReportView[],
): CommentReportView[] {
return editListImmutable("comment_report", data, reports);
}

View file

@ -3,7 +3,7 @@ import { CommentView } from "lemmy-js-client";
export default function editComment(
data: CommentView,
comments: CommentView[]
comments: CommentView[],
): CommentView[] {
return editListImmutable("comment", data, comments);
}

View file

@ -3,7 +3,7 @@ import { CommunityView } from "lemmy-js-client";
export default function editCommunity(
data: CommunityView,
communities: CommunityView[]
communities: CommunityView[],
): CommunityView[] {
return editListImmutable("community", data, communities);
}

View file

@ -3,7 +3,7 @@ import { PersonMentionView } from "lemmy-js-client";
export default function editMention(
data: PersonMentionView,
comments: PersonMentionView[]
comments: PersonMentionView[],
): PersonMentionView[] {
return editListImmutable("person_mention", data, comments);
}

View file

@ -3,7 +3,7 @@ import { PostReportView } from "lemmy-js-client";
export default function editPostReport(
data: PostReportView,
reports: PostReportView[]
reports: PostReportView[],
) {
return editListImmutable("post_report", data, reports);
}

View file

@ -3,7 +3,7 @@ import { PostView } from "lemmy-js-client";
export default function editPost(
data: PostView,
posts: PostView[]
posts: PostView[],
): PostView[] {
return editListImmutable("post", data, posts);
}

View file

@ -3,7 +3,7 @@ import { PrivateMessageReportView } from "lemmy-js-client";
export default function editPrivateMessageReport(
data: PrivateMessageReportView,
reports: PrivateMessageReportView[]
reports: PrivateMessageReportView[],
): PrivateMessageReportView[] {
return editListImmutable("private_message_report", data, reports);
}

View file

@ -3,7 +3,7 @@ import { PrivateMessageView } from "lemmy-js-client";
export default function editPrivateMessage(
data: PrivateMessageView,
messages: PrivateMessageView[]
messages: PrivateMessageView[],
): PrivateMessageView[] {
return editListImmutable("private_message", data, messages);
}

View file

@ -3,7 +3,7 @@ import { RegistrationApplicationView } from "lemmy-js-client";
export default function editRegistrationApplication(
data: RegistrationApplicationView,
apps: RegistrationApplicationView[]
apps: RegistrationApplicationView[],
): RegistrationApplicationView[] {
return editListImmutable("registration_application", data, apps);
}

View file

@ -2,13 +2,13 @@ import { WithComment } from "@utils/types";
export default function editWith<D extends WithComment, L extends WithComment>(
{ comment, counts, saved, my_vote }: D,
list: L[]
list: L[],
) {
return [
...list.map(c =>
c.comment.id === comment.id
? { ...c, comment, counts, saved, my_vote }
: c
: c,
),
];
}

View file

@ -1,7 +1,7 @@
import { Comment } from "lemmy-js-client";
export default function getCommentParentId(
comment?: Comment
comment?: Comment,
): number | undefined {
const split = comment?.path.split(".");
// remove the 0

View file

@ -1,7 +1,7 @@
import { Comment } from "lemmy-js-client";
export default function getDepthFromComment(
comment?: Comment
comment?: Comment,
): number | undefined {
const len = comment?.path.split(".").length;
return len ? len - 2 : undefined;

View file

@ -1,6 +1,6 @@
export default function getUpdatedSearchId(
id?: number | null,
urlId?: number | null
urlId?: number | null,
) {
return id === null
? undefined

View file

@ -5,7 +5,7 @@ import { CommentNodeI } from "../../interfaces";
export default function insertCommentIntoTree(
tree: CommentNodeI[],
cv: CommentView,
parentComment: boolean
parentComment: boolean,
) {
// Building a fake node to be used for later
const node: CommentNodeI = {

View file

@ -1,5 +1,5 @@
export default function isAuthPath(pathname: string) {
return /^\/(create_.*?|inbox|settings|admin|reports|registration_applications)\b/g.test(
pathname
pathname,
);
}

View file

@ -3,7 +3,7 @@ import { UserService } from "../../services";
export default function isPostBlocked(
pv: PostView,
myUserInfo: MyUserInfo | undefined = UserService.Instance.myUserInfo
myUserInfo: MyUserInfo | undefined = UserService.Instance.myUserInfo,
): boolean {
return (
(myUserInfo?.community_blocks

View file

@ -3,7 +3,7 @@ import { UserService } from "../../services";
export default function nsfwCheck(
pv: PostView,
myUserInfo = UserService.Instance.myUserInfo
myUserInfo = UserService.Instance.myUserInfo,
): boolean {
const nsfw = pv.post.nsfw || pv.community.nsfw;
const myShowNsfw = myUserInfo?.local_user_view.local_user.show_nsfw ?? false;

View file

@ -3,7 +3,7 @@ import { hostname } from "@utils/helpers";
import { PersonTribute } from "@utils/types";
export default async function personSearch(
text: string
text: string,
): Promise<PersonTribute[]> {
const usersResponse = await fetchUsers(text);

View file

@ -2,7 +2,7 @@ import { CommentNodeI } from "../../interfaces";
export default function searchCommentTree(
tree: CommentNodeI[],
id: number
id: number,
): CommentNodeI | undefined {
for (const node of tree) {
if (node.comment_view.comment.id === id) {

View file

@ -13,7 +13,7 @@ export default function selectableLanguages(
siteLanguages: number[],
showAll?: boolean,
showSite?: boolean,
myUserInfo = UserService.Instance.myUserInfo
myUserInfo = UserService.Instance.myUserInfo,
): Language[] {
const allLangIds = allLanguages.map(l => l.id);
let myLangs = myUserInfo?.discussion_languages ?? allLangIds;

View file

@ -2,7 +2,7 @@ import { isBrowser } from "@utils/browser";
import { IsoData, RouteData } from "../../interfaces";
export default function setIsoData<T extends RouteData>(
context: any
context: any,
): IsoData<T> {
// If its the browser, you need to deserialize the data from the window
if (isBrowser()) {

View file

@ -30,7 +30,7 @@ export default async function () {
).default;
} catch (e) {
console.log(
`Could not load locale ${lang} from date-fns, falling back to ${EN_US}`
`Could not load locale ${lang} from date-fns, falling back to ${EN_US}`,
);
locale = (
await import(

View file

@ -1,7 +1,7 @@
import { UserService } from "../../services";
export default function showAvatars(
myUserInfo = UserService.Instance.myUserInfo
myUserInfo = UserService.Instance.myUserInfo,
): boolean {
return myUserInfo?.local_user_view.local_user.show_avatars ?? true;
}

View file

@ -1,7 +1,7 @@
import { UserService } from "../../services";
export default function showScores(
myUserInfo = UserService.Instance.myUserInfo
myUserInfo = UserService.Instance.myUserInfo,
): boolean {
return myUserInfo?.local_user_view.local_user.show_scores ?? true;
}

View file

@ -4,7 +4,7 @@ import { toast } from "../../toast";
export default function updateCommunityBlock(
data: BlockCommunityResponse,
myUserInfo: MyUserInfo | undefined = UserService.Instance.myUserInfo
myUserInfo: MyUserInfo | undefined = UserService.Instance.myUserInfo,
) {
if (myUserInfo) {
if (data.blocked) {
@ -15,16 +15,16 @@ export default function updateCommunityBlock(
toast(
`${I18NextService.i18n.t("blocked")} ${
data.community_view.community.name
}`
}`,
);
} else {
myUserInfo.community_blocks = myUserInfo.community_blocks.filter(
i => i.community.id !== data.community_view.community.id
i => i.community.id !== data.community_view.community.id,
);
toast(
`${I18NextService.i18n.t("unblocked")} ${
data.community_view.community.name
}`
}`,
);
}
}

View file

@ -4,7 +4,7 @@ import { toast } from "../../toast";
export default function updatePersonBlock(
data: BlockPersonResponse,
myUserInfo: MyUserInfo | undefined = UserService.Instance.myUserInfo
myUserInfo: MyUserInfo | undefined = UserService.Instance.myUserInfo,
) {
if (myUserInfo) {
if (data.blocked) {
@ -13,14 +13,14 @@ export default function updatePersonBlock(
target: data.person_view.person,
});
toast(
`${I18NextService.i18n.t("blocked")} ${data.person_view.person.name}`
`${I18NextService.i18n.t("blocked")} ${data.person_view.person.name}`,
);
} else {
myUserInfo.person_blocks = myUserInfo.person_blocks.filter(
i => i.target.id !== data.person_view.person.id
i => i.target.id !== data.person_view.person.id,
);
toast(
`${I18NextService.i18n.t("unblocked")} ${data.person_view.person.name}`
`${I18NextService.i18n.t("unblocked")} ${data.person_view.person.name}`,
);
}
}

View file

@ -4,6 +4,6 @@ import { getExternalHost, getSecure } from "@utils/env";
export default function httpExternalPath(path: string) {
return `http${getSecure()}://${getExternalHost().replace(
/:\d+/g,
""
"",
)}${path}`;
}

View file

@ -1,7 +1,7 @@
export default function debounce<T extends any[], R>(
func: (...e: T) => R,
wait = 1000,
immediate = false
immediate = false,
) {
let timeout: NodeJS.Timeout | null;

View file

@ -12,7 +12,7 @@ type ImmutableListKey =
export default function editListImmutable<
T extends { [key in F]: { id: number } },
F extends ImmutableListKey
F extends ImmutableListKey,
>(fieldName: F, data: T, list: T[]): T[] {
return [
...list.map(c => (c[fieldName].id === data[fieldName].id ? data : c)),

View file

@ -1,9 +1,9 @@
export default function futureDaysToUnixTime(
days?: number
days?: number,
): number | undefined {
return days
? Math.trunc(
new Date(Date.now() + 1000 * 60 * 60 * 24 * days).getTime() / 1000
new Date(Date.now() + 1000 * 60 * 60 * 24 * days).getTime() / 1000,
)
: undefined;
}

View file

@ -1,7 +1,7 @@
import { isBrowser } from "@utils/browser";
export default function getQueryParams<
T extends Record<string, any>
T extends Record<string, any>,
>(processors: {
[K in keyof T]: (param: string) => T[K];
}): T {
@ -13,7 +13,7 @@ export default function getQueryParams<
...acc,
[key]: process(searchParams.get(key)),
}),
{} as T
{} as T,
);
}

View file

@ -1,10 +1,10 @@
export default function getQueryString<
T extends Record<string, string | undefined>
T extends Record<string, string | undefined>,
>(obj: T) {
return Object.entries(obj)
.filter(([, val]) => val !== undefined && val !== null)
.reduce(
(acc, [key, val], index) => `${acc}${index > 0 ? "&" : ""}${key}=${val}`,
"?"
"?",
);
}

View file

@ -1,8 +1,11 @@
export const groupBy = <T>(
array: T[],
predicate: (value: T, index: number, array: T[]) => string
predicate: (value: T, index: number, array: T[]) => string,
) =>
array.reduce((acc, value, index, array) => {
(acc[predicate(value, index, array)] ||= []).push(value);
return acc;
}, {} as { [key: string]: T[] });
array.reduce(
(acc, value, index, array) => {
(acc[predicate(value, index, array)] ||= []).push(value);
return acc;
},
{} as { [key: string]: T[] },
);

View file

@ -5,7 +5,7 @@ const DEFAULT_ALPHABET =
export default function randomStr(
idDesiredLength = 20,
alphabet = DEFAULT_ALPHABET
alphabet = DEFAULT_ALPHABET,
): string {
/**
* Create n-long array and map it to random chars from given alphabet.

View file

@ -1,7 +1,7 @@
import { UserService } from "../../services";
export default function amAdmin(
myUserInfo = UserService.Instance.myUserInfo
myUserInfo = UserService.Instance.myUserInfo,
): boolean {
return myUserInfo?.local_user_view.person.admin ?? false;
}

View file

@ -4,7 +4,7 @@ import { UserService } from "../../services";
export default function amCommunityCreator(
creator_id: number,
mods?: CommunityModeratorView[],
myUserInfo = UserService.Instance.myUserInfo
myUserInfo = UserService.Instance.myUserInfo,
): boolean {
const myId = myUserInfo?.local_user_view.person.id;
// Don't allow mod actions on yourself

View file

@ -4,7 +4,7 @@ import { UserService } from "../../services";
export default function amMod(
mods?: CommunityModeratorView[],
myUserInfo = UserService.Instance.myUserInfo
myUserInfo = UserService.Instance.myUserInfo,
): boolean {
return myUserInfo ? isMod(myUserInfo.local_user_view.person.id, mods) : false;
}

Some files were not shown because too many files have changed in this diff Show more