import 'package:tm_app/core/utils/result.dart'; import 'package:tm_app/data/repositories/home_repository.dart'; import 'package:tm_app/data/services/notification_state_service.dart'; /// Service to check for unread notifications and update state class NotificationCheckService { final HomeRepository _homeRepository; final NotificationStateService _notificationStateService; NotificationCheckService({ required HomeRepository homeRepository, required NotificationStateService notificationStateService, }) : _homeRepository = homeRepository, _notificationStateService = notificationStateService; Future checkUnreadNotifications() async { final result = await _homeRepository.checkUnreadNotifications(); switch (result) { case Ok>(): final response = result.value; final data = response['data']; _notificationStateService.setHasUnreadNotification( data is List && data.isNotEmpty, ); break; case Error>(): _notificationStateService.setHasUnreadNotification(false); break; } } }