feat(offline): bundle local assets and add safe UI error recovery (U16)

This commit is contained in:
2026-11-02 19:49:31 +01:00
parent f284b85771
commit 71eed68e21
27 changed files with 275 additions and 24 deletions
@@ -1,4 +1,5 @@
@inject ToastService Toasts
@implements IDisposable
@inject ReportingPeriod Period
@page "/accounts/{AccountId:int}"
@inject IAccountService AccountService
@@ -96,7 +97,7 @@
@if (entries != null)
{
<div class="entries-scroll-wrapper">
<EntryTable HighlightedEntryId="lastSaved?.EntryId" Entries="entries" EmptyMessage="emptyEntriesMessage" OnDeleteEntry="RequestDeleteEntry" OnRestoreEntry="RequestRestoreEntry" OnEditEntry="RequestEditEntry" />
<EntryTable HighlightedEntryId="lastSaved?.EntryId" Entries="entries" EmptyMessage="@emptyEntriesMessage" OnDeleteEntry="RequestDeleteEntry" OnRestoreEntry="RequestRestoreEntry" OnEditEntry="RequestEditEntry" />
</div>
}
}
@@ -6,6 +6,8 @@ namespace Duempelkas.App.Pages.Accounts;
public partial class AccountDetail
{
private bool disposed;
public void Dispose() => disposed = true;
#region Parameters
[Parameter]
@@ -164,7 +166,7 @@ public partial class AccountDetail
await LoadAll();
if (undoToastId.HasValue) Toasts.Dismiss(undoToastId.Value);
undoToastId = Toasts.Show("Buchung gelöscht.", ToastKind.Success,
actionLabel: "Rückgängig", action: () => UndoEntryChange(id, true));
actionLabel: "Rückgängig", action: CreateUndoAction(AccountId, id, true));
}
catch (Exception ex) { Toasts.Show("Die Buchung konnte nicht geändert werden. Bitte erneut versuchen.", ToastKind.Error, ex.Message); }
finally { entryActionBusy = false; }
@@ -195,19 +197,21 @@ public partial class AccountDetail
await LoadAll();
if (undoToastId.HasValue) Toasts.Dismiss(undoToastId.Value);
undoToastId = Toasts.Show("Buchung wiederhergestellt.", ToastKind.Success,
actionLabel: "Rückgängig", action: () => UndoEntryChange(id, false));
actionLabel: "Rückgängig", action: CreateUndoAction(AccountId, id, false));
}
catch (Exception ex) { Toasts.Show("Die Buchung konnte nicht geändert werden. Bitte erneut versuchen.", ToastKind.Error, ex.Message); }
finally { entryActionBusy = false; }
}
private async Task UndoEntryChange(int id, bool restore)
private Func<Task> CreateUndoAction(int accountId, int id, bool restore) => () => UndoEntryChange(accountId, id, restore);
private async Task UndoEntryChange(int accountId, int id, bool restore)
{
if (entryActionBusy) return;
entryActionBusy = true;
try
{
var current = (await EntryService.GetEntriesAsync(AccountId, (int?)null)).FirstOrDefault(e => e.Id == id);
var current = (await EntryService.GetEntriesAsync(accountId, (int?)null)).FirstOrDefault(e => e.Id == id);
if (current == null || current.IsDeleted != restore)
{
Toasts.Show("Die Buchung wurde inzwischen geändert. Bitte die aktuelle Liste prüfen.");
@@ -215,7 +219,12 @@ public partial class AccountDetail
}
if (restore) await EntryService.RestoreEntryAsync(id); else await EntryService.DeleteEntryAsync(id);
if (undoToastId.HasValue) Toasts.Dismiss(undoToastId.Value);
await LoadAll();
if (!disposed)
{
await LoadAll();
await InvokeAsync(StateHasChanged);
}
else Navigation.NavigateTo($"/accounts/{accountId}");
Toasts.Show("Änderung rückgängig gemacht.", ToastKind.Success);
}
finally { entryActionBusy = false; }
@@ -56,7 +56,7 @@ else
@code {
private int step;
private bool loading = true, busy, showAccount;
private bool loading = true, busy, showAccount, advancing;
private string clubName = string.Empty;
private List<AccountSummaryDto> accounts = [];
private FileOperationResult? backupResult;
@@ -67,7 +67,14 @@ else
accounts = await Accounts.GetAllAccountsAsync();
loading = false;
}
private async Task Next() { step = Math.Min(step + 1, 4); await Settings.SetSetupStepAsync(step); }
private async Task Next()
{
if (advancing) return;
advancing = true;
try { var next = Math.Min(step + 1, 4); await Settings.SetSetupStepAsync(next); step = next; }
catch (Exception ex) { Toasts.Show("Der Fortschritt konnte nicht gespeichert werden. Bitte erneut versuchen.", ToastKind.Error, ex.Message); }
finally { advancing = false; }
}
private async Task SaveClub()
{
if (busy || string.IsNullOrWhiteSpace(clubName)) return;