refactor: Update download.tsx to fix issue with Twilight mode detection

This commit is contained in:
mauro-balades
2024-10-06 00:08:58 +02:00
parent f752156d68
commit f65c62251c

View File

@@ -74,9 +74,7 @@ const FieldDescription = styled.div`
export default function DownloadPage() { export default function DownloadPage() {
const [platform, setPlatform] = useState<string | null>(null); const [platform, setPlatform] = useState<string | null>(null);
if (typeof window === "undefined") return null; const [isTwilight, setIsTwilight] = useState(false);
const searchParams = new URLSearchParams(window.location.search);
const [isTwilight, setIsTwilight] = useState(searchParams.has("twilight"));
const [architecture, setArchitecture] = useState<string | null>(null); const [architecture, setArchitecture] = useState<string | null>(null);
const [selectedPlatform, setSelectedPlatform] = useState(""); const [selectedPlatform, setSelectedPlatform] = useState("");
@@ -103,6 +101,8 @@ export default function DownloadPage() {
if (userAgent.includes("Linux")) { if (userAgent.includes("Linux")) {
setSelectedPlatform("Linux"); setSelectedPlatform("Linux");
} }
const searchParams = new URLSearchParams(window.location.search);
setIsTwilight(searchParams.has("twilight"));
}, []); }, []);
const throwConfetti = () => { const throwConfetti = () => {
const end = Date.now() + 3 * 1000; // 3 seconds const end = Date.now() + 3 * 1000; // 3 seconds