feat(offline): bundle local assets and add safe UI error recovery (U16)
This commit is contained in:
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user