4040 :type 'integer
4141 :group 'pr-review )
4242
43+ (defvar pr-review-reaction-emojis
44+ '((" CONFUSED" . " 😕" )
45+ (" EYES" . " 👀" )
46+ (" HEART" . " ❤️" )
47+ (" HOORAY" . " 🎉" )
48+ (" LAUGH" . " 😄" )
49+ (" ROCKET" . " 🚀" )
50+ (" THUMBS_DOWN" . " 👎" )
51+ (" THUMBS_UP" . " 👍" ))
52+ " Alist of github reaction name to emoji unicode.
53+ See https://docs.github.com/en/graphql/reference/enums#reactioncontent" )
54+
4355(defun pr-review--format-timestamp (str )
4456 " Convert and format timestamp STR from json."
4557 (concat
@@ -154,6 +166,23 @@ in addition to other faces."
154166 (when extra-face
155167 (add-face-text-property start end extra-face))))
156168
169+ (defun pr-review--maybe-insert-reactions (reaction-group &optional indent )
170+ " Insert REACTION-GROUP if not nil.
171+ INDENT is an optional number of extra spaces at the start of the line."
172+ (let (s)
173+ (dolist (group reaction-group)
174+ (let-alist group
175+ (when (and (> .reactors.totalCount 0 ) .content)
176+ (when s
177+ (setq s (concat s " " )))
178+ (setq s (concat s (format " %s *%d "
179+ (alist-get .content pr-review-reaction-emojis .content nil 'equal )
180+ .reactors.totalCount))))))
181+ (when s
182+ (when indent
183+ (insert (propertize " " 'display `(space :width (,(* indent pr-review--char-pixel-width))))))
184+ (insert (propertize s 'face 'pr-review-reaction-face ) " \n " ))))
185+
157186(defun pr-review--fontify (body lang-mode &optional margin )
158187 " Fontify content BODY as LANG-MODE, return propertized string.
159188MARGIN is an optional number, if provided,
@@ -416,6 +445,7 @@ It will be inserted at the beginning."
416445 (pr-review--format-timestamp .createdAt))
417446 (pr-review--insert-html .bodyHTML (* 2 pr-review-section-indent-width)
418447 'pr-review-thread-comment-face )
448+ (pr-review--maybe-insert-reactions .reactionGroups (* 2 pr-review-section-indent-width))
419449 (insert " \n " ))))
420450 (let-alist review-thread .comments.nodes))
421451
@@ -456,6 +486,7 @@ It will be inserted at the beginning."
456486 (pr-review--format-timestamp .createdAt))
457487 (unless (string-empty-p .body)
458488 (pr-review--insert-html .bodyHTML))
489+ (pr-review--maybe-insert-reactions .reactionGroups)
459490 (insert " \n " )
460491 (dolist (top-comment-and-review-thread top-comment-and-review-thread-list)
461492 (apply #'pr-review--insert-review-thread-section top-comment-and-review-thread))
@@ -475,6 +506,7 @@ It will be inserted at the beginning."
475506 " - "
476507 (pr-review--format-timestamp .createdAt))
477508 (pr-review--insert-html .bodyHTML)
509+ (pr-review--maybe-insert-reactions .reactionGroups)
478510 (insert " \n " ))))
479511
480512(defun pr-review--insert-misc-event-section (event )
@@ -837,7 +869,8 @@ it can be displayed in a single line."
837869 (oset section body .body)
838870 (oset section updatable .viewerCanUpdate)
839871 (magit-insert-heading " Description" )
840- (pr-review--insert-html .bodyHTML))
872+ (pr-review--insert-html .bodyHTML)
873+ (pr-review--maybe-insert-reactions .reactionGroups))
841874 (insert " \n " )
842875 (when (< .timelineItems.filteredCount .timelineItems.totalCount)
843876 (insert (propertize (format " Timeline items truncated. Displaying last %d of %d .\n "
0 commit comments