From 6754c08902e5fd3925413085b6c0d0d83722eb78 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 1 Aug 2024 09:12:04 -0400 Subject: [PATCH] Fixing --- src/server/utils/create-ssr-html.tsx | 2 +- src/server/utils/generate-manifest-json.ts | 2 +- src/shared/components/common/emoji-picker.tsx | 14 +++++++++----- src/shared/components/common/markdown-textarea.tsx | 2 +- src/shared/components/home/login.tsx | 12 +++++++----- src/shared/markdown.ts | 8 +------- src/shared/services/UserService.ts | 4 +++- src/shared/utils/helpers/format-past-date.ts | 2 +- 8 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/server/utils/create-ssr-html.tsx b/src/server/utils/create-ssr-html.tsx index e69eff76..2381b009 100644 --- a/src/server/utils/create-ssr-html.tsx +++ b/src/server/utils/create-ssr-html.tsx @@ -50,7 +50,7 @@ export async function createSsrHtml( .toBuffer() .then(buf => buf.toString("base64"))}` : favIconPngUrl; - } catch (e) { + } catch { console.log( "Could not fetch site logo for apple touch icon. Using default icon.", ); diff --git a/src/server/utils/generate-manifest-json.ts b/src/server/utils/generate-manifest-json.ts index 2bdf6724..3a959377 100644 --- a/src/server/utils/generate-manifest-json.ts +++ b/src/server/utils/generate-manifest-json.ts @@ -42,7 +42,7 @@ export default async function (site: Site) { } else { icons = generateDefaultIcons(); } - } catch (e) { + } catch { console.log( `Failed to fetch site logo for manifest icon. Using default icon`, ); diff --git a/src/shared/components/common/emoji-picker.tsx b/src/shared/components/common/emoji-picker.tsx index ab061071..2c35b063 100644 --- a/src/shared/components/common/emoji-picker.tsx +++ b/src/shared/components/common/emoji-picker.tsx @@ -13,8 +13,10 @@ interface EmojiPickerState { showPicker: boolean; } -function closeEmojiMartOnEsc(i, event): void { - event.key === "Escape" && i.setState({ showPicker: false }); +function closeEmojiMartOnEsc(i: EmojiPicker, event: KeyboardEvent): void { + if (event.key === "Escape") { + i.setState({ showPicker: false }); + } } @tippyMixin @@ -72,9 +74,11 @@ export class EmojiPicker extends Component { e.preventDefault(); i.setState({ showPicker: !i.state.showPicker }); - i.state.showPicker - ? document.addEventListener("keyup", e => closeEmojiMartOnEsc(i, e)) - : document.removeEventListener("keyup", e => closeEmojiMartOnEsc(i, e)); + if (i.state.showPicker) { + document.addEventListener("keyup", e => closeEmojiMartOnEsc(i, e)); + } else { + document.removeEventListener("keyup", e => closeEmojiMartOnEsc(i, e)); + } } handleEmojiClick(e: any) { diff --git a/src/shared/components/common/markdown-textarea.tsx b/src/shared/components/common/markdown-textarea.tsx index 3be18ff0..6e5e2f2e 100644 --- a/src/shared/components/common/markdown-textarea.tsx +++ b/src/shared/components/common/markdown-textarea.tsx @@ -451,7 +451,7 @@ export class MarkdownTextArea extends Component< })); }), ); - } catch (e) { + } catch { errorOccurred = true; } } diff --git a/src/shared/components/home/login.tsx b/src/shared/components/home/login.tsx index 4a7723d8..d4dc9e97 100644 --- a/src/shared/components/home/login.tsx +++ b/src/shared/components/home/login.tsx @@ -57,11 +57,13 @@ async function handleLoginSuccess(i: Login, loginRes: LoginResponse) { const { prev } = i.props; - prev - ? i.props.history.replace(prev) - : i.props.history.action === "PUSH" - ? i.props.history.back() - : i.props.history.replace("/"); + if (prev) { + i.props.history.replace(prev); + } else if (i.props.history.action === "PUSH") { + i.props.history.back(); + } else { + i.props.history.replace("/"); + } UnreadCounterService.Instance.updateAll(); } diff --git a/src/shared/markdown.ts b/src/shared/markdown.ts index 9e510bfc..fa293609 100644 --- a/src/shared/markdown.ts +++ b/src/shared/markdown.ts @@ -1,5 +1,4 @@ import { communitySearch, personSearch } from "@utils/app"; -import { isBrowser } from "@utils/browser"; import { debounce, groupBy } from "@utils/helpers"; import { CommunityTribute, PersonTribute } from "@utils/types"; import { Picker } from "emoji-mart"; @@ -18,8 +17,7 @@ import markdown_it_highlightjs from "markdown-it-highlightjs/core"; import { Renderer, Token } from "markdown-it"; import { instanceLinkRegex, relTags } from "./config"; import { lazyHighlightjs } from "./lazy-highlightjs"; - -export let Tribute: any; +import Tribute from "tributejs"; export let md: MarkdownIt = new MarkdownIt(); @@ -40,10 +38,6 @@ export let customEmojisLookup: Map = new Map< CustomEmojiView >(); -if (isBrowser()) { - Tribute = require("tributejs"); -} - export function mdToHtml(text: string, rerender: () => void) { return { __html: lazyHighlightjs.render(md, text, rerender) }; } diff --git a/src/shared/services/UserService.ts b/src/shared/services/UserService.ts index 856fca8a..165bf03f 100644 --- a/src/shared/services/UserService.ts +++ b/src/shared/services/UserService.ts @@ -37,7 +37,9 @@ export class UserService { showToast?: boolean; }) { if (isBrowser() && res.jwt) { - showToast && toast(I18NextService.i18n.t("logged_in")); + if (showToast) { + toast(I18NextService.i18n.t("logged_in")); + } setAuthCookie(res.jwt); this.#setAuthInfo(); } diff --git a/src/shared/utils/helpers/format-past-date.ts b/src/shared/utils/helpers/format-past-date.ts index fc544956..5ba17b89 100644 --- a/src/shared/utils/helpers/format-past-date.ts +++ b/src/shared/utils/helpers/format-past-date.ts @@ -6,7 +6,7 @@ export default function (dateString?: string) { return formatDistanceStrict(parsed, new Date(), { addSuffix: true, }); - } catch (e) { + } catch { return "indeterminate"; } }