@using Iceshrimp.Frontend.Core.Services @using Iceshrimp.Frontend.Localization @using Microsoft.AspNetCore.SignalR.Client @using Microsoft.Extensions.Localization @inject StreamingService StreamingService @inject GlobalComponentSvc GlobalComponentSvc @inject IStringLocalizer Loc
@switch (_hubConnectionState) { case HubConnectionState.Connected:
@Loc["Connected"]
break; case HubConnectionState.Connecting:
@Loc["Connecting"]
break; case HubConnectionState.Disconnected:
@Loc["Disconnected"]
break; case HubConnectionState.Reconnecting:
@Loc["Reconnecting"]
break; }
@code { private HubConnectionState _hubConnectionState = HubConnectionState.Connected; protected override async Task OnInitializedAsync() { await StreamingService.ConnectAsync(); StreamingService.OnConnectionChange += HandleConnectionChange; } private void HandleConnectionChange(object? _, HubConnectionState hubConnectionState) { _hubConnectionState = hubConnectionState; StateHasChanged(); } private async Task Reconnect() { await StreamingService.ReconnectAsync(); } }