From 88a67e4e850c713dbc86aa92f8ee9f7216f98ba5 Mon Sep 17 00:00:00 2001 From: DrMint <29893320+DrMint@users.noreply.github.com> Date: Wed, 22 Feb 2023 06:19:29 +0100 Subject: [PATCH] Small fixes --- src/components/Cli/Terminal.tsx | 11 +++++++---- src/components/Panels/SettingsPopup.tsx | 7 ++++++- src/components/PostPage.tsx | 26 +++++++++++-------------- src/components/PreviewCard.tsx | 4 ++-- src/contexts/atoms.ts | 11 ----------- src/pages/archives/videos/c/[uid].tsx | 4 +++- src/pages/archives/videos/index.tsx | 4 +++- src/pages/contents/all.tsx | 4 +++- src/pages/library/[slug]/index.tsx | 2 +- src/pages/library/index.tsx | 4 +++- 10 files changed, 39 insertions(+), 38 deletions(-) diff --git a/src/components/Cli/Terminal.tsx b/src/components/Cli/Terminal.tsx index 5a91c09..88b4f1c 100644 --- a/src/components/Cli/Terminal.tsx +++ b/src/components/Cli/Terminal.tsx @@ -1,9 +1,10 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { useRouter } from "next/router"; +import { atom } from "jotai"; import { cJoin, cIf } from "helpers/className"; import { isDefined, isDefinedAndNotEmpty } from "helpers/asserts"; import { atoms } from "contexts/atoms"; -import { useAtomSetter, useAtomPair } from "helpers/atoms"; +import { useAtomSetter, useAtomPair, atomPairing } from "helpers/atoms"; /* * ╭─────────────╮ @@ -12,6 +13,9 @@ import { useAtomSetter, useAtomPair } from "helpers/atoms"; const LINE_PREFIX = "root@accords-library.com:"; +const previousLinesAtom = atomPairing(atom([])); +const previousCommandsAtom = atomPairing(atom([])); + /* * ╭─────────────╮ * ───────────────────────────────────────╯ COMPONENT ╰─────────────────────────────────────────── @@ -33,8 +37,8 @@ export const Terminal = ({ const [childrenPaths, setChildrenPaths] = useState(propsChildrenPaths); const setPlayerName = useAtomSetter(atoms.settings.playerName); - const [previousCommands, setPreviousCommands] = useAtomPair(atoms.terminal.previousCommands); - const [previousLines, setPreviousLines] = useAtomPair(atoms.terminal.previousLines); + const [previousCommands, setPreviousCommands] = useAtomPair(previousCommandsAtom); + const [previousLines, setPreviousLines] = useAtomPair(previousLinesAtom); const [line, setLine] = useState(""); const [displayCurrentLine, setDisplayCurrentLine] = useState(true); @@ -112,7 +116,6 @@ export const Terminal = ({ key: "rm", description: "Remove files or directories", handle: (currentLine, parameters) => { - console.log(parameters); if (parameters.startsWith("-r ")) { const folder = parameters.slice("-r ".length); if (childrenPaths.includes(folder)) { diff --git a/src/components/Panels/SettingsPopup.tsx b/src/components/Panels/SettingsPopup.tsx index 80cd31b..015fe08 100644 --- a/src/components/Panels/SettingsPopup.tsx +++ b/src/components/Panels/SettingsPopup.tsx @@ -17,6 +17,11 @@ import { Ico } from "components/Ico"; import { useFormat } from "hooks/useFormat"; import { ToolTip } from "components/ToolTip"; +/* + * ╭─────────────╮ + * ───────────────────────────────────────╯ COMPONENT ╰─────────────────────────────────────────── + */ + export const SettingsPopup = (): JSX.Element => { const [preferredLanguages, setPreferredLanguages] = useAtomPair( atoms.settings.preferredLanguages @@ -142,7 +147,7 @@ export const SettingsPopup = (): JSX.Element => { const newCurrencyName = currencyOptions[newCurrency]; if (isDefined(newCurrencyName)) { setCurrency(newCurrencyName); - sendAnalytics("Settings", `Change currency (${currencyOptions[newCurrency]})}`); + sendAnalytics("Settings", `Change currency (${currencyOptions[newCurrency]})`); } }} className="w-28" diff --git a/src/components/PostPage.tsx b/src/components/PostPage.tsx index 8999de7..e00f9d1 100644 --- a/src/components/PostPage.tsx +++ b/src/components/PostPage.tsx @@ -1,7 +1,6 @@ import { Fragment, useCallback } from "react"; import { AppLayout, AppLayoutRequired } from "./AppLayout"; import { Chip } from "./Chip"; -import { HorizontalLine } from "./HorizontalLine"; import { getTocFromMarkdawn, Markdawn, TableOfContents } from "./Markdown/Markdawn"; import { ReturnButton } from "./PanelComponents/ReturnButton"; import { ContentPanel } from "./Containers/ContentPanel"; @@ -132,20 +131,17 @@ export const PostPage = ({ )} {displayThumbnailHeader ? ( - <> - 1 ? ( - - ) : undefined - } - /> - {(isDefined(prependBody) || isDefined(body)) && } - + 1 ? ( + + ) : undefined + } + /> ) : ( <> {displayLanguageSwitcher && ( diff --git a/src/components/PreviewCard.tsx b/src/components/PreviewCard.tsx index 5b7708d..822c472 100644 --- a/src/components/PreviewCard.tsx +++ b/src/components/PreviewCard.tsx @@ -174,14 +174,14 @@ export const PreviewCard = ({ )}
{metadata?.position === "Top" && metadataJSX} diff --git a/src/contexts/atoms.ts b/src/contexts/atoms.ts index 79a5f47..db66009 100644 --- a/src/contexts/atoms.ts +++ b/src/contexts/atoms.ts @@ -53,20 +53,9 @@ const layout = { terminalMode, }; -/* [ TERMINAL ATOMS ] */ - -const previousLines = atomPairing(atom([])); -const previousCommands = atomPairing(atom([])); - -const terminal = { - previousLines, - previousCommands, -}; - export const atoms = { settings, layout, - terminal, localData, lightBox, containerQueries, diff --git a/src/pages/archives/videos/c/[uid].tsx b/src/pages/archives/videos/c/[uid].tsx index d1885a2..5eb9074 100644 --- a/src/pages/archives/videos/c/[uid].tsx +++ b/src/pages/archives/videos/c/[uid].tsx @@ -191,7 +191,9 @@ const Channel = ({ channel, ...otherProps }: Props): JSX.Element => { setSortingMethod(newSort); sendAnalytics( "Videos", - `Change sorting method (${sortingMethods.map((item) => item.displayedName)[newSort]})` + `Change sorting method (${ + sortingMethods.map((item) => item.meiliAttribute)[newSort] + })` ); }} /> diff --git a/src/pages/archives/videos/index.tsx b/src/pages/archives/videos/index.tsx index 3c85165..bbdea5f 100644 --- a/src/pages/archives/videos/index.tsx +++ b/src/pages/archives/videos/index.tsx @@ -183,7 +183,9 @@ const Videos = ({ ...otherProps }: Props): JSX.Element => { setSortingMethod(newSort); sendAnalytics( "Videos", - `Change sorting method (${sortingMethods.map((item) => item.displayedName)[newSort]})` + `Change sorting method (${ + sortingMethods.map((item) => item.meiliAttribute)[newSort] + })` ); }} /> diff --git a/src/pages/contents/all.tsx b/src/pages/contents/all.tsx index b7796b9..b8a7849 100644 --- a/src/pages/contents/all.tsx +++ b/src/pages/contents/all.tsx @@ -173,7 +173,9 @@ const Contents = (props: Props): JSX.Element => { setSortingMethod(newSort); sendAnalytics( "Contents/All", - `Change sorting method (${sortingMethods.map((item) => item.displayedName)[newSort]})` + `Change sorting method (${ + sortingMethods.map((item) => item.meiliAttribute)[newSort] + })` ); }} /> diff --git a/src/pages/library/[slug]/index.tsx b/src/pages/library/[slug]/index.tsx index 1fdb080..6bc3957 100644 --- a/src/pages/library/[slug]/index.tsx +++ b/src/pages/library/[slug]/index.tsx @@ -88,7 +88,7 @@ const LibrarySlug = ({ item, itemId, ...otherProps }: Props): JSX.Element => { const setSubPanelOpened = useAtomSetter(atoms.layout.subPanelOpened); const closeSubPanel = useCallback(() => setSubPanelOpened(false), [setSubPanelOpened]); - useScrollTopOnChange(Ids.ContentPanel, [item]); + useScrollTopOnChange(Ids.ContentPanel, [itemId]); const currentIntersection = useIntersectionList(intersectionIds); const isVariantSet = diff --git a/src/pages/library/index.tsx b/src/pages/library/index.tsx index 42ba853..3bd32eb 100644 --- a/src/pages/library/index.tsx +++ b/src/pages/library/index.tsx @@ -279,7 +279,9 @@ const Library = (props: Props): JSX.Element => { setSortingMethod(newSort); sendAnalytics( "Library", - `Change sorting method (${sortingMethods.map((item) => item.displayedName)[newSort]})` + `Change sorting method (${ + sortingMethods.map((item) => item.meiliAttribute)[newSort] + })` ); }} />