2026-08-10 22:49:37 +02:00
|
|
|
@* NotificationBadge.razor — cloche avec badge compteur temps réel (SignalR). *@
|
|
|
|
|
@implements IAsyncDisposable
|
|
|
|
|
@inject NotificationsHubClient Hub
|
|
|
|
|
@inject NavigationManager Navigation
|
2026-10-25 05:59:18 +01:00
|
|
|
@inject Heimdall.Web.Services.UiText Text
|
2026-08-10 22:49:37 +02:00
|
|
|
|
2026-10-25 05:59:18 +01:00
|
|
|
<MudTooltip Text="@Text["SharedNotificationBadge_Title"]">
|
|
|
|
|
<MudIconButton Icon="@Icons.Material.Filled.Notifications" Color="Color.Inherit" aria-label="@Text["SharedNotificationBadge_Title"]"
|
2026-08-10 22:49:37 +02:00
|
|
|
OnClick="@(() => Navigation.NavigateTo("/events"))">
|
|
|
|
|
@if (Hub.UnreadCount > 0)
|
|
|
|
|
{
|
|
|
|
|
<MudBadge Color="Color.Error" Overlap="true" Bordered="true" Content="@Hub.UnreadCount" />
|
|
|
|
|
}
|
|
|
|
|
</MudIconButton>
|
|
|
|
|
</MudTooltip>
|
|
|
|
|
|
|
|
|
|
@code {
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
|
|
|
|
Hub.UnreadCountChanged += OnUnreadChanged;
|
|
|
|
|
await Hub.StartAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnUnreadChanged(int _) => InvokeAsync(StateHasChanged);
|
|
|
|
|
|
|
|
|
|
public async ValueTask DisposeAsync()
|
|
|
|
|
{
|
|
|
|
|
Hub.UnreadCountChanged -= OnUnreadChanged;
|
|
|
|
|
await Hub.DisposeAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|