Skip to content

Commit

Permalink
Change: (ement-room--format-reactions) Show name if only one sender
Browse files Browse the repository at this point in the history
  • Loading branch information
alphapapa committed Jan 9, 2024
1 parent b3a9487 commit 64424c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ Ement.el doesn't support encrypted rooms natively, but it can be used transparen

+ Customization group ~ement-room-list~.
+ Option ~ement-room-list-space-prefix~ is applied to space names in the room list (e.g. set to empty string for cleaner appearance).
+ Reactions sent by only one user are displayed with the user's name (so it's not necessary to check the tooltip).

*Changes*

Expand Down
13 changes: 8 additions & 5 deletions ement-room.el
Original file line number Diff line number Diff line change
Expand Up @@ -943,8 +943,8 @@ spec) without requiring all events to use the same margin width."

(ement-room-define-event-formatter ?r
"Reactions."
(ignore room session)
(ement-room--format-reactions event))
(ignore session)
(ement-room--format-reactions event room))

(ement-room-define-event-formatter ?t
"Timestamp."
Expand Down Expand Up @@ -3349,14 +3349,17 @@ Formats according to `ement-room-message-format-spec', which see."
(propertize " "
'display ement-room-event-separator-display-property)))

(defun ement-room--format-reactions (event)
"Return formatted reactions to EVENT."
(defun ement-room--format-reactions (event room)
"Return formatted reactions to EVENT in ROOM."
;; TODO: Like other events, pop to a buffer showing the raw reaction events when a key is pressed.
(if-let ((reactions (map-elt (ement-event-local event) 'reactions)))
(cl-labels ((format-reaction (ks)
(pcase-let* ((`(,key . ,senders) ks)
(key (propertize key 'face 'ement-room-reactions-key))
(count (propertize (format " (%s)" (length senders))
(count (propertize (format " (%s)"
(if (length= senders 1)
(ement--user-displayname-in room (car senders))
(length senders)))
'face 'ement-room-reactions))
(string
(propertize (concat key count)
Expand Down

0 comments on commit 64424c1

Please sign in to comment.