{% import "chats/macros.html" as m with context %} {# one conversation beside its list: its messages and what it is about; one waiting for a decision, the question about it and who it is #} {% if opened %} {% set agent = opened.agent %} {% set conversation = opened.detail.conversation %} {% set address = ref(agent.id) ~ "/" ~ ref(conversation.thread_id) %} {% set kind = t.text("chats.kind." ~ conversation.kind) %} {% if conversation.review == "pending" %}
{% include "chats/review.html" %}

{{ t.text("chats.contact") }}

{{ m.face(conversation, "av sm") }}
{{ m.named(conversation) }}{{ m.logo(conversation.channel) }}{% if conversation.handle %}@{{ conversation.handle }}{% else %}{{ kind }}{% if conversation.kind == "group" %} · {{ t.text("chats.members", {"n": conversation.member_count}) }}{% endif %}{% endif %}

{{ t.text("chats.conversation") }}

{{ t.text("chats.first") }}{{ opened.detail.created_at_ms | moment }}
{{ t.text("chats.messages") }}{{ t.text("chats.messages.count", {"n": "{:,}".format(opened.detail.message_count)}) }}
{% set reply = opened.reply %}{% set update = opened.update %}{% set failed = false %}{% set named = true %} {% include "chats/reply.html" %}
{% else %}
{{ m.face(conversation, "gav") }}

{{ m.named(conversation) }}

{{ m.logo(conversation.channel) }}{{ t.text("chats.where", {"channel": m.channel(conversation.channel) | trim, "kind": kind}) }}{% if conversation.kind == "group" %} · {{ t.text("chats.members", {"n": conversation.member_count}) }}{% endif %} · {{ t.text("chats.replies", {"agent": agent.name}) }}
{{ m.icon("alarm-clock") }}
{# the messages: the newest when it opens, or those around one the search found; each way, more as it scrolls, and new ones as they come #}
{% if opened.history.has_before and opened.history.messages %}
{% endif %} {% set messages = opened.history.messages %}{% set receipts = opened.receipts %}{% set around = opened.around %} {% include "chats/said.html" %} {% if opened.history.has_after and opened.history.messages %}
{% endif %} {% set working = opened.working %} {% include "chats/working.html" %}
{% if opened.around %}
{{ m.icon("chevron-down") }}{{ t.text("chats.latest") }}
{% endif %}
{{ m.icon("lock") }}{{ t.text("chats.readonly." ~ conversation.kind, {"agent": agent.name, "channel": m.channel(conversation.channel) | trim}) }}
{{ m.face(conversation) }}
{{ m.named(conversation) }}{{ kind }}{% if conversation.kind == "group" %} · {{ t.text("chats.members", {"n": conversation.member_count}) }}{% endif %} · {{ t.text("chats.replies", {"agent": agent.name}) }}

{{ t.text("chats.members.title") }}{{ opened.detail.members | length }}

{% for member in opened.detail.members %} {% set name = m.who(member.sender) | trim %}
{{ name[:1] | upper }}
{{ name }}{% if member.is_self %}{{ t.text("chats.tag.self") }}{% elif member.sender_kind == "agent" %}{{ t.text("chats.tag.agent") }}{% elif member.sender_kind == "system" %}{{ t.text("chats.tag.system") }}{% else %}{{ t.text("chats.tag.human") }}{% endif %}
{% endfor %}

{{ m.icon("alarm-clock") }}{{ t.text("chats.reminders") }}{{ opened.reminders | length }}

{% for reminder in opened.reminders %}
{{ m.icon("alarm-clock") }}
{{ m.when(reminder) }}
{{ reminder.title }}
{% else %}

{{ t.text("chats.reminders.none") }}

{% endfor %}

{{ t.text("chats.conversation") }}

{{ t.text("chats.review") }}{% if conversation.review == "approved" %}{{ m.icon("circle-check") }}{{ t.text("chats.review.approved") }}{% if opened.approve %}{% endif %}{% else %}{{ t.text("chats.review.denied") }}{% endif %}
{{ t.text("chats.first") }}{{ opened.detail.created_at_ms | moment }}
{{ t.text("chats.messages") }}{{ t.text("chats.messages.count", {"n": "{:,}".format(opened.detail.message_count)}) }}
{% endif %} {% else %}

{{ t.text("chats.unavailable") }}

{% endif %}