Fix: Blazor Server loading screen now works correctly
Problem: - Loading screen was getting stuck and not hiding properly - Conflicting logic between pwa.js and inline scripts - Blazor Server lifecycle not properly integrated with loading screen Solution (Meziantou-inspired approach for Blazor Server): 1. **blazor-integration.js** - Now manages loading screen lifecycle: - Shows loading screen only on first load (sessionStorage check) - Hides screen when Blazor.start() promise resolves (SignalR connected) - Added reconnection UI for Blazor Server disconnections - Proper error handling if Blazor fails to start 2. **_Layout.cshtml** - Simplified loading screen management: - Removed inline script that was conflicting - Moved blazor-integration.js before pwa.js (load order critical) - Loading screen now controlled by Blazor lifecycle 3. **pwa.js** - Removed conflicting logic: - Removed hideLoadingScreen() method - Removed 5-second fallback timeout - PWA initialization no longer interferes with Blazor loading Key Differences from WebAssembly Approach: - WASM: Downloads .NET runtime + shows download progress - Server: Establishes SignalR connection + shows spinner - Loading screen hides when SignalR connection is ready 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -39,22 +39,9 @@ class PWAManager {
|
||||
// Setup push notifications
|
||||
this.setupPushNotifications();
|
||||
|
||||
// Hide loading screen after initialization
|
||||
this.hideLoadingScreen();
|
||||
}
|
||||
|
||||
hideLoadingScreen() {
|
||||
const loadingScreen = document.getElementById('pwa-loading-screen');
|
||||
if (loadingScreen && loadingScreen.style.display !== 'none') {
|
||||
// Add fade-out class
|
||||
loadingScreen.classList.add('fade-out');
|
||||
|
||||
// Hide after animation completes (don't remove from DOM to avoid layout issues)
|
||||
setTimeout(() => {
|
||||
loadingScreen.style.display = 'none';
|
||||
console.log('PWA: Loading screen hidden');
|
||||
}, 500);
|
||||
}
|
||||
// Loading screen is now managed by blazor-integration.js
|
||||
// Don't interfere with Blazor Server's loading lifecycle
|
||||
console.log('PWA: Initialization complete (loading screen managed by Blazor)');
|
||||
}
|
||||
|
||||
setupInstallPrompt() {
|
||||
@@ -701,15 +688,5 @@ window.addEventListener('load', () => {
|
||||
}
|
||||
});
|
||||
|
||||
// Fallback: Ensure loading screen is hidden after maximum timeout
|
||||
// This guarantees the loading screen won't stay visible indefinitely
|
||||
setTimeout(() => {
|
||||
const loadingScreen = document.getElementById('pwa-loading-screen');
|
||||
if (loadingScreen && loadingScreen.style.display !== 'none') {
|
||||
console.log('PWA: Hiding loading screen via fallback timeout');
|
||||
loadingScreen.classList.add('fade-out');
|
||||
setTimeout(() => {
|
||||
loadingScreen.style.display = 'none';
|
||||
}, 500);
|
||||
}
|
||||
}, 5000); // 5 second maximum
|
||||
// Loading screen fallback timeout removed - now managed by blazor-integration.js
|
||||
// Blazor Server controls loading screen lifecycle based on SignalR connection state
|
||||
Reference in New Issue
Block a user