diff --git a/src/pages/components/loadingScene.jsx b/src/pages/components/loadingScene.jsx index 2acae03..023b5f6 100644 --- a/src/pages/components/loadingScene.jsx +++ b/src/pages/components/loadingScene.jsx @@ -1,21 +1,24 @@ -import { useState, useEffect } from 'react'; import '../../css/global.css'; function LoadingScene() { return (
Loading...
); } -export default LoadingScene \ No newline at end of file +export default LoadingScene; diff --git a/src/pages/homePage.jsx b/src/pages/homePage.jsx index cd294a5..591fbde 100644 --- a/src/pages/homePage.jsx +++ b/src/pages/homePage.jsx @@ -1,8 +1,11 @@ -import { useEffect } from 'react'; +import { useEffect, useState } from 'react'; import '../css/global.css'; import BlackButton from './components/customButton'; +import LoadingScene from './components/loadingScene'; function HomePage() { + const [loading, setLoading] = useState(true); // Track loading state + useEffect(() => { const controller = new AbortController(); @@ -10,16 +13,17 @@ function HomePage() { try { const res = await fetch(`${import.meta.env.VITE_ASSETS_URL}/hallway_FFF.mp4`, { signal: controller.signal, - cache: 'force-cache', // Helps to ensure the response is stored + cache: 'force-cache', }); - // Read the response into memory (helps trigger caching) - await res.blob(); + await res.blob(); // Read into memory to trigger caching console.log('Video prefetched successfully.'); } catch (err) { if (err.name !== 'AbortError') { console.error('Video prefetch failed:', err); } + } finally { + setLoading(false); // Done loading either way } }; @@ -28,6 +32,12 @@ function HomePage() { return () => controller.abort(); }, []); + if (loading) { + return ( + + ); + } + return (
) : ( -
- - -
- + )} +
); }