From bbbda4f130dd44c151adfe29bd629b7277bc2495 Mon Sep 17 00:00:00 2001 From: Pas <74743263+Pasithea0@users.noreply.github.com> Date: Mon, 9 Jun 2025 17:45:48 -0600 Subject: [PATCH] fix febbox setup on onboarding --- src/pages/onboarding/Onboarding.tsx | 54 +++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/src/pages/onboarding/Onboarding.tsx b/src/pages/onboarding/Onboarding.tsx index ccedab81..46e25767 100644 --- a/src/pages/onboarding/Onboarding.tsx +++ b/src/pages/onboarding/Onboarding.tsx @@ -57,18 +57,21 @@ async function getFebboxKeyStatus(febboxKey: string | null) { export function FEDAPISetup() { const { t } = useTranslation(); - const [isExpanded, setIsExpanded] = useState(false); const febboxKey = usePreferencesStore((s) => s.febboxKey); const setFebboxKey = usePreferencesStore((s) => s.setFebboxKey); - const user = useAuthStore(); - // Enable febbox token when account is loaded and we have a token + // Initialize isExpanded based on whether febboxKey has a value + const [isExpanded, setIsExpanded] = useState( + febboxKey !== null && febboxKey !== "", + ); + + // Add a separate effect to set the initial state useEffect(() => { - if (user.account && febboxKey) { - setFebboxKey(febboxKey); + // If we have a valid key, make sure the section is expanded + if (febboxKey && febboxKey.length > 0) { setIsExpanded(true); } - }, [user.account, febboxKey, setFebboxKey]); + }, [febboxKey]); const [status, setStatus] = useState("unset"); const statusMap: Record = { @@ -87,6 +90,17 @@ export function FEDAPISetup() { checkTokenStatus(); }, [febboxKey]); + // Toggle handler that preserves the key + const toggleExpanded = () => { + if (isExpanded) { + // Store the key temporarily instead of setting to null + setFebboxKey(""); + setIsExpanded(false); + } else { + setIsExpanded(true); + } + }; + const [showVideo, setShowVideo] = useState(false); if (conf().ALLOW_FEBBOX_KEY) { @@ -103,10 +117,7 @@ export function FEDAPISetup() {

- setIsExpanded(!isExpanded)} - enabled={isExpanded} - /> +
{isExpanded ? ( @@ -184,6 +195,29 @@ export function FEDAPISetup() { {t("fedapi.status.failure")}

)} + {status === "api_down" && ( +

+ {t( + "fedapi.status.api_down", + "Febbox API is currently unavailable. Please try again later.", + )} +

+ )} + {status === "invalid_token" && ( +

+ {t( + "fedapi.status.invalid_token", + "Invalid token. Please check your Febbox UI token.", + )} +

+ )} + + ) : null} + + + ); + } +} ) : null}