json.tutor_groups do
  json.partial! 'chat/chat_members', collection: @groups, as: :group
end

if current_user
  json.others do
    json.([:recents]) do |group|
      json.name group.capitalize
      json.conversations do
        json.array! @recents.map {|conversation| conversation.chat_data_for(current_user, true, params[:query])}
      end
      if @recents.present?
        json.set! :show_more_recents_url, (link_to_next_page @recents, 'Show More', remote: true, params: {group_id: nil, user_type: 'recents'}).try(:html_safe)
      end
    end
  end
end

json.my_groups do
  json.partial! 'chat/chat_members', collection: @my_groups, as: :group
end
