Fix and harden prospect creation against Blazor runtime crashes
All checks were successful
Build And Push Dev Docker Image / docker (push) Successful in 3m3s

- Handle empty numeric input safely with nullable integer binding.

- Add semaphore locks to prevent double-click invocation errors on mobile.

- Implement global exception handling and user notifications for prospect operations.
This commit is contained in:
troogs
2026-05-10 19:47:39 +02:00
parent e1c57967e4
commit 935f026c75
2 changed files with 35 additions and 10 deletions

View File

@@ -96,15 +96,33 @@ namespace FoodsharingSiegen.Server.Dialogs
if (IsUpdateMode)
{
var updateR = await ProspectService.UpdateAsync(Prospect);
if (updateR.Success && OnSuccess != null) await OnSuccess.Invoke();
if (updateR.Success)
{
if (OnSuccess != null) await OnSuccess.Invoke();
await ModalService.Hide();
}
else
{
await Notification.Error(updateR.Exception?.Message ?? "Unbekannter Fehler beim Speichern.", "Fehler");
}
}
else
{
var addR = await ProspectService.AddProspectAsync(Prospect);
if (addR.Success && OnSuccess != null) await OnSuccess.Invoke();
if (addR.Success)
{
if (OnSuccess != null) await OnSuccess.Invoke();
await ModalService.Hide();
}
else
{
await Notification.Error(addR.Exception?.Message ?? "Unbekannter Fehler beim Hinzufügen.", "Fehler");
}
}
await ModalService.Hide();
}
catch (Exception ex)
{
await Notification.Error(ex.Message, "Systemfehler");
}
finally
{

View File

@@ -100,15 +100,22 @@ namespace FoodsharingSiegen.Server.Pages
/// </summary>
private async Task LoadProspects()
{
var parameter = new GetProspectsParameter
try
{
CannotHaveInteractions = [InteractionType.Complete, InteractionType.Verify, InteractionType.ReleasedForVerification]
};
var parameter = new GetProspectsParameter
{
CannotHaveInteractions = [InteractionType.Complete, InteractionType.Verify, InteractionType.ReleasedForVerification]
};
var prospectsR = await ProspectService.GetProspectsAsync(parameter);
if (prospectsR.Success) ProspectList = prospectsR.Data;
var prospectsR = await ProspectService.GetProspectsAsync(parameter);
if (prospectsR.Success) ProspectList = prospectsR.Data;
await InvokeAsync(StateHasChanged);
await InvokeAsync(StateHasChanged);
}
catch (Exception ex)
{
await Notification.Error(ex.Message, "Fehler beim Laden");
}
}
#endregion