Loading angepasst
This commit is contained in:
@@ -226,6 +226,27 @@ else
|
||||
@code {
|
||||
private static readonly System.Globalization.CultureInfo _deCulture = new("de-DE");
|
||||
|
||||
[PersistentState(AllowUpdates = true)]
|
||||
public AppSettings? PersistentSettings { get; set; }
|
||||
|
||||
[PersistentState(AllowUpdates = true)]
|
||||
public Dictionary<DateOnly, string>? PersistentHolidays { get; set; }
|
||||
|
||||
[PersistentState(AllowUpdates = true)]
|
||||
public List<DateOnly>? PersistentVacationList { get; set; }
|
||||
|
||||
[PersistentState(AllowUpdates = true)]
|
||||
public int? PersistentRemainingDays { get; set; }
|
||||
|
||||
[PersistentState(AllowUpdates = true)]
|
||||
public List<Suggestion>? PersistentSuggestions { get; set; }
|
||||
|
||||
[PersistentState(AllowUpdates = true)]
|
||||
public string? PersistentSubLabel { get; set; }
|
||||
|
||||
[PersistentState(AllowUpdates = true)]
|
||||
public int? PersistentYear { get; set; }
|
||||
|
||||
private bool _loading = true;
|
||||
private int _year = DateTime.Today.Year;
|
||||
private AppSettings _settings = new();
|
||||
@@ -238,13 +259,37 @@ else
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (PersistentSettings != null && PersistentSuggestions != null)
|
||||
{
|
||||
_settings = PersistentSettings;
|
||||
_holidays = PersistentHolidays ?? [];
|
||||
_vacationSet = (PersistentVacationList ?? []).ToHashSet();
|
||||
_remainingDays = PersistentRemainingDays ?? 0;
|
||||
_suggestions = PersistentSuggestions;
|
||||
_subLabel = PersistentSubLabel ?? "";
|
||||
_year = PersistentYear ?? DateTime.Today.Year;
|
||||
_loading = false;
|
||||
}
|
||||
|
||||
var authState = await AuthStateProvider.GetAuthenticationStateAsync();
|
||||
var claim = authState.User.FindFirst(ClaimTypes.NameIdentifier);
|
||||
if (claim == null) return;
|
||||
_userId = int.Parse(claim.Value);
|
||||
_settings = await TrackerService.GetSettingsAsync(_userId);
|
||||
await LoadYear();
|
||||
_loading = false;
|
||||
|
||||
if (PersistentSettings == null || PersistentSuggestions == null)
|
||||
{
|
||||
_settings = await TrackerService.GetSettingsAsync(_userId);
|
||||
await LoadYear();
|
||||
|
||||
PersistentSettings = _settings;
|
||||
PersistentHolidays = _holidays;
|
||||
PersistentVacationList = _vacationSet.ToList();
|
||||
PersistentRemainingDays = _remainingDays;
|
||||
PersistentSuggestions = _suggestions;
|
||||
PersistentSubLabel = _subLabel;
|
||||
PersistentYear = _year;
|
||||
_loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadYear()
|
||||
@@ -283,7 +328,7 @@ else
|
||||
// ── Algorithmus ──────────────────────────────────────────────────────
|
||||
private enum DayKind { Free, WorkAvailable, WorkTaken }
|
||||
|
||||
private sealed record Suggestion(
|
||||
public sealed record Suggestion(
|
||||
DateOnly SpanStart,
|
||||
DateOnly SpanEnd,
|
||||
List<DateOnly> VacationDaysToTake,
|
||||
|
||||
Reference in New Issue
Block a user