{# chat list of the users #}
{% if chat_list_of_users is not empty %}
{{ 'Chat List'|trans }}
{% set ar__of_users = [] %}
{% for chat_ar in chat_list_of_users %}
{# chat reference #}
{# this chat is not group based then we use user reference niether we will use group reference #}
{% if chat_ar.icg_name is empty %}
{# check both from and to field - a sender can't send message himself so, if the message_to id is current user id then we'll pick up the from id to see the user chat picture and name niether we will use from id#}
{% if chat_ar.user_ref == app.user.id %}
{# message is sent to the this current user#}
{% set key___ref = chat_ar.user_ref__from %}
{% set name___ref = chat_ar.user_from_fName ~ ' ' ~ chat_ar.user_from_lName %}
{% set slogan = get_the_user__full_category(chat_ar.user_from_category) %}
{% set img___url = asset(user_avatar(chat_ar.user_ref__from,false)) %}
{% else %}
{# message is sent to from this current logged in user #}
{% set key___ref = chat_ar.user_ref %}
{% set name___ref = chat_ar.fName ~ ' ' ~ chat_ar.lName %}
{% set slogan = get_the_user__full_category(chat_ar.category) %}
{% set img___url = asset(user_avatar(chat_ar.user_ref,false)) %}
{% endif %}
{% else %}
{# using group reference is not empty #}
{% set key___ref = 'g___' ~ chat_ar.internalChatGroup_ref %}
{% set name___ref = chat_ar.icg_name %}
{% set slogan = chat_ar.icg_description %}
{% set img___url = '' %}
{% endif %}
{% if key___ref in ar__of_users %}
{% else %}
{% if chat_ar.icg_name is empty %}
{% else %}
G
{% endif %}
{{ name___ref }}
{% if chat_ar._unread_counter__ %}
{{ chat_ar._unread_counter__ }}
{% endif %}
{# add message to or message from reference in it#}
{% set ar__of_users = ar__of_users|merge([chat_ar.user_ref,chat_ar.user_ref__from]) %}
{% endif %}
{% endfor %}
{% endif %}
{# group list in which I'm involved #}
{% if involvements_in_groups is not empty %}
{{ 'Group List'|trans }}
{% for group in involvements_in_groups %}
{% for uU in group.getInternalChatGroupUsers.toArray() %}
{% endfor %}
G