From db2443c7ac5f43da6f71798f58a3cf6d8caa5041 Mon Sep 17 00:00:00 2001 From: SysAdmin Date: Mon, 6 Oct 2025 11:45:08 +0100 Subject: [PATCH] Fix: Blazor Server loading screen now works correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../Areas/Admin/Views/Shared/_Layout.cshtml | 20 +--- LittleShop/wwwroot/js/blazor-integration.js | 104 +++++++++++++++++- LittleShop/wwwroot/js/pwa.js | 33 +----- 3 files changed, 107 insertions(+), 50 deletions(-) diff --git a/LittleShop/Areas/Admin/Views/Shared/_Layout.cshtml b/LittleShop/Areas/Admin/Views/Shared/_Layout.cshtml index 05d0cf2..473c6ee 100644 --- a/LittleShop/Areas/Admin/Views/Shared/_Layout.cshtml +++ b/LittleShop/Areas/Admin/Views/Shared/_Layout.cshtml @@ -40,7 +40,7 @@ @await RenderSectionAsync("Head", required: false) - +