loadInitialMessages method
Implementation
Future<List<ChatMessage?>?> loadInitialMessages(String disputeId) async {
Dispute? _dispute;
// Retrieve the tradeId from the mapping
final tradeId = _disputeToTradeIdMap[disputeId];
if (tradeId == null) return null;
// Retrieve the dispute from the _disputes list using the disputeId
try {
_dispute = _disputes.firstWhere((d) => d.id == disputeId);
} catch (e) {
return null;
}
debugPrint("Setting chat messages for dispute: $disputeId with ${_dispute.chatMessage.length} messages");
// Store the chat messages in _chatMessages for this disputeId
_chatMessages[disputeId] = _dispute.chatMessage;
// If a stream controller exists for this disputeId, add the messages to the stream
if (_chatControllers.containsKey(disputeId)) {
_chatControllers[disputeId]!.add(_chatMessages[disputeId]!);
}
return null;
}