{% from "_macros.html" import icon %} {# A folder and everything under it. Recursive: a folder includes this same template for each of its children, so nesting has no fixed depth limit. Open/closed state is local to the browser (Alpine), not persisted per request -- collapsing a folder should not cost a round trip. #}
{# Bound once: the loop and the "Empty" check must be looking at the same list, or a folder holding only archived chats claims to be empty while showing them. Narrowed by the sidebar's switch, so a folder shows one kind at a time -- a folder is free to hold both. #} {% set listed = folder.visible_chats(sidebar_kind | default("")) %} {% set shown = folder.visible_children(sidebar_kind | default("")) %} {% for child in shown %} {% with folder = child %} {% include "partials/_folder.html" %} {% endwith %} {% endfor %} {% for chat_item in listed %} {% include "partials/_chat_link.html" %} {% endfor %} {% if not shown and not listed %} {% endif %}