getAllConversations method

Future<Map<String, ConversationState>> getAllConversations()

Implementation

Future<Map<String, ConversationState>> getAllConversations() async {
  // Note: ReaxDB.simple might not have a direct way to get all keys with prefix easily
  // depending on version, but usually we can track session IDs elsewhere or use a known set.
  // For this template, we'll assume a fixed set of IDs or store an index.
  final indexData = await _db.get('conversation_index');
  final List<String> ids = indexData != null ? List<String>.from(indexData['ids']) : [];

  final Map<String, ConversationState> conversations = {};
  for (final id in ids) {
    final conv = await getConversation(id);
    if (conv != null) {
      conversations[id] = conv;
    }
  }
  return conversations;
}