import '../../features/auth/presentation/bloc/auth_state.dart'; import '../../features/calendar/data/services/calendar_service.dart'; import '../../features/notification/data/services/local_notification_service.dart'; class AuthSessionBootstrapper { AuthSessionBootstrapper({ required CalendarService calendarService, required LocalNotificationService notificationService, }) : _calendarService = calendarService, _notificationService = notificationService; final CalendarService _calendarService; final LocalNotificationService _notificationService; String? _syncedUserId; Future syncForAuthState(AuthState state) async { if (state is! AuthAuthenticated) { _syncedUserId = null; return; } if (_syncedUserId == state.user.id) { return; } try { final now = DateTime.now(); final start = now.subtract(const Duration(days: 90)); final end = now.add(const Duration(days: 90)); final events = await _calendarService.getEventsForRange(start, end); await _notificationService.rebuildUpcomingReminders(events); _syncedUserId = state.user.id; } catch (_) { // ignore reminder bootstrap failures } } }