From 404d3b885fc1b260adda067e0aebcecc55837f67 Mon Sep 17 00:00:00 2001 From: William Oldham Date: Sun, 3 Mar 2024 18:37:43 +0000 Subject: [PATCH] Handle nullability of config fields --- src/hooks/auth/useBackendUrl.ts | 2 +- src/pages/parts/admin/TMDBTestPart.tsx | 2 +- src/pages/parts/settings/SidebarPart.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hooks/auth/useBackendUrl.ts b/src/hooks/auth/useBackendUrl.ts index 64545227..adee8622 100644 --- a/src/hooks/auth/useBackendUrl.ts +++ b/src/hooks/auth/useBackendUrl.ts @@ -1,7 +1,7 @@ import { conf } from "@/setup/config"; import { useAuthStore } from "@/stores/auth"; -export function useBackendUrl(): string | undefined { +export function useBackendUrl(): string | null { const backendUrl = useAuthStore((s) => s.backendUrl); return backendUrl ?? conf().BACKEND_URL; } diff --git a/src/pages/parts/admin/TMDBTestPart.tsx b/src/pages/parts/admin/TMDBTestPart.tsx index a7f8fa50..d760c948 100644 --- a/src/pages/parts/admin/TMDBTestPart.tsx +++ b/src/pages/parts/admin/TMDBTestPart.tsx @@ -25,7 +25,7 @@ export function TMDBTestPart() { errorText: "", }); - if (tmdbApiKey.length === 0) { + if (!tmdbApiKey || tmdbApiKey.length === 0) { return setStatus({ hasTested: true, success: false, diff --git a/src/pages/parts/settings/SidebarPart.tsx b/src/pages/parts/settings/SidebarPart.tsx index 13db06fe..98404c84 100644 --- a/src/pages/parts/settings/SidebarPart.tsx +++ b/src/pages/parts/settings/SidebarPart.tsx @@ -14,7 +14,7 @@ import { useAuthStore } from "@/stores/auth"; const rem = 16; -function SecureBadge(props: { url: string | undefined }) { +function SecureBadge(props: { url: string | null }) { const { t } = useTranslation(); const secure = props.url ? props.url.startsWith("https://") : false; return (