Update .gitignore to exclude Firebase configuration files and refactor notification handling in the app. Removed redundant logging and notification data storage in SharedPreferences. Introduced NotificationCheckService and NotificationStateService for improved notification management. Updated view models and UI components to utilize the new services, enhancing notification state tracking and user experience.
This commit is contained in:
@@ -4,18 +4,22 @@ import 'package:tm_app/core/utils/app_toast.dart';
|
||||
import 'package:tm_app/core/utils/result.dart';
|
||||
import 'package:tm_app/data/repositories/notification_repository.dart';
|
||||
import 'package:tm_app/data/services/model/notification__response/notification_response_model.dart';
|
||||
import 'package:tm_app/view_models/home_view_model.dart';
|
||||
import 'package:tm_app/data/services/notification_check_service.dart';
|
||||
import 'package:tm_app/data/services/notification_state_service.dart';
|
||||
import 'package:tm_app/views/notification/strings/notification_strings.dart';
|
||||
|
||||
class NotificationViewModel with ChangeNotifier {
|
||||
final NotificationsRepository _repository;
|
||||
final HomeViewModel _homeViewModel;
|
||||
final NotificationStateService _notificationStateService;
|
||||
final NotificationCheckService _notificationCheckService;
|
||||
|
||||
NotificationViewModel({
|
||||
required NotificationsRepository repositoryViewModel,
|
||||
required HomeViewModel homeViewModel,
|
||||
}) : _repository = repositoryViewModel,
|
||||
_homeViewModel = homeViewModel {
|
||||
required NotificationsRepository notificationsRepository,
|
||||
required NotificationStateService notificationStateService,
|
||||
required NotificationCheckService notificationCheckService,
|
||||
}) : _repository = notificationsRepository,
|
||||
_notificationStateService = notificationStateService,
|
||||
_notificationCheckService = notificationCheckService {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
init();
|
||||
});
|
||||
@@ -347,7 +351,7 @@ class NotificationViewModel with ChangeNotifier {
|
||||
}
|
||||
|
||||
void setNotificationFalse(BuildContext context) {
|
||||
_homeViewModel.setUnreadNotificationFalse();
|
||||
_notificationStateService.clearUnreadNotification();
|
||||
}
|
||||
|
||||
void _checkAndUpdateUnreadState() {
|
||||
@@ -379,8 +383,9 @@ class NotificationViewModel with ChangeNotifier {
|
||||
return importantCount > 0;
|
||||
}
|
||||
|
||||
void checkNotifications() {
|
||||
_homeViewModel.checkUnreadNotifications();
|
||||
Future<void> checkNotifications() async {
|
||||
// Re-check unread notifications from server
|
||||
await _notificationCheckService.checkUnreadNotifications();
|
||||
}
|
||||
|
||||
Future<void> markAsRead({required String notificationId}) async {
|
||||
|
||||
Reference in New Issue
Block a user