feat: synchronisation mode deconnecte fin chat et stats

This commit is contained in:
2025-08-31 18:21:20 +02:00
parent f5bef999df
commit 96af94ad13
129 changed files with 125731 additions and 110375 deletions

View File

@@ -26,6 +26,18 @@ class Room extends HiveObject {
@HiveField(6)
final int unreadCount;
@HiveField(7)
final List<Map<String, dynamic>>? recentMessages;
@HiveField(8)
final DateTime? updatedAt;
@HiveField(9)
final int? createdBy;
@HiveField(10)
final bool isSynced;
Room({
required this.id,
required this.title,
@@ -34,6 +46,10 @@ class Room extends HiveObject {
this.lastMessage,
this.lastMessageAt,
this.unreadCount = 0,
this.recentMessages,
this.updatedAt,
this.createdBy,
this.isSynced = true,
});
// Simple factory depuis JSON
@@ -42,12 +58,20 @@ class Room extends HiveObject {
id: json['id'],
title: json['title'] ?? 'Sans titre',
type: json['type'] ?? 'private',
createdAt: DateTime.parse(json['date_creation']),
createdAt: DateTime.parse(json['created_at'] ?? json['date_creation']),
lastMessage: json['last_message'],
lastMessageAt: json['last_message_at'] != null
? DateTime.parse(json['last_message_at'])
: null,
unreadCount: json['unread_count'] ?? 0,
recentMessages: json['recent_messages'] != null
? List<Map<String, dynamic>>.from(json['recent_messages'])
: null,
updatedAt: json['updated_at'] != null
? DateTime.parse(json['updated_at'])
: null,
createdBy: json['created_by'],
isSynced: json['is_synced'] ?? true,
);
}
@@ -58,4 +82,33 @@ class Room extends HiveObject {
'type': type,
'date_creation': createdAt.toIso8601String(),
};
// Méthode copyWith pour faciliter les mises à jour
Room copyWith({
String? id,
String? title,
String? type,
DateTime? createdAt,
String? lastMessage,
DateTime? lastMessageAt,
int? unreadCount,
List<Map<String, dynamic>>? recentMessages,
DateTime? updatedAt,
int? createdBy,
bool? isSynced,
}) {
return Room(
id: id ?? this.id,
title: title ?? this.title,
type: type ?? this.type,
createdAt: createdAt ?? this.createdAt,
lastMessage: lastMessage ?? this.lastMessage,
lastMessageAt: lastMessageAt ?? this.lastMessageAt,
unreadCount: unreadCount ?? this.unreadCount,
recentMessages: recentMessages ?? this.recentMessages,
updatedAt: updatedAt ?? this.updatedAt,
createdBy: createdBy ?? this.createdBy,
isSynced: isSynced ?? this.isSynced,
);
}
}