class Message {
  final String id;
  final String senderName;
  final String content;
  final DateTime timestamp;
  final String avatarUrl;
  final bool isRead;

  Message({
    required this.id,
    required this.senderName,
    required this.content,
    required this.timestamp,
    required this.avatarUrl,
    this.isRead = false,
  });

  // 获取格式化的时间
  String get formattedTime {
    final now = DateTime.now();
    final difference = now.difference(timestamp);

    if (difference.inDays > 0) {
      return '${difference.inDays}d ago';
    } else if (difference.inHours > 0) {
      return '${difference.inHours}h ago';
    } else if (difference.inMinutes > 0) {
      return '${difference.inMinutes}m ago';
    } else {
      return 'Just now';
    }
  }
}
