issue/activity: concatenate similar replies
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 27 Apr 2021 18:43:52 +0000 (20:43 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 27 Apr 2021 19:12:30 +0000 (21:12 +0200)
Omit title for unchanged ticket and author,
causing stacked images from different messages.
Don't bother with closing <dd> for simplicity.

widget/issue/activity.php

index 153034efb84124dba0476239382858daab2ce74e..23b95c6b9890d050c5bd282711d724df289e5ff5 100644 (file)
@@ -17,28 +17,29 @@ $msgformat = [
 
 print '<dl class="replies">';
 
-$group = NULL;
+$prev = NULL;
 while ($row = $query->fetch()) {
-       print '<dt>';
-       if ($group !== $row->issue) {
-               $group = $row->issue;
-               printf('<a href="/%s">%s</a>', $row->page, $row->subject);
-               if ($row->closed) {
-                       print ' <em>(opgelost)</em>';
+       if (!$prev or $prev->issue !== $row->issue or $prev->author !== $row->author) {
+               print '<dt>';
+               if (!$prev or $prev->issue !== $row->issue) {
+                       printf('<a href="/%s">%s</a>', $row->page, $row->subject);
+                       if ($row->closed) {
+                               print ' <em>(opgelost)</em>';
+                       }
                }
+               print '<span class="right">';
+               if ($row->author and $rowuser = new User("profile/{$row->author}")) {
+                       printf('<strong>%s</strong> ', $rowuser->html);
+               }
+               printf('<small class="date">%s</small>',
+                       showdate(preg_split('/\D/', $row->created))
+               );
+               print "</span>";
+               print '</dt>';
+               print '<dd>';
        }
-       print '<span class="right">';
-       if ($row->author and $rowuser = new User("profile/{$row->author}")) {
-               printf('<strong>%s</strong> ', $rowuser->html);
-       }
-       printf('<small class="date">%s</small>',
-               showdate(preg_split('/\D/', $row->created))
-       );
-       print "</span>";
-       print '</dt>';
-       print '<dd>';
        print preg_replace(array_keys($msgformat), array_values($msgformat), $row->message);
-       print "</dd>\n";
+       $prev = $row;
 }
 
 print "</dl>\n";