Refactor lets to consts

This commit is contained in:
James Whitmarsh 2023-06-05 22:31:12 +01:00
parent 400e62b21c
commit 0754b9ba19
50 changed files with 734 additions and 727 deletions

View file

@ -85,7 +85,7 @@ export class MarkdownTextArea extends Component<
}
componentDidMount() {
let textarea: any = document.getElementById(this.id);
const textarea: any = document.getElementById(this.id);
if (textarea) {
autosize(textarea);
this.tribute.attach(textarea);
@ -132,7 +132,7 @@ export class MarkdownTextArea extends Component<
}
render() {
let languageId = this.state.languageId;
const languageId = this.state.languageId;
return (
<form id={this.formId} onSubmit={linkEvent(this, this.handleSubmit)}>
@ -321,7 +321,7 @@ export class MarkdownTextArea extends Component<
handleEmoji(i: MarkdownTextArea, e: any) {
let value = e.native;
if (value == null) {
let emoji = customEmojisLookup.get(e.id)?.custom_emoji;
const emoji = customEmojisLookup.get(e.id)?.custom_emoji;
if (emoji) {
value = `![${emoji.alt_text}](${emoji.image_url} "${emoji.shortcode}")`;
}
@ -330,7 +330,7 @@ export class MarkdownTextArea extends Component<
content: `${i.state.content ?? ""} ${value} `,
});
i.contentChange();
let textarea: any = document.getElementById(i.id);
const textarea: any = document.getElementById(i.id);
autosize.update(textarea);
}
@ -420,7 +420,7 @@ export class MarkdownTextArea extends Component<
contentChange() {
// Coerces the undefineds to empty strings, for replacing in the DB
let content = this.state.content ?? "";
const content = this.state.content ?? "";
this.props.onContentChange?.(content);
}
@ -441,7 +441,7 @@ export class MarkdownTextArea extends Component<
handleSubmit(i: MarkdownTextArea, event: any) {
event.preventDefault();
i.setState({ loading: true });
let msg = {
const msg = {
val: i.state.content,
formId: i.formId,
languageId: i.state.languageId,
@ -589,7 +589,7 @@ export class MarkdownTextArea extends Component<
}
simpleInsert(chars: string) {
let content = this.state.content;
const content = this.state.content;
if (!content) {
this.setState({ content: `${chars} ` });
} else {
@ -598,7 +598,7 @@ export class MarkdownTextArea extends Component<
});
}
let textarea: any = document.getElementById(this.id);
const textarea: any = document.getElementById(this.id);
textarea.focus();
setTimeout(() => {
autosize.update(textarea);
@ -608,8 +608,8 @@ export class MarkdownTextArea extends Component<
handleInsertSpoiler(i: MarkdownTextArea, event: any) {
event.preventDefault();
let beforeChars = `\n::: spoiler ${i18n.t("spoiler")}\n`;
let afterChars = "\n:::\n";
const beforeChars = `\n::: spoiler ${i18n.t("spoiler")}\n`;
const afterChars = "\n:::\n";
i.simpleSurroundBeforeAfter(beforeChars, afterChars);
}