{% extends "hyperkitty/user_profile/base.html" %}
{% load i18n %}
{% load hk_generic %}
{% load pagination %}


{% block user_profile_content %}

    {% if last_views %}
        <table class="table table-bordered table-sm d-md-none">
            <tbody>
            {% for lv in last_views %}
                {% ifchanged lv.thread.mailinglist.name %}
                <tr class="list-address">
                    <td>{{ lv.thread.mailinglist.name }}</td>
                </tr>
                {% endifchanged %}
                <tr>
                    <td>
                        {% with num_unread=lv.num_unread starting_email=lv.thread.starting_email %}
                        {% if num_unread %}
                        <i class="unread icon-eye-close" title="{% trans 'New comments' %}"></i>
                        {% endif %}
                        <a href="{% url 'hk_thread' mlist_fqdn=lv.thread.mailinglist.name threadid=lv.thread.thread_id %}"
                            >{{ starting_email.subject }}</a>
                        <br>
                        {% trans "Original author:" %} {{ starting_email.sender_name|default:starting_email.sender.address }}
                        <br>
                        {% trans "Started on:" %} {{ starting_email.date|date:"D, j M Y H:i" }}
                        <br>
                        {% trans "Last activity:" %} {{ lv.thread.date_active|timesince }}
                        <br>
                        {% trans "Replies:" %} {{ lv.thread|num_comments }}
                        {% if num_unread %} / {{ num_unread }} {% trans "new" %} {% endif %}
                        {% endwith %}
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
        <table class="table table-striped table-bordered table-sm d-none d-md-table">
            <thead>
                <tr>
                    <th></th>
                    <th>{% trans "List" %}</th>
                    <th>{% trans "Subject" %}</th>
                    <th>{% trans "Original author" %}</th>
                    <th>{% trans "Start date" %}</th>
                    <th>{% trans "Last activity" %}</th>
                    <th>{% trans "Replies" %}</th>
                </tr>
            </thead>
            <tbody>
            {% for lv in last_views %}
                <tr>
                    {% with num_unread=lv.num_unread starting_email=lv.thread.starting_email %}
                    <td>
                        {% if num_unread %}
                        <i class="unread icon-eye-close" title="{% trans 'New comments' %}"></i>
                        {% endif %}
                    </td>
                    <td>
                        <span class="hidden-md hidden-lg">{{ lv.thread.mailinglist.name|until:"@" }}</span>
                        <span class="hidden-sm">{{ lv.thread.mailinglist.name }}</span>
                    </td>
                    <td><a href="{% url 'hk_thread' mlist_fqdn=lv.thread.mailinglist.name threadid=lv.thread.thread_id %}"
                            >{{ starting_email.subject }}</a></td>
                    <td>{{ starting_email.sender_name|default:starting_email.sender.address }}</td>
                    <td>{{ starting_email.date }}</td>
                    <td>{{ lv.thread.date_active|timesince }}</td>
                    <td>
                        {{ lv.thread|num_comments }}
                        {% if num_unread %} / {{ num_unread }} {% trans "new" %} {% endif %}
                    </td>
                    {% endwith %}
                </tr>
            {% endfor %}
            </tbody>
        </table>
        {% paginator last_views qsprefix="lv" bydate=True %}
    {% else %}
        <p>{% trans "Nothing read yet." %}</p>
    {% endif %}

{% endblock %}
