peformance verbesserungen

This commit is contained in:
MarcWieland
2026-06-08 16:39:28 +02:00
parent b3e578308f
commit 708aa3991a
6 changed files with 73 additions and 13 deletions
@@ -6,6 +6,7 @@ namespace timetracker.Client.Services;
public class ClientTimetrackerService : ITimetrackerService
{
private readonly HttpClient _http;
private AppSettings? _cachedSettings;
public ClientTimetrackerService(HttpClient http)
{
@@ -24,12 +25,19 @@ public class ClientTimetrackerService : ITimetrackerService
public async Task<AppSettings> GetSettingsAsync(int userId)
{
return await _http.GetFromJsonAsync<AppSettings>($"api/tracker/settings/{userId}") ?? new AppSettings { UserId = userId };
if (_cachedSettings != null && _cachedSettings.UserId == userId)
{
return _cachedSettings;
}
var settings = await _http.GetFromJsonAsync<AppSettings>($"api/tracker/settings/{userId}");
_cachedSettings = settings ?? new AppSettings { UserId = userId };
return _cachedSettings;
}
public async Task SaveSettingsAsync(AppSettings settings)
{
await _http.PostAsJsonAsync("api/tracker/settings", settings);
_cachedSettings = settings;
}
public async Task<List<VacationDay>> GetVacationDaysAsync(int userId, int year)