{% import "components.html" as c with context %} {% set url = c.messages_url(history.agent, history.contact) %} {# the top of what is loaded: while the conversation goes on before it, scrolling it into view asks for the page before, which takes its place; the column notes how tall it was, so the page can be put above what is being read without moving it #} {% if history.before %}
{{ c.icon("loader-circle") }}
{% endif %} {% if earlier is defined %}{% endif %} {# a day's turns start under a line with its date: the first loaded when there is nothing before it, and any whose day is not the one above; a page put above others ends with the line for the day below it, when that one starts there #} {% set ns = namespace(day=history.previous_ms|day if history.previous_ms else (history.turns[0].at_ms|day if history.before and history.turns else none)) %} {% for turn in history.turns %} {% set day = turn.at_ms|day %} {% if day != ns.day %}
{{ day }}
{% set ns.day = day %}{% endif %} {% if turn.kind == "system" %} {# what the node itself says - a reminder going off - is no one's turn: a line on the background, apart from the conversation #} {% for line in turn.lines %}
{{ turn.at_ms|time }}{{ line.body }}
{% endfor %} {% else %}
{{ c.avatar(turn.identity, small=true, opens=".turn" if turn.own else none) }} {% if turn.own %} {# the agent's own face opens onto what it is doing, the way its row in the list does; the card fetches itself the first time the pointer reaches the avatar, and shows by the pointer while it is there #}
{{ c.icon("loader-circle") }}
{% endif %}
{{ turn.speaker }}{% if turn.kind in ("agent", "human") %} {{ t.text("history." ~ turn.kind) }}{% endif %} {{ turn.at_ms|time }}
{% for line in turn.lines %}
{{ line.body|markdown }}{% for name in line.attachments %}
{{ c.icon("paperclip") }} {{ name }}
{% endfor %}
{% endfor %}
{% endif %} {% endfor %} {% if history.next_ms and history.turns and history.next_ms|day != ns.day %}
{{ history.next_ms|day }}
{% endif %}