summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mumi/web/view/html.scm51
1 files changed, 28 insertions, 23 deletions
diff --git a/mumi/web/view/html.scm b/mumi/web/view/html.scm
index b212972..5959bac 100644
--- a/mumi/web/view/html.scm
+++ b/mumi/web/view/html.scm
@@ -1,5 +1,5 @@
;;; mumi -- Mediocre, uh, mail interface
-;;; Copyright © 2016, 2017, 2018, 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2016, 2017, 2018, 2019, 2020, 2021 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2018, 2019 Arun Isaac <arunisaac@systemreboot.net>
;;;
;;; This program is free software: you can redistribute it and/or
@@ -355,13 +355,18 @@ failed to process associated messages.")
(define* (issue-page bug #:optional flash-message)
"Render the conversation for the given BUG."
(define id (bug-num bug))
- (define messages
- (filter (lambda (msg)
- ;; Ignore messages without body, and internal messages.
- (and msg
- (email-body msg)
- (not (internal-message? msg))))
- (issue-messages id)))
+ (define all-messages-with-numbers
+ (let ((msgs (issue-messages id)))
+ (zip (iota (length msgs)) msgs)))
+ (define messages-with-numbers
+ (filter (match-lambda
+ ((number msg)
+ ;; Ignore messages without body, and internal messages.
+ (and msg
+ (email-body msg)
+ (not (internal-message? msg)))))
+ all-messages-with-numbers))
+ (define messages (map second messages-with-numbers))
(define parties (sort (filter (compose (negate bot?) extract-email)
(participants (filter identity messages)))
(lambda (a b)
@@ -370,20 +375,20 @@ failed to process associated messages.")
(define sidebar
`(ul (@ (id "sidebar")
(class "sticky-top flex-column"))
- ,(map (lambda (message message-number)
- `(li
- (div
- (@ (class "avatar")
- (style ,(string-append "background-color:"
- (avatar-color (sender-email message)
- (map extract-email parties)))))
- ,(string-upcase (string-take (sender-name message) 1)))
- (span (@ (class "date"))
- (a (@ (href ,(string-append "#" (number->string
- message-number))))
- ,(time->string (date message))))))
- messages
- (iota (length messages)))))
+ ,(map (match-lambda
+ ((message-number message)
+ `(li
+ (div
+ (@ (class "avatar")
+ (style ,(string-append "background-color:"
+ (avatar-color (sender-email message)
+ (map extract-email parties)))))
+ ,(string-upcase (string-take (sender-name message) 1)))
+ (span (@ (class "date"))
+ (a (@ (href ,(string-append "#" (number->string
+ message-number))))
+ ,(time->string (date message)))))))
+ messages-with-numbers)))
(define issue-details
`(span (@ (class "details"))
,(status-tag bug)
@@ -621,7 +626,7 @@ currently disabled."))
(div
(@ (class "conversation col-12"))
,(map show-message
- (iota (length messages))
+ (map car messages-with-numbers)
messages
(cons (bug-subject* bug)
(map subject messages)))