{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template core_message/message_drawer_conversations_list

    This template will render a list of conversations for the message drawer.

    Classes required for JS:
    * none

    Data attributes required for JS:
    * All data attributes are required

    Context variables required for this template:
    * userid The logged in user id
    * urls The URLs for the popover

    Example context (json):
    {}

}}

{{#conversations}}
    <a
        href="javascript:void(0)"
        class="px-10 d-flex list-group-item list-group-item-action align-items-center"
        data-conversation-id="{{id}}"
        {{#userid}}
            data-user-id="{{.}}"
        {{/userid}}
    >

        <div class="media">
            <div class="pr-10">
                
                <div style="width: 30px;" class="avatar avatar-sm {{#showonlinestatus}}{{^isblocked}}{{#isonline}}avatar-online{{/isonline}}{{^isonline}}avatar-off{{/isonline}}{{/isblocked}}{{/showonlinestatus}}">
                    {{#imageurl}}
                        <img
                            src="{{{.}}}"
                            alt="{{name}}"
                            aria-hidden="true"
                        >
                    {{/imageurl}}

                    {{^isblocked}}<i style="width: 12px; height: 12px;"></i>{{/isblocked}}
                    
                    {{#isblocked}}
                        <i class="icon fa fa-ban fa-fw text-dark" aria-hidden="true" title="{{#str}} contactblocked, message {{/str}}" aria-label="{{#str}} contactblocked, message {{/str}}" data-region="contact-icon-blocked">
                        </i>
                    {{/isblocked}}
                </div>



            </div>

            <div class="media-body">
                <small class="position-absolute font-size-10 position-right d-flex align-self-center align-items-center {{^lastmessagedate}}hidden{{/lastmessagedate}}" data-region="last-message-date">
                    {{#lastmessagedate}}
                        {{#userdate}} {{.}}, {{#str}} strftimetime24, core_langconfig  {{/str}} {{/userdate}}
                    {{/lastmessagedate}}
                </small>
                
                <h5 class="mt-0 mb-5 text-truncate mr-10">{{name}}</h5>
                {{#subname}}
                    <p class="m-0 text-truncate font-size-10">{{.}}</p>
                {{/subname}}
                {{#unreadcount}}
                <span class="position-absolute font-size-10 position-right d-flex align-self-center align-items-center badge badge-pill badge-important {{^unreadcount}}hidden{{/unreadcount}}"data-region="unread-count">
                    {{unreadcount}}
                </span>
                {{/unreadcount}}
                <span class="text-truncate font-size-12" data-region="last-message">
                    {{#sentfromcurrentuser}}
                        {{#str}} you, core_message {{/str}}
                    {{/sentfromcurrentuser}}
                    {{^sentfromcurrentuser}}
                        {{#lastsendername}}
                            {{#str}} sender, core_message, {{.}} {{/str}}
                        {{/lastsendername}}
                    {{/sentfromcurrentuser}}
                    {{lastmessage}}
                </span>
            </div>
        </div>
    </a>
{{/conversations}}
