diff --git a/src/components/common/Logo.tsx b/src/components/common/Logo.tsx index bd8ecd5..92f0d48 100644 --- a/src/components/common/Logo.tsx +++ b/src/components/common/Logo.tsx @@ -4,9 +4,9 @@ * SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL */ -import { useState, useEffect } from 'react'; +import { useEffect } from 'react'; import { useTranslation } from 'react-i18next'; -import { getApiBaseUrl } from '@/services/api'; +import { useUIStore } from '@/stores/uiStore'; export function DefaultLogo() { const { t } = useTranslation(); @@ -31,51 +31,21 @@ export function DefaultLogo() { export default function Logo() { const { t } = useTranslation(); - const [logoUrl, setLogoUrl] = useState(null); - const [failed, setFailed] = useState(false); + const logoUrl = useUIStore((s) => s.logoUrl); + const logoLoading = useUIStore((s) => s.logoLoading); + const fetchLogo = useUIStore((s) => s.fetchLogo); useEffect(() => { - const controller = new AbortController(); - - async function fetchLogo() { - try { - const response = await fetch(`${getApiBaseUrl()}/logo`, { - signal: controller.signal, - }); - const contentType = response.headers.get('content-type') ?? ''; - - if (response.ok && contentType.startsWith('image/')) { - const blob = await response.blob(); - if (!controller.signal.aborted) { - const url = URL.createObjectURL(blob); - setLogoUrl(url); - } - } else { - if (!controller.signal.aborted) setFailed(true); - } - } catch { - if (!controller.signal.aborted) setFailed(true); - } - } - fetchLogo(); + }, [fetchLogo]); - return () => { - controller.abort(); - }; - }, []); - - useEffect(() => { - return () => { - if (logoUrl) { - URL.revokeObjectURL(logoUrl); - } - }; - }, [logoUrl]); - - if (logoUrl && !failed) { + if (logoUrl) { return {t('logo.alt',; } + if (logoLoading) { + return