added date parsing for reminder

This commit is contained in:
Username1548
2025-07-07 14:16:23 +07:00
parent ad538472f0
commit 43e9098d8d
7 changed files with 51 additions and 35 deletions

View File

@@ -21,7 +21,8 @@ class NotificationsCubit extends Cubit<NotificationsState> {
Future<void> connectToWebSocket() async {
await _newNotificationsSubscription?.cancel();
_newNotificationsSubscription = wsManager.newNotificationsStream?.listen((event) {
_handleNotification(event.data);
_handleNotification(event.data, event.rootObject['created_at']);
});
}
@@ -49,8 +50,9 @@ class NotificationsCubit extends Cubit<NotificationsState> {
}
}
void _handleNotification(String notificationData) {
void _handleNotification(String notificationData, String createdAt) {
final json = jsonDecode(notificationData) as Map<String, dynamic>;
json.addAll({'date': createdAt});
final stringifiedType = json['notification_class_name'];
final type = NotificationType.getTypeFromString(stringifiedType);
final notification = _parseNotification(json, type);