fix select members
Zusammenfassung der Änderungen: 1. FluxorComponent als Basisklasse - Dialog reagiert nun auf PersonState-Änderungen 2. Redundante DB-Anfragen vermeiden - LoadPersonsAction wird nur dispatched wenn Persons.Count == 0 && !IsLoading 3. Pre-Selection bei asynchronem Laden - In OnAfterRender wird die Member-Vorauswahl aktualisiert sobald Persons verfügbar sind Ursache des Problems: - Der Dialog dispatched LoadPersonsAction bei jedem Öffnen - DayDetails.razor dispatched gleichzeitig mehrere Actions (LoadAvailablePersonsAction, etc.) - Viele parallele DB-Requests erschöpfen den Connection Pool
This commit is contained in:
parent
8987fc34b5
commit
53a68c91d0
|
|
@ -597,9 +597,20 @@ else
|
|||
return Icons.Material.Filled.Circle; // Future
|
||||
}
|
||||
|
||||
private void AdvanceStatus()
|
||||
private async Task AdvanceStatus()
|
||||
{
|
||||
if (Day is null) return;
|
||||
if (Day is null)
|
||||
return;
|
||||
|
||||
if (Day.Status == DayStatus.Started )
|
||||
{
|
||||
var res = await DialogService.ShowMessageBox("Tag abschließen?", "Spieltag wirklich beenden?", yesText: "Ja", noText: "Nein");
|
||||
if (res.HasValue && !res.Value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Dispatcher.Dispatch(new AdvanceDayStatusAction(Day.Id));
|
||||
Snackbar.Add("Status wird aktualisiert...", Severity.Info);
|
||||
}
|
||||
|
|
@ -834,11 +845,15 @@ else
|
|||
}
|
||||
}
|
||||
|
||||
private void EndGame()
|
||||
private async Task EndGame()
|
||||
{
|
||||
Dispatcher.Dispatch(new EndGameAction(GameStatus.Completed));
|
||||
_activeTabIndex = 0; // Switch back to Details tab
|
||||
Snackbar.Add("Spiel wird beendet...", Severity.Info);
|
||||
var res = await DialogService.ShowMessageBox("Spiel beenden", "Spiel wirklich beenden?", yesText:"Ja", noText:"Nein");
|
||||
if (res.HasValue && res.Value)
|
||||
{
|
||||
Dispatcher.Dispatch(new EndGameAction(GameStatus.Completed));
|
||||
_activeTabIndex = 0; // Switch back to Details tab
|
||||
Snackbar.Add("Spiel wird beendet...", Severity.Info);
|
||||
}
|
||||
}
|
||||
|
||||
private string? GetCurrentPlayerName()
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
@using Fluxor
|
||||
@using Koogle.Web.Store.PersonState
|
||||
|
||||
@inherits Fluxor.Blazor.Web.Components.FluxorComponent
|
||||
|
||||
@inject IState<PersonState> PersonState
|
||||
@inject IDispatcher Dispatcher
|
||||
|
||||
|
|
@ -98,6 +100,8 @@
|
|||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
|
||||
if (Day is not null)
|
||||
{
|
||||
_postDate = Day.PostDate;
|
||||
|
|
@ -105,8 +109,11 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
// Load persons for selection when creating new day
|
||||
Dispatcher.Dispatch(new LoadPersonsAction());
|
||||
// Only load persons if not already loaded
|
||||
if (PersonState.Value.Persons.Count == 0 && !PersonState.Value.IsLoading)
|
||||
{
|
||||
Dispatcher.Dispatch(new LoadPersonsAction());
|
||||
}
|
||||
|
||||
// Pre-select all members
|
||||
_selectedPersonIds = PersonState.Value.Persons
|
||||
|
|
@ -118,9 +125,15 @@
|
|||
|
||||
protected override void OnAfterRender(bool firstRender)
|
||||
{
|
||||
if (firstRender && !IsEditMode)
|
||||
base.OnAfterRender(firstRender);
|
||||
|
||||
if (!IsEditMode && _selectedPersonIds.Count == 0 && PersonState.Value.Persons.Count > 0)
|
||||
{
|
||||
// Update selection after persons are loaded
|
||||
// Update pre-selection after persons are loaded
|
||||
_selectedPersonIds = PersonState.Value.Persons
|
||||
.Where(p => p.PersonStatus == PersonStatus.Member)
|
||||
.Select(p => p.Id)
|
||||
.ToList();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue