findConversationById static method

Future<ChatModel?> findConversationById(
  1. int id
)

Implementation

static Future<ChatModel?> findConversationById(int id) async {
  UserStatusHelper.setMyLastSeenAt();
  try {
    final response = await getFromTable('chats').select('''
        *,
        chat_members (
          user_id,
          is_admin,
          joined_at,
          latest_seen_at
        )
      ''').eq('id', id).single();

    chatV2Print("findConversationById response: $response");

    if (response.isNotEmpty) {
      return ChatModel.fromJson(response);
    }
    return null;
  } catch (e) {
    chatV2Print("findConversationById Error finding conversation: $e");
    return null;
  }
}