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:
amirrezaghabeli
2025-10-06 11:59:54 +03:30
parent 17634744f7
commit 42f2e93a8e
28 changed files with 1499 additions and 595 deletions
+14 -9
View File
@@ -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 {