This repository has been archived on 2026-06-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
FabledApp/lib/data/models/message.dart
T
bvandeusen 46d0427901 feat: weather card and RSS reactions in briefing screen
- Parse metadata field on Message model (weather, rss_item_ids)
- Add WeatherCard widget: location, current temp, condition, today hi/lo,
  delta from yesterday, scrollable 3-day forecast strip
- BriefingScreen shows WeatherCard above the first assistant message that
  carries weather metadata (mirrors web BriefingView.vue behaviour)
- RSS reaction buttons (👍/👎) shown below assistant messages with
  rss_item_ids; optimistic toggle with rollback on failure
- Add postRssReaction / deleteRssReaction to BriefingApi

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 17:30:26 -04:00

44 lines
1.3 KiB
Dart

enum MessageRole { user, assistant }
class Message {
final int? id;
final int conversationId;
final MessageRole role;
final String content;
final String status; // "complete" | "generating"
final DateTime? createdAt;
final Map<String, dynamic>? metadata;
const Message({
this.id,
required this.conversationId,
required this.role,
required this.content,
this.status = 'complete',
this.createdAt,
this.metadata,
});
factory Message.fromJson(Map<String, dynamic> json) => Message(
id: json['id'] as int?,
conversationId: json['conversation_id'] as int,
role: json['role'] == 'user' ? MessageRole.user : MessageRole.assistant,
content: json['content'] as String,
status: json['status'] as String? ?? 'complete',
createdAt: json['created_at'] != null
? DateTime.parse(json['created_at'] as String)
: null,
metadata: json['metadata'] as Map<String, dynamic>?,
);
Message copyWith({String? content, String? status}) => Message(
id: id,
conversationId: conversationId,
role: role,
content: content ?? this.content,
status: status ?? this.status,
createdAt: createdAt,
metadata: metadata,
);
}