Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion Ticky.Web/Components/Pages/BoardView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@inject ILogger<BoardView> _logger
@inject IHttpContextAccessor _httpContextAccessor
@inherits NotifiableBase
@implements IAsyncDisposable

@if (_board is not null)
{
Expand Down Expand Up @@ -208,6 +209,7 @@

private HubConnection? _hubConnection;
private HashSet<string> _expandedSections = new();
private bool _isDisposed;

protected override void OnParametersSet()
{
Expand Down Expand Up @@ -266,6 +268,10 @@
var boardPreferences = await _protectedLocalStorage.GetAsync<BoardPreferencesModel>(Constants.StorageKeys.BoardPreferences);
_preferences = (boardPreferences.Success ? boardPreferences.Value : new()) ?? new();
}
catch (JSDisconnectedException)
{
_preferences = new();
}
catch (CryptographicException)
{
_preferences = new();
Expand All @@ -276,6 +282,10 @@
var filterPreferences = await _protectedLocalStorage.GetAsync<FilterCardsModel>(FILTERS_SCOPED_KEY);
_filterModel = (filterPreferences.Success ? filterPreferences.Value : new()) ?? new();
}
catch (JSDisconnectedException)
{
_filterModel = new();
}
catch(CryptographicException)
{
_filterModel = new();
Expand Down Expand Up @@ -328,6 +338,9 @@
await _hubConnection.SendAsync(nameof(UpdateHub.SubscribeBoard), Id);
} catch(Exception ex)
{
if (_isDisposed)
return;

_logger.LogError(ex, "Failed to start hub connection or subscribe to board {BoardId}", Id);
MainLayout.RunNotification(new("Real-time updates unavailable. Please refresh the page.", NotificationType.Fail));
}
Expand All @@ -341,6 +354,9 @@
{
await _protectedLocalStorage.SetAsync(Constants.StorageKeys.BoardPreferences, _preferences);
}
catch (JSDisconnectedException)
{
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to save board preferences.");
Expand Down Expand Up @@ -492,11 +508,17 @@

await LoadCardsAsync();

if (_isDisposed)
return;

await InvokeAsync(StateHasChanged);
}

private async Task LoadCardsAsync()
{
if (_isDisposed)
return;

ArgumentNullException.ThrowIfNull(_board);

using var db = _dbContextFactory.CreateDbContext();
Expand Down Expand Up @@ -534,18 +556,41 @@

_cards = await queryableCards.ToListAsync();

if (_isDisposed)
return;

await InvokeAsync(StateHasChanged);
Comment thread
coderabbitai[bot] marked this conversation as resolved.

try
{
await _protectedLocalStorage.SetAsync(FILTERS_SCOPED_KEY, _filterModel);
}
catch (JSDisconnectedException)
{
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
catch (Exception ex)
{
_logger.LogError(ex, "Failed to save filter preferences.");
}
}

public async ValueTask DisposeAsync()
{
_isDisposed = true;

if (_hubConnection is null)
return;

try
{
await _hubConnection.DisposeAsync();
}
catch (Exception ex)
{
_logger.LogDebug(ex, "Failed to dispose board hub connection.");
}
}

Comment thread
coderabbitai[bot] marked this conversation as resolved.
private bool IsAdmin()
{
if(_board is null)
Expand Down Expand Up @@ -590,4 +635,3 @@

private bool IsExpanded(string id) => _expandedSections.Contains(id);
}

Loading