aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus@riseup.net>2024-10-12 17:30:41 +0200
committermarty hiatt <martianhiatus@riseup.net>2024-10-12 17:30:41 +0200
commit64a0a0a276b5cadc8b4d98ee28ef1c23b4a799b7 (patch)
treec01e61c4b846de5033772209a1b9a27d2d9e4a05 /lisp
parent3190c2833a1fbaeafe82585e7e6d494f8081b597 (diff)
use byline-username/-handle in notifications--byline-accounts
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-notifications.el71
-rw-r--r--lisp/mastodon-tl.el10
2 files changed, 29 insertions, 52 deletions
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index 73c20f1..7632173 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -278,56 +278,33 @@ JSON is the full notifications JSON."
;; we provide account directly, rather than let-alisting toot
;; almost everything is .account.field anyway
;; but toot still needed also, for attachments, etc.
-(defun mastodon-notifications--byline-account
- (accounts toot &optional avatar domain)
+(defun mastodon-notifications--byline-accounts
+ (accounts toot group &optional avatar domain)
"Propertize author byline ACCOUNT for TOOT, the item responded to.
With arg AVATAR, include the account's avatar image.
When DOMAIN, force inclusion of user's domain in their handle."
- (cl-loop
- for account in accounts
- concat
- (let-alist account
- (concat
- ;; avatar insertion moved up to `mastodon-tl--byline' by default to
- ;; be outside 'byline propt.
- (when (and avatar ; used by `mastodon-profile--format-user'
- mastodon-tl--show-avatars
- mastodon-tl--display-media-p
- (mastodon-tl--image-trans-check))
- (mastodon-media--get-avatar-rendering .avatar))
- ;; username:
- (propertize (if (not (string-empty-p .display_name))
- .display_name
- .username)
- 'face 'mastodon-display-name-face
- ;; enable playing of videos when point is on byline:
- 'attachments (mastodon-tl--get-attachments-for-byline toot)
- 'keymap mastodon-tl--byline-link-keymap
- ;; echo faves count when point on post author name:
- ;; which is where --goto-next-toot puts point.
- 'help-echo
- ;; but don't add it to "following"/"follows" on profile views:
- ;; we don't have a tl--buffer-spec yet:
- (unless (or (string-suffix-p "-followers*" (buffer-name))
- (string-suffix-p "-following*" (buffer-name)))
- (mastodon-tl--format-byline-help-echo toot)))
- ;; handle:
- " ("
- (propertize (concat "@" .acct
- (when domain
- (concat "@"
- (url-host
- (url-generic-parse-url .url)))))
- 'face 'mastodon-handle-face
- 'mouse-face 'highlight
- 'mastodon-tab-stop 'user-handle
- 'account account
- 'shr-url .url
- 'keymap mastodon-tl--link-keymap
- 'mastodon-handle (concat "@" .acct)
- 'help-echo (concat "Browse user profile of @" .acct))
- ")"
- (if (< 1 (length accounts)) "\n" "")))))
+ (let ((others-count (- (alist-get 'notifications_count group)
+ (length accounts))))
+ (concat
+ (cl-loop
+ for account in accounts
+ concat
+ (let-alist account
+ (concat
+ ;; avatar insertion moved up to `mastodon-tl--byline' by default to
+ ;; be outside 'byline propt.
+ (when (and avatar ; used by `mastodon-profile--format-user'
+ mastodon-tl--show-avatars
+ mastodon-tl--display-media-p
+ (mastodon-tl--image-trans-check))
+ (mastodon-media--get-avatar-rendering .avatar))
+ ;; username:
+ (mastodon-tl--byline-username toot account)
+ ;; handle:
+ " (" (mastodon-tl--byline-handle toot nil account) ")"
+ (if (< 1 (length accounts)) "\n" ""))))
+ (if (< 0 others-count)
+ (format "and %s others" others-count)))))
(defun mastodon-notifications--by-type (groups json)
"Filter NOTE for those listed in `mastodon-notifications--types-alist'.
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 0f04e58..ca5ec6f 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -589,9 +589,9 @@ Do so if type of status at poins is not follow_request/follow."
(string= type "follow")) ; no counts for these
(message "%s" echo)))))
-(defun mastodon-tl--byline-username (toot)
+(defun mastodon-tl--byline-username (toot &optional account)
"Format a byline username from account in TOOT."
- (let-alist (alist-get 'account toot)
+ (let-alist (or account (alist-get 'account toot))
(propertize (if (not (string-empty-p .display_name))
.display_name
.username)
@@ -609,10 +609,10 @@ Do so if type of status at poins is not follow_request/follow."
(string-suffix-p "-following*" (buffer-name)))
(mastodon-tl--format-byline-help-echo toot)))))
-(defun mastodon-tl--byline-handle (toot &optional domain)
+(defun mastodon-tl--byline-handle (toot &optional domain account)
"Format a byline handle from account in TOOT.
DOMAIN is optionally added to the handle."
- (let-alist (alist-get 'account toot)
+ (let-alist (or account (alist-get 'account toot))
(propertize (concat "@" .acct
(when domain
(concat "@"
@@ -621,7 +621,7 @@ DOMAIN is optionally added to the handle."
'face 'mastodon-handle-face
'mouse-face 'highlight
'mastodon-tab-stop 'user-handle
- 'account .account
+ 'account account
'shr-url .url
'keymap mastodon-tl--link-keymap
'mastodon-handle (concat "@" .acct)