{% extends "layouts/" + render_mode + ".html" %} {% block title %}{{ nice_subject(result.data.metadata[result.thread_ids[-1]]) }}{% endblock %} {% block content %} {% if result %} {% set start_mid = result.thread_ids[-1] %} {% set last_mid = result.thread_ids.0 %} {% set start_subject = result.data.metadata[start_mid].subject %} {% set profiles = mailpile('profiles').result %} {% set loop_history = [] %} {% for mid in result.thread_ids|reverse %} {% set metadata = result.data.metadata.get(mid) %} {% set message = result.data.messages.get(mid) %} {# Render the composer #} {% if message and "editing_strings" in message %} {% set editing_strings = message.editing_strings %} {% set editing_addresses = result.data.addresses %} {% set attachments = message.attachments %} {% include("partials/compose.html") %} {% do loop_history.append("edit message") %} {# Render full message #} {% elif message %} {% include("partials/thread_message.html") %}{# Show: Message #} {% set show_reply = (mid != last_mid) %} {% do loop_history.append("display message") %} {# Message is a draft, show composer #} {% elif metadata.flags.draft %} {# FIXME: We should probably just tell the user this is a draft, make loading the composer a manual action UNLESS this is the last message in the the thread. #} {% set compose = mailpile('message/draft', 'all', '='+mid).result %}{# Gets Ephermal message #} {% if compose %} {% do loop_history.append("edit draft") %} {% set mid = compose.message_ids.0 %} {% if "editing_strings" in compose.data.messages[mid] %} {% set editing_strings = compose.data.messages[mid].editing_strings %} {% set editing_addresses = compose.data.addresses %} {% set attachments = compose.data.messages[mid].attachments %} {% include("partials/compose.html") %} {% endif %} {% else %} {{_("Could Not Render Composer")}} {% endif %} {% else %}{# Just render snippet view #}
{% set from = metadata.from %} {% include("partials/thread_metadata.html") %} {% if metadata.crypto.encryption in ("lockedkey", "missingkey", "error", "mixed-lockedkey", "mixed-missingkey", "mixed-error") %}
{{_("Unable to see message preview")}}
{% else %}
{{ metadata.body.snippet }}
{% endif %}
{% do loop_history.append("display snippet") %} {% endif %} {% endfor %}{# End for loop #} {% if loop_history|last not in ("edit draft", "edit message") %} {# Give the user the option to reply to the last message in the thread unless we already did! #} {% set compose = mailpile('message/reply', 'all', 'ephemeral', '='+last_mid).result %}{# Gets Ephermal message #} {% if compose %} {% set mid = compose.message_ids.0 %} {% set editing_strings = compose.data.messages[mid].editing_strings %} {% set editing_addresses = compose.data.addresses %} {% set attachments = compose.data.messages[mid].attachments %} {% include("partials/compose.html") %} {% else %} {{_("Could Not Render Composer")}} {% endif %} {% endif %}
{% else %}{# No Result, Show Error #} {% set error_title = "message_missing" %} {% include("partials/errors_content.html") %} {% endif %}{# if result #} {% endblock %}