branch: elpa/mastodon commit 0aaa2fb42d34adb5126052d68b60f7155170ea85 Author: marty hiatt <martianhia...@disroot.org> Commit: marty hiatt <martianhia...@disroot.org>
refactor mastodon-notifications--follower-name --- lisp/mastodon-notifications.el | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index ed27574e6b..5730a95e08 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -302,8 +302,7 @@ Can be called in notifications view or in follow-requests view." str)))) (status (mastodon-tl--field 'status note)) (follower (alist-get 'account note)) - (follower-name (or (alist-get 'display_name follower) - (alist-get 'username follower))) + (follower-name (mastodon-notifications--follower-name follower)) (filtered (mastodon-tl--field 'filtered status)) (filters (when filtered (mastodon-tl--current-filters filtered)))) @@ -340,8 +339,7 @@ ACCOUNTS is data of the accounts that have reacted to the notification." str)))) (follower (when (member type '(follow follow_request)) (car accounts))) - (follower-name (or (alist-get 'display_name follower) - (alist-get 'username follower))) + (follower-name (mastodon-notifications--follower-name follower)) (filtered (mastodon-tl--field 'filtered status)) (filters (when filtered (mastodon-tl--current-filters filtered)))) @@ -362,6 +360,12 @@ ACCOUNTS is data of the accounts that have reacted to the notification." status) folded group accounts)))))) +(defun mastodon-notifications--follower-name (follower) + "Return display_name or username of FOLLOWER." + (if (not (string= "" (alist-get 'display_name follower))) + (alist-get 'display_name follower) + (alist-get 'username follower))) + (defun mastodon-notifications--comment-note-text (str) "Add comment face to all text in STR with `shr-text' face only." (with-temp-buffer