SignalR FIX
All checks were successful
Build Docker Images / test (map[name:Morska plugin_project:DiunaBI.Plugins.Morska]) (push) Successful in 1m26s
Build Docker Images / test (map[name:PedrolloPL plugin_project:DiunaBI.Plugins.PedrolloPL]) (push) Successful in 1m24s
Build Docker Images / build-and-push (map[image_suffix:morska name:Morska plugin_project:DiunaBI.Plugins.Morska]) (push) Successful in 1m41s
Build Docker Images / build-and-push (map[image_suffix:pedrollopl name:PedrolloPL plugin_project:DiunaBI.Plugins.PedrolloPL]) (push) Successful in 1m38s

This commit is contained in:
2025-12-06 00:36:22 +01:00
parent eb570679ba
commit 08abd96751
3 changed files with 62 additions and 8 deletions

View File

@@ -2,7 +2,9 @@
@using DiunaBI.UI.Shared.Services
@inject AppConfig AppConfig
@inject EntityChangeHubService HubService
@inject AuthService AuthService
@inherits LayoutComponentBase
@implements IDisposable
<AuthGuard>
<MudThemeProvider Theme="_theme"/>
@@ -55,10 +57,30 @@
private bool _drawerOpen = true;
private DrawerVariant _drawerVariant = DrawerVariant.Persistent;
protected override async Task OnInitializedAsync()
protected override void OnInitialized()
{
// Initialize SignalR connection when layout loads
await HubService.InitializeAsync();
// Subscribe to authentication state changes
AuthService.AuthenticationStateChanged += OnAuthenticationStateChanged;
// If already authenticated (e.g., from restored session), initialize SignalR
if (AuthService.IsAuthenticated)
{
_ = HubService.InitializeAsync();
}
}
private async void OnAuthenticationStateChanged(bool isAuthenticated)
{
if (isAuthenticated)
{
Console.WriteLine("🔐 MainLayout: User authenticated, initializing SignalR...");
await HubService.InitializeAsync();
}
}
public void Dispose()
{
AuthService.AuthenticationStateChanged -= OnAuthenticationStateChanged;
}
private MudTheme _theme = new MudTheme()