Files
ARCHITECT f199daf4ba Change PIN to 1451
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 23:31:52 +00:00

39 lines
1.0 KiB
Dart

class Conversation {
final String id;
final String? title;
final DateTime createdAt;
final DateTime updatedAt;
final int messageCount;
Conversation({
required this.id,
this.title,
required this.createdAt,
required this.updatedAt,
this.messageCount = 0,
});
factory Conversation.fromJson(Map<String, dynamic> json) {
return Conversation(
id: json['id'],
title: json['title'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
messageCount: json['message_count'] ?? 0,
);
}
String get displayTitle => title ?? 'New Conversation';
String get timeAgo {
final now = DateTime.now();
final diff = now.difference(updatedAt);
if (diff.inMinutes < 1) return 'Just now';
if (diff.inMinutes < 60) return '${diff.inMinutes}m ago';
if (diff.inHours < 24) return '${diff.inHours}h ago';
if (diff.inDays < 7) return '${diff.inDays}d ago';
return '${updatedAt.day}/${updatedAt.month}/${updatedAt.year}';
}
}