52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
using cfs_tracker.Data;
|
|
|
|
namespace cfs_tracker.Services;
|
|
|
|
public class AppBootstrapService
|
|
{
|
|
private readonly AppDatabase _database;
|
|
private readonly ActivityRepository _activityRepository;
|
|
private readonly SymptomRepository _symptomRepository;
|
|
private readonly AppearanceRepository _appearanceRepository;
|
|
private readonly AppearanceService _appearanceService;
|
|
private readonly INotificationScheduler _notificationScheduler;
|
|
|
|
private bool _initialized;
|
|
|
|
public AppBootstrapService(
|
|
AppDatabase database,
|
|
ActivityRepository activityRepository,
|
|
SymptomRepository symptomRepository,
|
|
AppearanceRepository appearanceRepository,
|
|
AppearanceService appearanceService,
|
|
INotificationScheduler notificationScheduler)
|
|
{
|
|
_database = database;
|
|
_activityRepository = activityRepository;
|
|
_symptomRepository = symptomRepository;
|
|
_appearanceRepository = appearanceRepository;
|
|
_appearanceService = appearanceService;
|
|
_notificationScheduler = notificationScheduler;
|
|
}
|
|
|
|
public async Task InitializeAsync()
|
|
{
|
|
if (_initialized)
|
|
return;
|
|
|
|
await _database.InitAsync();
|
|
await _activityRepository.EnsureDefaultsAsync();
|
|
await _symptomRepository.EnsureDefaultsAsync();
|
|
await _appearanceRepository.EnsureDefaultsAsync();
|
|
await _appearanceService.SyncLocalizedStatusTextsAsync();
|
|
|
|
// Wichtig: gespeicherte Appearance-Werte direkt beim Start
|
|
// auf die App-Ressourcen anwenden.
|
|
await _appearanceService.ApplyAsync();
|
|
|
|
await _notificationScheduler.SyncAsync();
|
|
|
|
_initialized = true;
|
|
}
|
|
}
|