Fix EditProspectDialog and Prospects: prevent multiple modal openings during save and create operations

This commit is contained in:
troogs
2026-05-10 19:40:06 +02:00
parent c702e8dbd5
commit e1c57967e4
2 changed files with 33 additions and 11 deletions

View File

@@ -82,23 +82,34 @@ namespace FoodsharingSiegen.Server.Dialogs
#region Private Method SaveClick #region Private Method SaveClick
private bool _isSaving;
/// <summary> /// <summary>
/// Saves the click (a. beging, 31.05.2022) /// Saves the click (a. beging, 31.05.2022)
/// </summary> /// </summary>
private async Task SaveClick() private async Task SaveClick()
{ {
if (IsUpdateMode) if (_isSaving) return;
_isSaving = true;
try
{ {
var updateR = await ProspectService.UpdateAsync(Prospect); if (IsUpdateMode)
if (updateR.Success && OnSuccess != null) await OnSuccess.Invoke(); {
} var updateR = await ProspectService.UpdateAsync(Prospect);
else if (updateR.Success && OnSuccess != null) await OnSuccess.Invoke();
{ }
var addR = await ProspectService.AddProspectAsync(Prospect); else
if (addR.Success && OnSuccess != null) await OnSuccess.Invoke(); {
} var addR = await ProspectService.AddProspectAsync(Prospect);
if (addR.Success && OnSuccess != null) await OnSuccess.Invoke();
}
await ModalService.Hide(); await ModalService.Hide();
}
finally
{
_isSaving = false;
}
} }
#endregion #endregion

View File

@@ -56,13 +56,24 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Method CreateProspectAsync #region Private Method CreateProspectAsync
private bool _isOpeningModal;
/// <summary> /// <summary>
/// Asynchronously creates a new prospect by displaying the AddProspectModal dialog and refreshing the prospect list. /// Asynchronously creates a new prospect by displaying the AddProspectModal dialog and refreshing the prospect list.
/// </summary> /// </summary>
/// <returns>A task that represents the asynchronous operation.</returns> /// <returns>A task that represents the asynchronous operation.</returns>
private async Task CreateProspectAsync() private async Task CreateProspectAsync()
{ {
await EditProspectDialog.ShowAsync(ModalService, LoadProspects); if (_isOpeningModal) return;
_isOpeningModal = true;
try
{
await EditProspectDialog.ShowAsync(ModalService, LoadProspects);
}
finally
{
_isOpeningModal = false;
}
} }
#endregion #endregion