diff --git a/src/components/player/display/displayInterface.ts b/src/components/player/display/displayInterface.ts index 3109180b..c4c33d0d 100644 --- a/src/components/player/display/displayInterface.ts +++ b/src/components/player/display/displayInterface.ts @@ -1,7 +1,7 @@ import { LoadableSource, SourceQuality } from "@/stores/player/utils/qualities"; import { Listener } from "@/utils/events"; -export type DisplayErrorType = "hls" | "htmlvideo"; +export type DisplayErrorType = "hls" | "htmlvideo" | "global"; export type DisplayError = { stackTrace?: string; message?: string; diff --git a/src/hooks/useSearchQuery.ts b/src/hooks/useSearchQuery.ts index ca60f70f..68171cc4 100644 --- a/src/hooks/useSearchQuery.ts +++ b/src/hooks/useSearchQuery.ts @@ -1,6 +1,10 @@ import { useEffect, useState } from "react"; import { generatePath, useHistory, useParams } from "react-router-dom"; +function decode(query: string | null | undefined) { + return query ? decodeURIComponent(query) : ""; +} + export function useSearchQuery(): [ string, (inp: string, force?: boolean) => void, @@ -8,10 +12,10 @@ export function useSearchQuery(): [ ] { const history = useHistory(); const params = useParams<{ query: string }>(); - const [search, setSearch] = useState(params.query ?? ""); + const [search, setSearch] = useState(decode(params.query)); useEffect(() => { - setSearch(params.query ?? ""); + setSearch(decode(params.query)); }, [params.query]); const updateParams = (inp: string, commitToUrl = false) => { diff --git a/src/pages/parts/errors/ErrorPart.tsx b/src/pages/parts/errors/ErrorPart.tsx index 90109232..e61ec744 100644 --- a/src/pages/parts/errors/ErrorPart.tsx +++ b/src/pages/parts/errors/ErrorPart.tsx @@ -3,25 +3,35 @@ import { useTranslation } from "react-i18next"; import { ButtonPlain } from "@/components/buttons/Button"; import { Icons } from "@/components/Icon"; import { IconPill } from "@/components/layout/IconPill"; +import { DisplayError } from "@/components/player/display/displayInterface"; import { Title } from "@/components/text/Title"; import { Paragraph } from "@/components/utils/Text"; import { ErrorContainer, ErrorLayout } from "@/pages/layouts/ErrorLayout"; +import { ErrorCard } from "@/pages/parts/errors/ErrorCard"; export function ErrorPart(props: { error: any; errorInfo: any }) { - const data = JSON.stringify({ - error: props.error, - errorInfo: props.errorInfo, - }); const { t } = useTranslation(); + const maxLineCount = 5; + const errorLines = (props.errorInfo.componentStack || "") + .split("\n") + .slice(0, maxLineCount); + + const error: DisplayError = { + errorName: "What does this do", + type: "global", + message: errorLines.join("\n"), + }; + return ( -