{% extends 'stdgrid.html.twig' %}
{% import '/cards/macros/note/factory.html.twig' as NoteFactory %}

{% block title %}{% if page_title is defined %}{% trans %}%page_title%{% endtrans %}{% endif %}{% endblock %}

{% block stylesheets %}
    {{ parent() }}
    <link rel="stylesheet" href="{{ asset('assets/default_theme/feeds.css') }}" type="text/css">
{% endblock stylesheets %}

{% block body %}
    {% for block in handle_event('BeforeFeed', app.request) %}
        {{ block | raw }}
    {% endfor %}

    {% if notes is defined %}
        <header class="feed-header">
            {% set current_path = app.request.get('_route') %}
            {% if notes_feed_title is defined %}
                {{ notes_feed_title.getHtml() }}
            {% endif %}
            <nav class="feed-actions" title="{% trans %}Actions that change how the feed behaves{% endtrans %}">
                <details class="feed-actions-details" role="group">
                    <summary>
                        {{ icon('filter', 'icon icon-feed-actions') | raw }} {# button-container #}
                    </summary>
                    <menu class="feed-actions-details-dropdown" role="toolbar">
                        {% for block in handle_event('AddFeedActions', app.request, notes is defined and notes is not empty) %}
                            {{ block | raw }}
                        {% endfor %}
                    </menu>
                </details>
            </nav>
        </header>

        {% if notes is not empty %}
            {# Backwards compatibility with hAtom 0.1 #}
            <section class="feed h-feed hfeed notes" role="feed" aria-busy="false" title="{% trans %}Feed content{% endtrans %}">
                {% for conversation in notes %}
                    {% block current_note %}
                        {% if conversation is instanceof('array') %}
                            {% set args = conversation | merge({'type': 'vanilla_full'}) %}
                            {{ NoteFactory.constructor(args) }}
{#                        {% else %}
                            {% set args = { 'type': 'vanilla_full', 'note': conversation, 'extra': { 'depth': 0 } } %}
                            {{ NoteFactory.constructor(args) }}#}
                        {% endif %}
                        <hr class="hr-replies-end" role="separator" aria-label="{% trans %}Marks the end of previous conversation's initial note{% endtrans %}">
                    {% endblock current_note %}
                {% endfor %}
            </section>
        {% else %}
            <section class="feed h-feed hfeed notes" tabindex="0" role="feed">
                <span>{% trans %}No notes here...{% endtrans %}</span>
            </section>
        {% endif %}
    {% endif %}
{% endblock body %}
