diff --git a/public/app.js b/public/app.js index 578bd0c..705c157 100644 --- a/public/app.js +++ b/public/app.js @@ -4,6 +4,7 @@ let refreshInterval = null; let currentRefreshRate = 5000; // default 5 seconds let isAdmin = false; let showAll = false; +const SPLASH_MIN_MS = 1200; // minimum splash display time // Apply saved theme immediately (before DOMContentLoaded to avoid flash) (function() { @@ -63,7 +64,30 @@ function stopAutoRefresh() { } } +function showSplash() { + const splash = document.getElementById('splash-screen'); + splash.style.display = 'flex'; + splash.style.opacity = '1'; + splash.classList.remove('fade-out'); +} + +function dismissSplash(startTime) { + return new Promise(resolve => { + const elapsed = Date.now() - (startTime || 0); + const remaining = Math.max(0, SPLASH_MIN_MS - elapsed); + setTimeout(() => { + const splash = document.getElementById('splash-screen'); + splash.classList.add('fade-out'); + splash.addEventListener('transitionend', () => { + splash.style.display = 'none'; + resolve(); + }, { once: true }); + }, remaining); + }); +} + async function checkAuthentication() { + const splashStart = Date.now(); try { const response = await fetch('/api/auth/me'); const data = await response.json(); @@ -72,13 +96,16 @@ async function checkAuthentication() { currentUser = data.user; isAdmin = !!data.user.isAdmin; showDashboard(); - fetchUserDownloads(true); + await fetchUserDownloads(true); startAutoRefresh(); + await dismissSplash(splashStart); } else { + await dismissSplash(splashStart); showLogin(); } } catch (err) { console.error('Authentication check failed:', err); + await dismissSplash(splashStart); showLogin(); } } @@ -103,9 +130,12 @@ async function handleLogin(e) { if (data.success) { currentUser = data.user; isAdmin = !!data.user.isAdmin; + showSplash(); showDashboard(); - fetchUserDownloads(true); + const splashStart = Date.now(); + await fetchUserDownloads(true); startAutoRefresh(); + await dismissSplash(splashStart); } else { showLoginError(data.error || 'Login failed'); } diff --git a/public/images/sofarr-flashscreen.png b/public/images/sofarr-flashscreen.png new file mode 100644 index 0000000..b738d12 Binary files /dev/null and b/public/images/sofarr-flashscreen.png differ diff --git a/public/index.html b/public/index.html index dbf5ed5..8e05d95 100644 --- a/public/index.html +++ b/public/index.html @@ -7,6 +7,11 @@
+ +
+