diff --git a/templates/cards/blocks/note.html.twig b/templates/cards/blocks/note.html.twig index 07edc625cc..3e63bf61a1 100644 --- a/templates/cards/blocks/note.html.twig +++ b/templates/cards/blocks/note.html.twig @@ -93,28 +93,42 @@ {% endblock note_info %} +{% macro mention_anchor(target) %} + {{mention(target)}} +{% endmacro mention_anchor %} + {% block note_context %} {% set notification_targets = note.getNotificationTargets() %} - {% if notification_targets is not empty %} - {% for target in notification_targets %} - {% if target.isGroup() %} - - {% set mentionAnchor %}{{ mention(target) | raw }}{% endset %} - {% trans %}in %mentionAnchor%{% endtrans %} - - {% else %} - - {% set replyAnchor %}{% endset %} - {% set mentionAnchor %}{{ mention(target) | raw }}{% endset %} - {% trans %}%replyAnchor% in reply to %mentionAnchor%{% endtrans %} - - {% endif %} - {% endfor %} + {% set notification_targets_individuals = notification_targets|filter(nt => nt.isGroup() == false) %} + {% set mention_individuals = [] %} + {% for target in notification_targets_individuals %} + {% set mention_individuals = mention_individuals|merge([_self.mention_anchor(target)]) %} + {% endfor %} + + {% set notification_targets_groups = notification_targets|filter(nt => nt.isGroup()) %} + {% set mention_groups = [] %} + {% for target in notification_targets_groups %} + {% set mention_groups = mention_groups|merge([_self.mention_anchor(target)]) %} + {% endfor %} + + {% if notification_targets_individuals is not empty %} + + {% set mentions_anchors = mention_individuals|join(' ⃕ ') %} + {% trans %}in reply to %mentions_anchors%{% endtrans %} + + {% endif %} + + {% if notification_targets_groups is not empty %} + + {% set mentions_anchors = mention_groups|join(', ', ' and ') %} + {% trans %}in %mentions_anchors%{% endtrans %} + {% endif %} {% endblock note_context %}