{% extends "dictionary/conversation/inbox_base.html" %}
{% load filters humanize i18n %}

{% block title %}{% trans "conversation archive" context "titleblock" %}{% endblock %}

{% block innercontent %}
    {% if conversations %}
        <ul class="threads" data-mode="archived">
            {% for object in conversations %}
                {% with lastmsg=object.to_json.messages|last %}
                    <li class="chat" data-id="{{ object.pk }}">
                        <a href="{{ object.get_absolute_url }}">
                            <header class="d-flex justify-content-between">
                                <h2 class="h5">{{ object.target }}</h2>
                                <div class="custom-control custom-checkbox">
                                    <input type="checkbox" class="chat-selector custom-control-input" id="_arc{{ object.pk }}">
                                    <label class="text-hide custom-control-label" for="_arc{{ object.pk }}">{% trans "select" %}</label>
                                </div>
                            </header>
                            <p>{{ lastmsg.body|truncatechars:225 }}</p>
                        </a>

                        <footer class="d-flex justify-content-between fs-90">
                            <div>
                                <a role="button" tabindex="0" class="chat-delete-individual mr-1">{% trans "delete" %}</a>
                            </div>
                            <time>{{ lastmsg.sent_at|strdate|naturalday }}</time>
                        </footer>
                    </li>
                {% endwith %}
            {% endfor %}
        </ul>
    {% else %}
        <div class="border rounded p-3 bg-light">{% trans "your archive is empty 🤔" %}</div>
    {% endif %}
{% endblock %}
