diff --git a/src/components/AppLayout.tsx b/src/components/AppLayout.tsx index 2226e2b..b5e208b 100644 --- a/src/components/AppLayout.tsx +++ b/src/components/AppLayout.tsx @@ -46,11 +46,13 @@ export function AppLayout(props: Immutable): JSX.Element { const sensibilitySwipe = 1.1; useMemo(() => { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition router.events?.on("routeChangeStart", () => { appLayout.setConfigPanelOpen(false); appLayout.setMainPanelOpen(false); appLayout.setSubPanelOpen(false); }); + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition router.events?.on("hashChangeStart", () => { appLayout.setSubPanelOpen(false); }); @@ -425,7 +427,9 @@ export function AppLayout(props: Immutable): JSX.Element { ) } > - text_decrease + + text_decrease + diff --git a/src/components/Inputs/LanguageSwitcher.tsx b/src/components/Inputs/LanguageSwitcher.tsx index 307215c..b1abbe4 100644 --- a/src/components/Inputs/LanguageSwitcher.tsx +++ b/src/components/Inputs/LanguageSwitcher.tsx @@ -1,7 +1,7 @@ import { AppStaticProps } from "graphql/getAppStaticProps"; import { prettyLanguage } from "helpers/formatters"; import { Immutable } from "helpers/types"; -import { Dispatch, SetStateAction } from "react"; +import { Dispatch, Fragment, SetStateAction } from "react"; import { ToolTip } from "../ToolTip"; import { Button } from "./Button"; @@ -21,17 +21,16 @@ export function LanguageSwitcher(props: Immutable): JSX.Element { content={
{[...locales].map(([locale, value], index) => ( - <> + {locale && ( )} - + ))}
} diff --git a/src/components/Inputs/OrderableList.tsx b/src/components/Inputs/OrderableList.tsx index e013d50..040b4a5 100644 --- a/src/components/Inputs/OrderableList.tsx +++ b/src/components/Inputs/OrderableList.tsx @@ -1,6 +1,6 @@ import { arrayMove } from "helpers/others"; import { Immutable } from "helpers/types"; -import { useEffect, useState } from "react"; +import { Fragment, useEffect, useState } from "react"; interface Props { className?: string; @@ -25,7 +25,7 @@ export function OrderableList(props: Immutable): JSX.Element { return (
{[...items].map(([key, value], index) => ( - <> + {props.insertLabels?.get(index) && (

{props.insertLabels.get(index)}

)} @@ -60,7 +60,6 @@ export function OrderableList(props: Immutable): JSX.Element { border-[1px] transition-all hover:text-light hover:bg-dark hover:drop-shadow-shade-lg border-dark bg-light text-dark rounded-full cursor-grab select-none px-1 py-2 pr-4 gap-2" - key={key} draggable >
@@ -87,7 +86,7 @@ export function OrderableList(props: Immutable): JSX.Element {
{value}
- + ))} ); diff --git a/src/components/Inputs/Select.tsx b/src/components/Inputs/Select.tsx index fd379cc..2119df8 100644 --- a/src/components/Inputs/Select.tsx +++ b/src/components/Inputs/Select.tsx @@ -1,5 +1,5 @@ import { Immutable } from "helpers/types"; -import { Dispatch, SetStateAction, useState } from "react"; +import { Dispatch, Fragment, SetStateAction, useState } from "react"; interface Props { setState: Dispatch>; @@ -47,12 +47,12 @@ export function Select(props: Immutable): JSX.Element { }`} > {props.options.map((option, index) => ( - <> + {index !== props.state && (
{ setOpened(false); @@ -62,7 +62,7 @@ export function Select(props: Immutable): JSX.Element { {option}
)} - +
))} diff --git a/src/components/Inputs/Switch.tsx b/src/components/Inputs/Switch.tsx index be1d2c7..0073d13 100644 --- a/src/components/Inputs/Switch.tsx +++ b/src/components/Inputs/Switch.tsx @@ -5,23 +5,25 @@ interface Props { setState: Dispatch>; state: boolean; className?: string; + disabled?: boolean; } export function Switch(props: Immutable): JSX.Element { + const { state, setState, className, disabled } = props; return (
{ - props.setState(!props.state); + if (!disabled) setState(!state); }} >
diff --git a/src/components/Library/ScanSet.tsx b/src/components/Library/ScanSet.tsx index 777c3aa..6e540aa 100644 --- a/src/components/Library/ScanSet.tsx +++ b/src/components/Library/ScanSet.tsx @@ -10,6 +10,7 @@ import { isInteger } from "helpers/numbers"; import { getStatusDescription } from "helpers/others"; import { Immutable } from "helpers/types"; import { useSmartLanguage } from "hooks/useSmartLanguage"; +import { Fragment } from "react"; interface Props { openLightBox: (images: string[], index?: number) => void; @@ -121,15 +122,14 @@ export function ScanSet(props: Immutable): JSX.Element {

{"Scanners"}:

{selectedScan.scanners.data.map((scanner) => ( - <> + {scanner.attributes && ( )} - + ))}
@@ -140,15 +140,14 @@ export function ScanSet(props: Immutable): JSX.Element {

{"Cleaners"}:

{selectedScan.cleaners.data.map((cleaner) => ( - <> + {cleaner.attributes && ( )} - + ))}
@@ -160,15 +159,14 @@ export function ScanSet(props: Immutable): JSX.Element {

{"Typesetters"}:

{selectedScan.typesetters.data.map((typesetter) => ( - <> + {typesetter.attributes && ( )} - + ))}
diff --git a/src/components/Library/ScanSetCover.tsx b/src/components/Library/ScanSetCover.tsx index e15238b..593b001 100644 --- a/src/components/Library/ScanSetCover.tsx +++ b/src/components/Library/ScanSetCover.tsx @@ -11,6 +11,7 @@ import { getAssetURL, ImageQuality } from "helpers/img"; import { getStatusDescription } from "helpers/others"; import { Immutable } from "helpers/types"; import { useSmartLanguage } from "hooks/useSmartLanguage"; +import { Fragment } from "react"; interface Props { openLightBox: (images: string[], index?: number) => void; @@ -87,15 +88,14 @@ export function ScanSetCover(props: Immutable): JSX.Element {

{"Scanners"}:

{selectedScan.scanners.data.map((scanner) => ( - <> + {scanner.attributes && ( )} - + ))}
@@ -106,15 +106,14 @@ export function ScanSetCover(props: Immutable): JSX.Element {

{"Cleaners"}:

{selectedScan.cleaners.data.map((cleaner) => ( - <> + {cleaner.attributes && ( )} - + ))}
@@ -126,15 +125,14 @@ export function ScanSetCover(props: Immutable): JSX.Element {

{"Typesetters"}:

{selectedScan.typesetters.data.map((typesetter) => ( - <> + {typesetter.attributes && ( )} - + ))}
diff --git a/src/components/Markdown/TOC.tsx b/src/components/Markdown/TOC.tsx index 4d14b64..3a0bea8 100644 --- a/src/components/Markdown/TOC.tsx +++ b/src/components/Markdown/TOC.tsx @@ -1,6 +1,7 @@ import { slugify } from "helpers/formatters"; import { Immutable } from "helpers/types"; import { useRouter } from "next/router"; +import { Fragment } from "react"; import { preprocessMarkDawn } from "./Markdawn"; interface Props { @@ -39,11 +40,8 @@ function TOCLevel(props: LevelProps): JSX.Element { return (
    {tocchildren.map((child, childIndex) => ( - <> -
  1. + +
  2. {`${parentNumbering}${ childIndex + 1 }.`}{" "} @@ -55,7 +53,7 @@ function TOCLevel(props: LevelProps): JSX.Element { tocchildren={child.children} parentNumbering={`${parentNumbering}${childIndex + 1}.`} /> - + ))}
); diff --git a/src/components/PostPage.tsx b/src/components/PostPage.tsx index 5402d58..f9f6a45 100644 --- a/src/components/PostPage.tsx +++ b/src/components/PostPage.tsx @@ -3,6 +3,7 @@ import { prettySlug } from "helpers/formatters"; import { getStatusDescription } from "helpers/others"; import { Immutable, PostWithTranslations } from "helpers/types"; import { useSmartLanguage } from "hooks/useSmartLanguage"; +import { Fragment } from "react"; import { AppLayout } from "./AppLayout"; import { Chip } from "./Chip"; import { HorizontalLine } from "./HorizontalLine"; @@ -97,15 +98,14 @@ export function PostPage(props: Immutable): JSX.Element {

{"Authors"}:

{post.authors.data.map((author) => ( - <> + {author.attributes && ( )} - + ))}
diff --git a/src/components/RecorderChip.tsx b/src/components/RecorderChip.tsx index de7c824..9fa4690 100644 --- a/src/components/RecorderChip.tsx +++ b/src/components/RecorderChip.tsx @@ -3,6 +3,7 @@ import { RecorderChipFragment } from "graphql/generated"; import { AppStaticProps } from "graphql/getAppStaticProps"; import { ImageQuality } from "helpers/img"; import { Immutable } from "helpers/types"; +import { Fragment } from "react"; import { Img } from "./Img"; import { Markdawn } from "./Markdown/Markdawn"; import { ToolTip } from "./ToolTip"; @@ -33,13 +34,11 @@ export function RecorderChip(props: Immutable): JSX.Element {

{langui.languages}:

{recorder.languages.data.map((language) => ( - <> + {language.attributes && ( - - {language.attributes.code.toUpperCase()} - + {language.attributes.code.toUpperCase()} )} - + ))}
)} diff --git a/src/components/Wiki/Chronology/ChronologyItemComponent.tsx b/src/components/Wiki/Chronology/ChronologyItemComponent.tsx index 7f5c4c0..7e0143d 100644 --- a/src/components/Wiki/Chronology/ChronologyItemComponent.tsx +++ b/src/components/Wiki/Chronology/ChronologyItemComponent.tsx @@ -7,6 +7,7 @@ import { import { AppStaticProps } from "graphql/getAppStaticProps"; import { getStatusDescription } from "helpers/others"; import { Immutable } from "helpers/types"; +import { Fragment } from "react"; interface Props { item: NonNullable["data"][number]; @@ -92,13 +93,13 @@ export function ChronologyItemComponent(props: Immutable): JSX.Element {
{props.item.attributes.events?.map((event) => ( - <> + {event && ( -
- {event.translations?.map((translation) => ( - <> +
+ {event.translations?.map((translation, translationIndex) => ( + {translation && ( - <> +
): JSX.Element { ) : ( "" )} - + )} - + ))}

@@ -157,7 +158,7 @@ export function ChronologyItemComponent(props: Immutable): JSX.Element {

)} - +
))}
diff --git a/src/pages/archives/videos/c/[uid].tsx b/src/pages/archives/videos/c/[uid].tsx index 430989b..a2547dd 100644 --- a/src/pages/archives/videos/c/[uid].tsx +++ b/src/pages/archives/videos/c/[uid].tsx @@ -20,7 +20,7 @@ import { GetStaticPathsResult, GetStaticPropsContext, } from "next"; -import { useState } from "react"; +import { Fragment, useState } from "react"; interface Props extends AppStaticProps { channel: NonNullable< @@ -67,10 +67,9 @@ export default function Channel(props: Props): JSX.Element { pb-12 border-b-[3px] border-dotted last-of-type:border-0" > {channel?.videos?.data.map((video) => ( - <> + {video.attributes && ( )} - + ))}
diff --git a/src/pages/archives/videos/index.tsx b/src/pages/archives/videos/index.tsx index 273e5c5..ddfaa57 100644 --- a/src/pages/archives/videos/index.tsx +++ b/src/pages/archives/videos/index.tsx @@ -18,7 +18,7 @@ import { getReadySdk } from "graphql/sdk"; import { prettyDate } from "helpers/formatters"; import { getVideoThumbnailURL } from "helpers/videos"; import { GetStaticPropsContext } from "next"; -import { useState } from "react"; +import { Fragment, useState } from "react"; interface Props extends AppStaticProps { videos: NonNullable["data"]; @@ -88,10 +88,9 @@ export default function Videos(props: Props): JSX.Element { pb-12 border-b-[3px] border-dotted last-of-type:border-0" > {paginatedVideos[page].map((video) => ( - <> + {video.attributes && ( )} - + ))} diff --git a/src/pages/contents/[slug]/index.tsx b/src/pages/contents/[slug]/index.tsx index 76b4e93..9e49c6f 100644 --- a/src/pages/contents/[slug]/index.tsx +++ b/src/pages/contents/[slug]/index.tsx @@ -31,6 +31,7 @@ import { GetStaticPathsResult, GetStaticPropsContext, } from "next"; +import { Fragment } from "react"; interface Props extends AppStaticProps { content: ContentWithTranslations; @@ -116,15 +117,14 @@ export default function Content(props: Immutable): JSX.Element {
{selectedTranslation.text_set.transcribers.data.map( (recorder) => ( - <> + {recorder.attributes && ( )} - + ) )}
@@ -138,15 +138,14 @@ export default function Content(props: Immutable): JSX.Element {
{selectedTranslation.text_set.translators.data.map( (recorder) => ( - <> + {recorder.attributes && ( )} - + ) )}
@@ -160,15 +159,14 @@ export default function Content(props: Immutable): JSX.Element {
{selectedTranslation.text_set.proofreaders.data.map( (recorder) => ( - <> + {recorder.attributes && ( )} - + ) )}
diff --git a/src/pages/contents/index.tsx b/src/pages/contents/index.tsx index 16ad774..180ebce 100644 --- a/src/pages/contents/index.tsx +++ b/src/pages/contents/index.tsx @@ -15,7 +15,7 @@ import { getReadySdk } from "graphql/sdk"; import { prettyinlineTitle, prettySlug } from "helpers/formatters"; import { Immutable } from "helpers/types"; import { GetStaticPropsContext } from "next"; -import { useEffect, useState } from "react"; +import { Fragment, useEffect, useState } from "react"; interface Props extends AppStaticProps { contents: NonNullable["data"]; @@ -30,9 +30,12 @@ export default function Contents(props: Immutable): JSX.Element { const [keepInfoVisible, setKeepInfoVisible] = useState(false); const [combineRelatedContent, setCombineRelatedContent] = useState(true); + const [effectiveCombineRelatedContent, setEffectiveCombineRelatedContent] = + useState(true); + const [searchName, setSearchName] = useState(""); const [filteredItems, setFilteredItems] = useState( - filterContents(combineRelatedContent, contents) + filterContents(contents, combineRelatedContent, searchName) ); const [groups, setGroups] = useState( @@ -40,8 +43,20 @@ export default function Contents(props: Immutable): JSX.Element { ); useEffect(() => { - setFilteredItems(filterContents(combineRelatedContent, contents)); - }, [combineRelatedContent, contents]); + if (searchName.length > 1) { + setEffectiveCombineRelatedContent(false); + } else { + setEffectiveCombineRelatedContent(combineRelatedContent); + } + setFilteredItems( + filterContents(contents, effectiveCombineRelatedContent, searchName) + ); + }, [ + effectiveCombineRelatedContent, + contents, + searchName, + combineRelatedContent, + ]); useEffect(() => { setGroups(getGroups(langui, groupingMethod, filteredItems)); @@ -55,6 +70,18 @@ export default function Contents(props: Immutable): JSX.Element { description={langui.contents_description} /> + { + const input = event.target as HTMLInputElement; + setSearchName(input.value); + }} + /> +

{langui.group_by}:

{ + const input = event.target as HTMLInputElement; + setSearchName(input.value); + }} + /> +

{langui.group_by}: