40 lines
1.0 KiB
Dart
40 lines
1.0 KiB
Dart
import 'package:brick_offline_first_with_supabase/brick_offline_first_with_supabase.dart';
|
|
import 'package:brick_supabase/brick_supabase.dart';
|
|
|
|
import '../utils/app_time.dart';
|
|
|
|
@ConnectOfflineFirstWithSupabase(
|
|
supabaseConfig: SupabaseSerializable(tableName: 'chat_messages'),
|
|
)
|
|
class ChatMessage extends OfflineFirstWithSupabaseModel {
|
|
final String id;
|
|
final String threadId;
|
|
final String senderId;
|
|
final String body;
|
|
final DateTime createdAt;
|
|
|
|
ChatMessage({
|
|
required this.id,
|
|
required this.threadId,
|
|
required this.senderId,
|
|
required this.body,
|
|
required this.createdAt,
|
|
});
|
|
|
|
factory ChatMessage.fromMap(Map<String, dynamic> map) {
|
|
return ChatMessage(
|
|
id: map['id'] as String,
|
|
threadId: map['thread_id'] as String,
|
|
senderId: map['sender_id'] as String,
|
|
body: map['body'] as String,
|
|
createdAt: AppTime.parse(map['created_at'] as String),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'thread_id': threadId,
|
|
'sender_id': senderId,
|
|
'body': body,
|
|
};
|
|
}
|