{% extends "dictionary/base.html" %}
{% load filters functions i18n %}

{% block title %}{% trans "activity" context "titleblock" %}{% endblock %}
{% block content %}
    <div class="left-frame-in">
        <h1 class="h4 description"><strong>{% trans "activity" context "titleblock" %}</strong></h1>

        {% if user.allow_site_announcements %}
            <ul class="list-group topic-list">
                <li class="list-group-item{% if user.unread_topic_count.announcements > 0 %} active{% endif %}">
                    <a href="{% url 'announcements-index' %}">
                        <div class="d-flex align-items-center">
                            <svg class="mr-2" fill="currentColor" width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
                                <use href="#megaphone"></use>
                            </svg>
                            <span>{% trans "site announcements" %}</span>
                        </div>
                        {% if user.unread_topic_count.announcements > 0 %}
                            <small class="total_entries">{{ user.unread_topic_count.announcements }}</small>
                        {% endif %}
                    </a>
                </li>
            </ul>
            <hr class="mt-0">
        {% endif %}

        {% if topics.exists %}
            <small class="mb-2 d-flex justify-content-between align-items-center fs-90">
                <span>{% blocktrans count topic_count=page_obj.paginator.count %}following {{ topic_count }} topic{% plural %}following {{ topic_count }} topics{% endblocktrans %}</span>
                {% if user.unread_topic_count.topics > 0 %}
                    <form method="post">
                        {% csrf_token %}
                        <button type="submit" class="btn btn-sm" onclick="return confirm('{% trans "Are you sure?" %}')">{% trans "mark all topics as read" %}</button>
                    </form>
                {% endif %}
            </small>

            <ul id="topic-list-standalone" class="list-group topic-list">
                {% for topic in topics %}
                    <li class="list-group-item{% if not topic.is_read %} active{% endif %}">
                        <a href="{{ topic.get_absolute_url }}?a=following&d={{ topic.last_read_at|date:"U" }}">
                            <span>{{ topic.title }}</span>
                            {% if not topic.is_read %}
                                <small class="total_entries">{{ topic.count }}</small>
                            {% endif %}
                        </a>
                    </li>
                {% endfor %}
            </ul>
        {% endif %}

        {% include "dictionary/includes/paginaton.html" with paginator=page_obj stretch="yes" classlist="lf_pagination my-4" %}
    </div>
{% endblock %}
